12845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphypage.title=Custom Accessories
235f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly@jd:body
335f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly
435f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<!--
52845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy    Copyright 2014 The Android Open Source Project
635f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly
735f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly    Licensed under the Apache License, Version 2.0 (the "License");
835f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly    you may not use this file except in compliance with the License.
935f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly    You may obtain a copy of the License at
1035f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly
1135f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly        http://www.apache.org/licenses/LICENSE-2.0
1235f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly
1335f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly    Unless required by applicable law or agreed to in writing, software
1435f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly    distributed under the License is distributed on an "AS IS" BASIS,
1535f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1635f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly    See the License for the specific language governing permissions and
1735f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly    limitations under the License.
1835f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly-->
192845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<div id="qv-wrapper">
202845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy  <div id="qv">
212845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy    <h2>In this document</h2>
222845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy    <ol id="auto-toc">
232845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy    </ol>
242845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy  </div>
252845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy</div>
262845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy
2735f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<p>An accessory for Android can be anything: keyboard, thermometer, robot, lighting control or
2835f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyanything else you can imagine. Accessories for Android all have one thing in common; they all
2935f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyconnect to an Android device in some way. When starting out to build an accessory, you should
3035f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lydecide how your accessory will connect to Android devices. This page gives you quick overview of
3135f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyyour options for connecting your Android accessory and resources to help you get started.</p>
3235f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<h2 id="connecting-over-usb">Connecting over USB</h2>
3335f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<p>An accessory that connects to an Android device through a USB cable must support the Android
3435f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert LyOpen Accessory (AOA) protocol, which specifies how an accessory can establish communication with
3535f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyan Android device over a USB cable. Due to the low power output of Android devices, the AOA
3635f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyprotocol requires the accessory act as a USB host, which means that the connecting accessory must
3735f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lypower the bus.</p>
3835f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<p>The AOA protocol has two versions which support different types of communication. Version
3935f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly1.0 supports a generic accessory communication and adb debugging. This version of the protocol is
4035f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lysupported by the platform in Android 3.1 (API Level 12) and higher, and supported through an
4135f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<a href="https://developers.google.com/android/add-ons/google-apis/">Add-On Library</a> in Android
4235f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly2.3.4 (API Level 10) and higher. Version 2.0 of the protocol is available in Android 4.1 (API Level
4335f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly16) and adds audio streaming and human interface device (HID) capabilities.</p>
4435f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<p>If you use the general accessory protocol to communicate with your accessory (rather than the
4535f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyadb or audio protocol), you must provide an Android application that can detect the connection of
4635f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyyour USB accessory and establish communication.</p>
4735f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<h3 id="next-steps">Next steps</h3>
4835f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<p>To get started on building an Android accessory that uses a USB connection:</p>
4935f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<ul>
5035f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<li>Select a hardware platform or build a hardware device that can support USB host mode.</li>
5135f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<li>Review the <a href="{@docRoot}accessories/index.html">AOA protocol</a> specifications to understand
5235f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  how to implement this protocol on your accessory hardware. Implementing the
5335f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  <a href="{@docRoot}accessories/aoa2.html">AOA 2.0 protocol</a> is recommended for all new Android USB
5435f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  accessories.</li>
5535f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<li>Review the ADK 2012 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware source code</a>
5635f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  (<code>&lt;adk-src&gt;/adk2012/board/library/ADK2/</code>), which demonstrates an implementation of an accessory
5735f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  using a USB connection for general data communications and audio streaming.</li>
5835f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<li>If you are planning to build an Android application that communicates with your accessory
5935f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  via USB, review the ADK 2012 Android
6035f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  <a href="http://developer.android.com/tools/adk/adk2.html#src-download">application source code</a>
6135f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  (<code>&lt;adk-src&gt;/adk2012/app/</code>).</li>
6235f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly</ul>
6335f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<h2 id="connecting-over-bluetooth">Connecting over Bluetooth</h2>
6435f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<p>An accessory that connects with Android devices over a Bluetooth connection can use the
6535f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyvarious connection profiles supported by Android, including the Simple Serial Protocol (SSP) and
6635f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert LyAdvanced Audio Distribution Profile (A2DP) profile. An accessory that uses Bluetooth to connect to
6735f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert LyAndroid devices must support Bluetooth communications and at least one of the supported connection
6835f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyprofiles.</p>
6935f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<p>Users must enable Bluetooth on their Android device and pair with your accessory in order to
7035f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyuse it. You can also provide a secondary Android application that handles any specialized
7135f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lycommunication, such as data input or control outputs, to interface with your accessory.</p>
7235f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<h3 id="next-steps_1">Next steps</h3>
7335f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<p>To get started on building an Android accessory that uses a Bluetooth connection:</p>
7435f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<ul>
7535f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<li>Select a hardware platform or build an hardware device that can support Bluetooth
7635f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  communications and an Android supported connection profile, such as SSP or A2DP.</li>
7735f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<li>Review the ADK 2012 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware source code</a>
7835f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  (<code>&lt;adk-src&gt;/adk2012/board/library/ADK2/</code>), which includes an example implementation
7935f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  of general data communications and audio streaming using a Bluetooth connection.</li>
8035f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<li>If you are planning to build an Android application that communicates with your accessory
8135f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  via Bluetooth, review the ADK 2012 Android
8235f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  <a href="http://developer.android.com/tools/adk/adk2.html#src-download">application source code</a>
8335f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly  (<code>&lt;adk-src&gt;/adk2012/app/</code>).</li>
8435f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly</ul>
8535f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Ly<p><strong>Note:</strong> The ADK 2012 source code includes an open source Bluetooth stack which
8635f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lyis built for the Texas Instruments CC2564 chip, but can work with any Bluetooth chip that
8735f2fda6aaeaf733ab68a3b7f7ccc67f009c09a9Robert Lysupports a standard Host/Controller Interface (HCI).</p>
882845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy
892845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<h2 id="audio-over-usb">Connecting audio over USB</h2>
902845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<p>An accessory that connects with Android over USB connection may use the Android Open
912845de394cec7efbb6f9fcc021914b0b8c92add3Clay MurphyAccessory (AOA) protocol version 2.0. This version of the AOA protocol is supported on Android 4.1
922845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy(API Level 16) and higher. Once an Android device connects to an accessory that supports this
932845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphyprotocol, the Android system treats it as a standard audio output device and routes all audio to
942845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphythat accessory. No secondary software application is required on the Android device.</p>
952845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<p><strong>Note:</strong> Due to the low power output of Android devices, the Android Open Accessory
962845de394cec7efbb6f9fcc021914b0b8c92add3Clay MurphyProtocol requires that accessories act as a USB host, which means that the connecting accessory
972845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphymust power the bus.</p>
982845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<h3 id="next-steps">Next steps</h3>
992845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<p>To get started on building an audio accessory that uses a USB connection:</p>
1002845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<ul>
1012845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<li>Select a hardware platform or build a hardware device that can support USB host mode.</li>
1022845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<li>Review the <a href="{@docRoot}accessories/aoa2.html">AOA 2.0 protocol</a> specification to understand
1032845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy  how to implement this protocol on your accessory hardware.</li>
1042845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<li>Review the ADK 2012 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware source code</a>
1052845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy  (<code>&lt;adk-src&gt;/adk2012/board/library/ADK2/</code>), which includes an example implementation
1062845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy  of an audio playback accessory using a USB connection.</li>
1072845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy</ul>
1082845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<p><strong>Note:</strong> The AOA 2.0 protocol also supports the
1092845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphy<a href="{@docRoot}accessories/aoa2.html#hid-support">human interface device</a> (HID) protocol through a USB
1102845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphyconnection, enabling accessories such as audio docks to provide hardware play back controls such
1112845de394cec7efbb6f9fcc021914b0b8c92add3Clay Murphyas pause, fast-forward or volume buttons.</p>
112