1 page.title=Building Custom Accessories 2 @jd:body 3 4 <!-- 5 Copyright 2010 The Android Open Source Project 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 --> 19 <p>An accessory for Android can be anything: keyboard, thermometer, robot, lighting control or 20 anything else you can imagine. Accessories for Android all have one thing in common; they all 21 connect to an Android device in some way. When starting out to build an accessory, you should 22 decide how your accessory will connect to Android devices. This page gives you quick overview of 23 your options for connecting your Android accessory and resources to help you get started.</p> 24 <h2 id="connecting-over-usb">Connecting over USB</h2> 25 <p>An accessory that connects to an Android device through a USB cable must support the Android 26 Open Accessory (AOA) protocol, which specifies how an accessory can establish communication with 27 an Android device over a USB cable. Due to the low power output of Android devices, the AOA 28 protocol requires the accessory act as a USB host, which means that the connecting accessory must 29 power the bus.</p> 30 <p>The AOA protocol has two versions which support different types of communication. Version 31 1.0 supports a generic accessory communication and adb debugging. This version of the protocol is 32 supported by the platform in Android 3.1 (API Level 12) and higher, and supported through an 33 <a href="https://developers.google.com/android/add-ons/google-apis/">Add-On Library</a> in Android 34 2.3.4 (API Level 10) and higher. Version 2.0 of the protocol is available in Android 4.1 (API Level 35 16) and adds audio streaming and human interface device (HID) capabilities.</p> 36 <p>If you use the general accessory protocol to communicate with your accessory (rather than the 37 adb or audio protocol), you must provide an Android application that can detect the connection of 38 your USB accessory and establish communication.</p> 39 <h3 id="next-steps">Next steps</h3> 40 <p>To get started on building an Android accessory that uses a USB connection:</p> 41 <ul> 42 <li>Select a hardware platform or build a hardware device that can support USB host mode.</li> 43 <li>Review the <a href="{@docRoot}accessories/index.html">AOA protocol</a> specifications to understand 44 how to implement this protocol on your accessory hardware. Implementing the 45 <a href="{@docRoot}accessories/aoa2.html">AOA 2.0 protocol</a> is recommended for all new Android USB 46 accessories.</li> 47 <li>Review the ADK 2012 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware source code</a> 48 (<code><adk-src>/adk2012/board/library/ADK2/</code>), which demonstrates an implementation of an accessory 49 using a USB connection for general data communications and audio streaming.</li> 50 <li>If you are planning to build an Android application that communicates with your accessory 51 via USB, review the ADK 2012 Android 52 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">application source code</a> 53 (<code><adk-src>/adk2012/app/</code>).</li> 54 </ul> 55 <h2 id="connecting-over-bluetooth">Connecting over Bluetooth</h2> 56 <p>An accessory that connects with Android devices over a Bluetooth connection can use the 57 various connection profiles supported by Android, including the Simple Serial Protocol (SSP) and 58 Advanced Audio Distribution Profile (A2DP) profile. An accessory that uses Bluetooth to connect to 59 Android devices must support Bluetooth communications and at least one of the supported connection 60 profiles.</p> 61 <p>Users must enable Bluetooth on their Android device and pair with your accessory in order to 62 use it. You can also provide a secondary Android application that handles any specialized 63 communication, such as data input or control outputs, to interface with your accessory.</p> 64 <h3 id="next-steps_1">Next steps</h3> 65 <p>To get started on building an Android accessory that uses a Bluetooth connection:</p> 66 <ul> 67 <li>Select a hardware platform or build an hardware device that can support Bluetooth 68 communications and an Android supported connection profile, such as SSP or A2DP.</li> 69 <li>Review the ADK 2012 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">firmware source code</a> 70 (<code><adk-src>/adk2012/board/library/ADK2/</code>), which includes an example implementation 71 of general data communications and audio streaming using a Bluetooth connection.</li> 72 <li>If you are planning to build an Android application that communicates with your accessory 73 via Bluetooth, review the ADK 2012 Android 74 <a href="http://developer.android.com/tools/adk/adk2.html#src-download">application source code</a> 75 (<code><adk-src>/adk2012/app/</code>).</li> 76 </ul> 77 <p><strong>Note:</strong> The ADK 2012 source code includes an open source Bluetooth stack which 78 is built for the Texas Instruments CC2564 chip, but can work with any Bluetooth chip that 79 supports a standard Host/Controller Interface (HCI).</p> 80