Professional Documents
Culture Documents
The Accessory Development Kit (ADK) is a reference implementation for hardware manufacturers and
hobbyists to use as a starting point for building accessories for Android. Each ADK release is provided
with source code and hardware specifications to make the process of developing your own accessories
easier.
The Android Accessory Development Kit (ADK) for 2012 is the latest reference implementation of
an Android Open Accessory device, designed to help Android hardware accessory builders and software
developers create accessories for Android. The ADK 2012 is based on the Arduino open source
electronics prototyping platform, with some hardware and software extensions that allow it to
communicate with Android devices.
A limited number of these kits were produced and distributed at the Google I/O 2012 developer
conference. If you did not receive one of these kits, fear not! The specifications and design files for the
hardware were also released for use by manufacturers and hobbyists. You should expect to see kits with
similar features available for purchase, or you can build one yourself!
One of the important new features demonstrated by this ADK is the ability to play audio over a USB
connection. Be sure to check out the reference implementation of a USB audio dock in this ADK if you
are interested in making audio-related USB accessories for Android.
Components
The ADK 2012 is based on the Arduino open source electronics prototyping platform and is an open
hardware design. The hardware design files and firmware source code are included with the ADK
software download. The ADK contains two main physical hardware components:
1. Main processing board containing the microprocessor, USB connections, power connector and
input/output pins. This board can be removed and used separately from the rest of the hardware.
2. Shield containing sensors, LEDs, input controls, audio amplifier and speaker output, contained in a
custom, polygon box enclosure.
Separate USB connections for an Android device and computer connection for programming and
debugging
Sensors for light, color, proximity, temperature, humidity, barometric pressure, and acceleration
Bluetooth support
The ADK comes preloaded with an alarm clock firmware program that you can use immediately. A
companion Android application, ADK 2012, is available on Google Play. The source code for both the
Android application and the ADK firmware (an Arduino sketch) can be downloaded from this page.
The ADK 2012 also comes with additional parts to help you develop accessories with it, including:
AC power adapter
The Google ADK is a USB Accessory development kit based on the Arduino Mega2560 and
the Circuits@Home USB shield. It contains the hardware designs for the board, including an optional
demo shield that affixes atop the main board and implements stuff like a small joystick, different LEDs
and more. It also includes firmware libraries for both the USB host logic and the Android device
interaction. Finally, it includes example firmware for the main board and demo shield as well as an
example application for the Android device.
The ADK 2012 app and hardware accessory use a Bluetooth Serial Port Profile (SPP) connection to
communicate. This connection allows two way communication between the ADK accessory and Android
devices.
Note: The implementation of the ADK hardware allows the use of other profiles and multiple
connections. However, the basic communication between the ADK 2012 accessory and the Android
application uses SPP.
In order to enable Bluetooth communications, the clock.ino sketch for the ADK 2012 accessory calls
a btStart()method during the setup() method to enable radio frequency communications and start listening
for Bluetooth connections:
ADK L;
void setup() {
L.adkInit();
L.btStart();
}
...
void btStart(){
uint8_t i, dlci;
int f;
dlci = L.btRfcommReserveDlci(RFCOMM_DLCI_NEED_EVEN);
if(sdpDescrADK[i] == MAGIX){
if(f == -1) f = i;
else break;
}
}
Once Bluetooth is enabled with the code shown above, the accessory listens for connection requests. The
ADK library handles listening and connection details, so the accessory
calls ADK::adkEventProcess() once during each loop execution:
void loop(void)
{
...
L.adkEventProcess(); //let the adk framework do its thing
...
}
The ADK 2012 app and hardware accessory can also use a USB connection to communicate, similar to
the original ADK.
Accessory USB Code
The ADK library takes care of most of the implementation details for a USB connection, the accessory
code must make a few calls to initialize USB connectivity, including setting the accessory identification
strings:
ADK L;
void setup() {
L.adkInit();
L.usbSetAccessoryStringVendor(...);
L.usbSetAccessoryStringName(...);
L.usbSetAccessoryStringLongname(...);
L.usbSetAccessoryStringVersion(...);
L.usbSetAccessoryStringUrl(...);
L.usbSetAccessoryStringSerial(...);
L.usbStart();
}
Once USB is enabled with code shown above, the accessory listens for connection requests. The ADK
library handles listening and connection details, so the accessory calls ADK::adkEventProcess() once
during each loop execution:
void loop(void)
{
...
L.adkEventProcess(); //let the adk framework do its thing
...
}
The accessory must then check for a live USB connection to process commands and send messages. Here
is a summary of the relevant code:
void loop() {
if (L.accessoryConnected()) {
int recvLen = L.accessoryReceive(msg, sizeof(msg));
if (recvLen > 0) {
... // process message
}
L.accessorySend(outmsg, outmsgLen);
}
L.adkEventProcess();
}