Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Documentation
Sidebar

Class USBTransport

Hierarchy

java.lang.Object
     com.smartdevicelink.transport.SdlTransport

Package
com.smartdevicelink.transport

Overview

Class that implements USB transport. A note about USB Accessory protocol. If the device is already in the USB accessory mode, any side (computer or Android) can open connection even if the other side is not connected. Conversely, if one side simply disconnects, the other side will NOT be notified and unblocked from reading data until some data is sent again or the USB is physically disconnected.

Fields

ACTION_USB_ACCESSORY_ATTACHED

public static final java.lang.String ACTION_USB_ACCESSORY_ATTACHED
Constant Value
"com.smartdevicelink.USB_ACCESSORY_ATTACHED"

Constructors

USBTransport( USBTransportConfig usbTransportConfig, ITransportListener transportListener )

Constructs the USBTransport instance.

public USBTransport(USBTransportConfig usbTransportConfig,ITransportListener transportListener)

Parameters

usbTransportConfig
Config object for the USB transport
transportListener
Listener that gets notified on different transport events

Methods

getState()

Returns the current state of transport.

public com.smartdevicelink.transport.USBTransport.State getState()

sendBytesOverTransport( SdlPacket packet )

Sends the array of bytes over USB.

protected boolean sendBytesOverTransport(SdlPacket packet)

Parameters

packet
The packet that is to be written out on the USB transport

registerReciever()

public void registerReciever()

openConnection()

Opens a USB connection if not open yet.

public void openConnection() throws com.smartdevicelink.exception.SdlException

Throws

disconnect()

Closes the USB connection if open.

public void disconnect()

stopReading()

Asks the reader thread to stop while it's possible. If it's blocked on read(), there is no way to stop it except for physical USB disconnect.

public void stopReading()

getTransportType()

Returns the type of the transport.

public com.smartdevicelink.transport.enums.TransportType getTransportType()

isAccessorySupported( UsbAccessory accessory )

Checks if the specified connected USB accessory is what we expect.

public static boolean isAccessorySupported(UsbAccessory accessory)

Parameters

accessory
Accessory to check

getBroadcastComment()

public java.lang.String getBroadcastComment()

Inherited Methods

From Class Methods
com.smartdevicelink.transport.SdlTransport getIsConnected, handleReceivedPacket, sendBytesOverTransport, sendBytes, handleTransportConnected, handleTransportDisconnected, handleTransportError, openConnection, disconnect, getTransportType, getBroadcastComment
java.lang.Object getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize
View on GitHub.com
Previous Section Next Section