Merge "cherry pick from hc mr1 Change-Id: I6f48d245e2837226096fe42d08fb0243e416dbbc" into honeycomb-mr2

This commit is contained in:
Robert Ly
2011-06-14 17:43:38 -07:00
committed by Android (Google) Code Review

View File

@@ -24,8 +24,7 @@ page.title=Android Open Accessory Development Kit
</li> </li>
<li> <li>
<a href="#how">How an Accessory Communicates with an Android-powered Device in Accessory <a href="#accessory-protocol">Implementing the Android Accessory Protocol</a>
Mode</a>
<ol> <ol>
<li><a href="#wait">Wait for and detect connected devices</a></li> <li><a href="#wait">Wait for and detect connected devices</a></li>
@@ -40,8 +39,7 @@ page.title=Android Open Accessory Development Kit
</li> </li>
<li> <li>
<a href="#firmware">How the ADK board communicates with an Android-powered Device in <a href="#firmware">How the ADK board implements the Android Accessory Protocol</a>
Accessory Mode</a>
<ol> <ol>
<li><a href="#wait-adk">Wait for and detect connected devices</a></li> <li><a href="#wait-adk">Wait for and detect connected devices</a></li>
@@ -56,7 +54,7 @@ page.title=Android Open Accessory Development Kit
</li> </li>
</ol> </ol>
<h2>See also</h2> <h2>See also</h2>
@@ -64,7 +62,7 @@ page.title=Android Open Accessory Development Kit
<li><a href="http://www.youtube.com/watch?v=s7szcpXf2rE">Google I/O Session Video</a></li> <li><a href="http://www.youtube.com/watch?v=s7szcpXf2rE">Google I/O Session Video</a></li>
<li><a href="{@docRoot}guide/topics/usb/accessory.html">USB Accessory Dev Guide</a></li> <li><a href="{@docRoot}guide/topics/usb/accessory.html">USB Accessory Dev Guide</a></li>
</ol> </ol>
<h2>Where to buy</h2> <h2>Where to buy</h2>
<ol> <ol>
@@ -78,6 +76,9 @@ page.title=Android Open Accessory Development Kit
<li><a href="https://store.diydrones.com/ProductDetails.asp?ProductCode=BR-PhoneDrone"> <li><a href="https://store.diydrones.com/ProductDetails.asp?ProductCode=BR-PhoneDrone">
DIY Drones</a></li> DIY Drones</a></li>
<li><a href="http://shop.moderndevice.com/products/freeduino-usb-host-board">
Modern Device</a></li>
</ol> </ol>
</div> </div>
</div> </div>
@@ -86,7 +87,7 @@ page.title=Android Open Accessory Development Kit
support, which allows external USB hardware (an Android USB accessory) to interact with an support, which allows external USB hardware (an Android USB accessory) to interact with an
Android-powered device in a special "accessory" mode. When an Android-powered powered device is Android-powered device in a special "accessory" mode. When an Android-powered powered device is
in accessory mode, the connected accessory acts as the USB host (powers the bus and enumerates in accessory mode, the connected accessory acts as the USB host (powers the bus and enumerates
devices) and the Android-powered device acts as the device. Android USB accessories are devices) and the Android-powered device acts as the USB device. Android USB accessories are
specifically designed to attach to Android-powered devices and adhere to a simple protocol specifically designed to attach to Android-powered devices and adhere to a simple protocol
(Android accessory protocol) that allows them to detect Android-powered devices that support (Android accessory protocol) that allows them to detect Android-powered devices that support
accessory mode. Accessories must also provide 500mA at 5V for charging power. Many previously accessory mode. Accessories must also provide 500mA at 5V for charging power. Many previously
@@ -112,6 +113,8 @@ page.title=Android Open Accessory Development Kit
<li><a href="https://store.diydrones.com/ProductDetails.asp?ProductCode=BR-PhoneDrone">DIY <li><a href="https://store.diydrones.com/ProductDetails.asp?ProductCode=BR-PhoneDrone">DIY
Drones</a> provides an Arduino-compatible board geared towards RC (radio controlled) and UAV Drones</a> provides an Arduino-compatible board geared towards RC (radio controlled) and UAV
(unmanned aerial vehicle) enthusiasts.</li> (unmanned aerial vehicle) enthusiasts.</li>
<li><a href="http://shop.moderndevice.com/products/freeduino-usb-host-board">Modern
Device</a> provides an Arduino-compatible board that supports the ADK firmware.</li>
</ul> </ul>
<p>We expect more hardware distributers to create a variety of kits, so please stay tuned for <p>We expect more hardware distributers to create a variety of kits, so please stay tuned for
@@ -380,14 +383,11 @@ page.title=Android Open Accessory Development Kit
accessories communicate with Android-powered devices describe much of what you should be doing in accessories communicate with Android-powered devices describe much of what you should be doing in
your own accessory.</p> your own accessory.</p>
<h2 id="how">How an Accessory Communicates with an Android-powered Device in Accessory Mode</h2> <h2 id="accessory-protocol">Implementing the Android Accessory Protocol</h2>
<p>When you connect an accessory to an Android-powered device, the accessory's firmware must <p>An Android USB accessory must adhere to Android Accessory Protocol, which defines how
carry out some standard steps to set up communication with the Android-powered device. If you are an accessory detects and sets up communication with an Android-powered device. In general, an
building an accessory along with an application, this section goes over some general steps that accessory should carry out the following steps:</p>
your firmware should carry out.</p>
<p>In general, an accessory should carry out the following steps:</p>
<ol> <ol>
<li>Wait for and detect connected devices</li> <li>Wait for and detect connected devices</li>
@@ -399,6 +399,8 @@ page.title=Android Open Accessory Development Kit
<li>Establish communication with the device if it supports the Android accessory protocol</li> <li>Establish communication with the device if it supports the Android accessory protocol</li>
</ol> </ol>
<p>The following sections go into depth about how to implement these steps.</p>
<h3 id="wait">Wait for and detect connected devices</h3> <h3 id="wait">Wait for and detect connected devices</h3>
<p>Your accessory should have logic to continuously check <p>Your accessory should have logic to continuously check
@@ -476,12 +478,12 @@ data zero terminated UTF8 string sent from accessory to device
<p>The following string IDs are supported, with a maximum size of 256 bytes for each string <p>The following string IDs are supported, with a maximum size of 256 bytes for each string
(must be zero terminated with \0).</p> (must be zero terminated with \0).</p>
<pre> <pre>
manufacturer name: 1 manufacturer name: 0
model name: 2 model name: 1
description: 3 description: 2
version: 4 version: 3
URI: 5 URI: 4
serial number: 6 serial number: 5
</pre> </pre>
</li> </li>
@@ -520,12 +522,11 @@ data: none
device's configuration to a value of 1 with a SET_CONFIGURATION (0x09) device request, then device's configuration to a value of 1 with a SET_CONFIGURATION (0x09) device request, then
communicate using the endpoints.</p> communicate using the endpoints.</p>
<h2 id="firmware">How the ADK board communicates with an Android-powered Device in Accessory <h2 id="firmware">How the ADK board implements the Android Accessory protocol</h2>
Mode</h2>
<p>If you have access to the ADK board and shield, the following sections describe the firmware <p>If you have access to the ADK board and shield, the following sections describe the firmware
code that you installed onto the ADK board. The firmware demonstrates a practical example of how code that you installed onto the ADK board. The firmware demonstrates a practical example of how
to communicate with an Android-powered device. Even if you do not have the ADK board and shield, to implement the Android Accessory protocol. Even if you do not have the ADK board and shield,
reading through how the hardware detects and interacts with devices in accessory mode is still reading through how the hardware detects and interacts with devices in accessory mode is still
useful if you want to port the code over for your own accessories.</p> useful if you want to port the code over for your own accessories.</p>
@@ -540,8 +541,7 @@ data: none
sections.</p> sections.</p>
<p>The following sections describe the firmware code in the context of the algorithm described in <p>The following sections describe the firmware code in the context of the algorithm described in
<a href="#how">How an Accessory Communicates with an Android-powered Device in Accessory <a href="#accessory-protocol">Implementing the Android Accessory Protocol</a>.</p>
Mode</a>.</p>
<h3 id="wait-adk">Wait for and detect connected devices</h3> <h3 id="wait-adk">Wait for and detect connected devices</h3>
@@ -559,13 +559,13 @@ AndroidAccessory acc("Google, Inc.",
"1.0", "1.0",
"http://www.android.com", "http://www.android.com",
"0000000012345678"); "0000000012345678");
... ...
void loop() void loop()
{ {
... ...
if (acc.isConnected()) { if (acc.isConnected()) {
//communicate with Android application //communicate with Android application
} }
else{ else{
//set the accessory to its default state //set the accessory to its default state
@@ -728,7 +728,7 @@ bool AndroidAccessory::findEndpoints(byte addr, EP_RECORD *inEp, EP_RECORD *outE
Serial.print("Can't get config descriptor\n"); Serial.print("Can't get config descriptor\n");
return false; return false;
} }
... ...
</pre> </pre>
@@ -859,13 +859,13 @@ bool AndroidAccessory::configureAndroid(void)
changes the state of the accessory, such as lighting up or changing the color of the LED changes the state of the accessory, such as lighting up or changing the color of the LED
lights.</p> lights.</p>
<pre> <pre>
int AndroidAccessory::read(void *buff, int len, unsigned int nakLimit) { int AndroidAccessory::read(void *buff, int len, unsigned int nakLimit) {
return usb.newInTransfer(1, in, len, (char *)buff, nakLimit); } return usb.newInTransfer(1, in, len, (char *)buff, nakLimit); }
int AndroidAccessory::write(void *buff, int len) { int AndroidAccessory::write(void *buff, int len) {
usb.outTransfer(1, out, len, (char *)buff); usb.outTransfer(1, out, len, (char *)buff);
return len; } return len; }
</pre> </pre>
<p>See the <code>firmware/demokit/demokit.pde</code> file for information about how the ADK board <p>See the <code>firmware/demokit/demokit.pde</code> file for information about how the ADK board