USB Accessories Support on Android

Melanie Gross
May 23, 2011
Updated • Dec 1, 2012
Google Android
|
1

In the recent past the Android users have been facing problems accessing the USB port efficiently for configuring their accessories to the Android powered phones or tablets. To solve these problems Android developers announced an all new Android Open Accessory API which permits the Android devices running on Android 3.1 or 2.3.4 to connect to USB accessories easily, without any additional fees or licensing. In the newly developed version the Android device does not act as a host, but instead gives accessories the right to be hosts and perform the corresponding functions.

The main function of the host is to act as a bus master which controls the data input and output channels and decide its use at varied times. The host also acts as the powered bus to provide power. In the computer world the laptop or the desktop acts as the host which performs as the bus master as well as providing power to the bus. While the other accessories such as the mouse, printer, webcam etc. act as the USB devices. Similarly in the smart phones the phone device acts as the host whereas its accessories act as the USB devices. But since very few Android powered devices support host mode to successfully connect the accessories as the USB devices, the Android developers turned the normal relationship on its head. Instead of using the phone or tablets as hosts, they act as USB Devices and the accessories acts as the USB Host. This means that the accessories act as the bus master and a powered bus.

The Open Accessory will consist of a USB host and a system to provide power to the Android Device such as a phone or tablet. Once the accessory is connected to the device the device will identify itself on the basis of its VID/PID (significant IDs which are unique to the Device model and manufacturer). Once the device is detected the accessory asks the device to switch to accessory mode by sending a series of control transactions to the device. While switching to accessory mode the device will reappear with the new VID/PID corresponding to the accessory mode. The above protocol will help the device to start in the accessory mode after the appropriate application is initiated. If the specific application is not found, the protocol will suggest a relevant URL for the application.

How to start Android device in accessory mode?

Step 1: Send a 51 control (“get protocol”) request to detect if the device supports Android Accessory Protocol. If the device supports the protocol, a non-zero number is returned. This number represents the version of the protocol. The following are the characteristics of the request control.

Step 2: After the appropriate protocol version is returned by the device, send a string information to the device, this information will select the appropriate application for the accessory attached, if the application is not found in the device it will suggest the user with a URL. The characteristics of this request are as follows:

The following string IDs are supported with maximum size of 256 bytes for each string.

Step 3: Once the application has been chosen, send the request to start device in accessory mode. This request is a control request on endpoint 0 having characteristics as follows:
android development

After the final control request has been sent, the device will reappear in the accessory mode and the accessory will be able to identify the device and establish communication with the device. Thus the Android seems to have created a pathway for configuring the accessories with the devices.

Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.