Closes the accessory. The accessory input and output streams should be individually closed first.
DescriptionAsString [read only]
Gets the description of the accessory.
InputStreamAsInputStreamWrapper [read only]
Gets the input stream for the accessory. When reading data from an accessory ensure that the buffer that you use is big enough to store the USB packet data. The Android accessory protocol supports packet buffers up to 16384 bytes, so you can choose to always declare your buffer to be of this size for simplicity.
Represents a connection between the host and a client. UsbDeviceConnection is created by calling UsbManager.OpenDevice. Once connected you should call StartListening to start listening for completed requests. Sending requests is done with UsbRequest.Queue. The NewData event is raised when a request completes. The request is passed as a parameter. You should call ContinueListening to allow the listener to listen to the next completed request (after another IN request is sent). Calling StopListening will close the connection. ControlTransfer method sends requests to endpoint zero which is the control endpoint. ControlTransfer is a blocking method (unlike UsbRequest.Queue which is asynchronous).
Events:
NewData (Request As UsbRequest, InDirection As Boolean)
Sends a synchronous request. Endpoint - The endpoint for this transaction. The transfer direction is determined by this endpoint. Buffer - Buffer for data to send or receive. Length - The length of the data. Timeout - Request timeout in milliseconds.
CloseSynchronous
Closes the connection. StopListening also closes the connection. This method should only be used when the asynchronous listener was not started.
ContinueListening
Notifies the listener to continue listening for completed requests.
Performs a control transaction on endpoint zero. Returns the number of bytes transferred. RequestType - The request type. It should combine USB_DIR_IN or USB_DIR_OUT to set the request direction. Request - Request Id. Value - Value field. Index - Index field. Buffer - Buffer for data portion. Pass Null if not needed. Length - The length of the data to send or receive. Timeout - Timeout in milliseconds.
GetRawDescriptorsAsByte()
Returns the raw descriptors as an array of bytes. This method is only available in Android 3.2 or above.It will return an empty array in Android 3.1.
IsInitializedAsBoolean
Tests whether the object was initialized.
SerialAsString [read only]
Returns the connected device serial number.
StartListening (EventNameAsString)
Starts listening for completed requests. When such are available the NewData event will be raised. EventName - The name of the sub that will handle the events.
StopListening
Stops listening to requests and closes the connection.
UsbManager gives access to the connected Usb devices. It also holds the related constants. This library requires Android SDK 12 or above (Android 3.1 or above). You should configure Basic4android to use android.jar from android-12 or above.
Connects to the given device and claims exclusive access to the given interface. ForceClaim - Whether the system should disconnect kernel drivers if necessary.
Initializes the request. The request will be binded to the given connection and endpoint. Note that for control transactions you should use UsbDeviceConnection.ControlTransfer.
IsInitializedAsBoolean
NameAsString
Gets or sets an arbitrary string that can be used to identify the request.
Queue (Buffer() AsByte, LengthAsInt)
Queues the request for sending. UsbDeviceConnection_NewData event will be raised when the transaction completes.