Google I/O 2012 - ADK 2.0

Uploaded by GoogleDevelopers on 29.06.2012


ERIC SCHLAEPFER: Hi, I'm Eric Schlaepfer.
Let's talk about the ADK 2012.
With me--
So just to finish the introductions, over here is
Dmitry Grinberg, who worked on the software.
Also over here is Travis Geiselbrecht, who worked on
the software as well.
And, since I didn't mention it before, I worked on the
hardware for the ADK 2012.
So first, let's talk about accessories for Android.
There's a couple of ways to connect
accessories to Android devices.
That includes USB and Bluetooth.
So through USB, we can use last year's Android Open
Accessory API.
And through Bluetooth, there's a variety protocols for a
variety of purposes that we can use.
And so a lot of the accessories you can build
here, commercial purposes include audio dock, exercise
equipment, medical devices, that kind of thing.
But there's also a lot of capability for hobby projects
as well, such as a robot controller and all kinds of
wonderful things that people can do with this.
So I'm sure you're dying to see what the
ADK 2012 looks like.
So let's just go ahead and take a look.
And here we have it.
We've attempted a little bit more than we did last year.
All right, so what is this thing?
This is an alarm clock.
You can take it out of the box and plug it in and begin using
it as an Android-connected alarm clock right away.
It's also an audio dock.
If you plug it into the USB connection, you can transfer
audio from your phone to the device and play it
back in real time.
You can do exactly the same thing over Bluetooth as well.
And it also acts as an Android accessory hacker platform.
It's totally extensible.
You can go in and edit all the code.
You could even go in there with a soldering iron and make
all kinds of changes to it.
So let's talk about some of the features here.
We've loaded it down with a lot of good stuff this year.
So we've got a light sensor in the corner that can sense
ambient light levels, proximity, and it has a built
in colorimeter, which we'll talk about a little bit later.
There is a capacitive slider control on the top for
adjusting the volume, adjusting brightness, color,
all kinds of other functions.
And we've put in a bunch of capacitive buttons as well.
In fact, almost the whole front panel is capacitive.
There are also 64 RGB LEDs.
So all those 7-segment display segments here, you can control
the color, set them to whatever you want, display
patterns, all kinds of cool things.
OK, now I'm sure you're wondering what's inside.
So let's go ahead and take it apart.
It's very easy.
You just squeeze the case.
There's not a single screw in this entire design.
It's held together by magnets.
And here it is unfolded.
This is one of the first devices that's actually
designed to be taken apart, because we want you to take it
apart and hack on it.
So on the inside, let's look at some of
the component pieces.
On the upper part, there's a speaker.
And we use that to play back alarm sounds, audio from
Bluetooth or USB.
And if it looks a little odd to you, that's because it's a
It connects to the back panel of the device.
And it uses the entire back surface as a speaker.
So you get big sound out of a small device.
There's also a whole bunch of sensors in there as well.
The ADK is aware of the temperature, the humidity, the
barometric pressure, the acceleration, and even the
local magnetic field.
Just imagine the potential for that.
Also, on the side of the device is an NFC Tag.
So when you first get your device, you can take your
Nexus device and hover it over the tag.
And it will send you to the app store to download the app.
Let's talk about the microcontroller.
I remember last year we had a little AVR processor, a little
8-bit processor.
And it's a great little processor.
But we decided to do it better a little bit this year.
So this device has a 32-bit ARM Cortex M3 processor.
We've connected a Bluetooth device to it and an SD card.
And if some of the stuff looks a little bit familiar, that's
because it's completely programmable through the
Arduino IDE.
So if you don't want to use it as an alarm clock, you can
actually take it apart and pull the entire
board off of it.
And it's an Arduino, except it's 32-bit.
So instead of writing code for a processor running at 16
megahertz, you can take that same code and
run it at 84 megahertz.
OK, let's talk about the phone application.
So again, if you take your Nexus device and you hover it
over the NFC Tag, you can pick up the application.
You can plug in through USB, and that will automatically
load the application for you.
Once you've launched it, it'll give you a
little Connect menu.
And so you can use this to connect though Bluetooth,
which is pretty straightforward.
So just search for devices on Bluetooth.
And it'll show up as the ADK 2012.
Click the Connect button, and it will show a little code on
the front of the device.
So you can just click OK here and pair up.
And once you're done, launch the ADK application and click
Use Bluetooth.
And then pick it off the menu and you're done.
That's it.
So one more step than you would have to use for a
Bluetooth headset.
If you want to connect it through USB, you do what you
would do last year.
Just plug it in and it works, magically launches the
And once you've done that, you'll get the main screen
here, which has a number of different functions here.
You can set the time.
You can set the alarm, set the color.
You can choose some display settings.
And you can lock the device as well so you won't accidentally
brush up against the cap sense and change your alarm.
Setting the time is very simple.
You get a little time picker like this.
And if you just click through that, it sets it to your cell
phone network time.
So it's a very quick way to update the time
on your alarm clock.
Alarms are similarly easy.
You can just come in, click on the Menu, set the alarm time.
And you get to choose the alarm sound.
There are a number of sounds that we
pre-load onto the SD card.
And they're all in the open-source Ogg format.
You can put all your own songs on there as well.
And we've got a built-in Ogg-Vorbis decoder.
All the source code is right there for you look at.
OK, now let's talk about setting the LED color.
And there's a couple of ways to do it.
But my favorite way is something that Dmitry here
will demonstrate for us.
So let me go ahead and switch over to his screen.
And so we can see the clock that he's been operating here.
OK, so Dmitry, go ahead and show us the color picker mode.
I did tell you about a colorimeter.
OK, so he's got--
DMITRY GRINBERG: So for example, we can grab different
colored swatches and have the device pick up their color.

ERIC SCHLAEPFER: And so, of course, you can do this from
the application as well.
But just imagine the possibilities.
You could take-- oh, for example-- little colored jelly
beans and make a robot that can recognize the
color and sort them.
I mean the possibilities are endless with
this type of sensor.
You guys will love it.
OK, I'd like to pass things off to Dmitry now to talk
about Bluetooth sound and storage.
DMITRY GRINBERG: Thank you, Eric.
So as Eric mentioned, we added Bluetooth to this device, by
which we mean we added real Bluetooth.
A lot of Arduino projects and similar small embedded devices
use Bluetooth to Serial converter chips, which just
give you a virtual serial port.
That's all nice and great, but it doesn't give you too much
So here in the ADK 2012, we have a real Bluetooth chip.
It's a TI CC2564.
And it's connected over UART to the main processor.
We have the on board antenna.
So everything you need to do to play with Bluetooth is
right in the ADK.
We wrote our little Bluetooth Stack for the ADK, mostly
because it's a very simple one.
It runs on BareMetal.
And it's BSD licensed.
So you can just grab it and use it.
You don't have to pay any money in royalties.
You don't have to disclose your code, nothing.
It is very simple.
It supports multiple concurrent connections.
We implemented a service discovery protocol server.
So you can advertise your services so devices can
discover it.
And if you do want RFCOMM, which is a Bluetooth serial,
we have that as well.
Here we have a few lines of code just to show the
functionality we have available.
You can set your device name, get remote device names.
You can do device discovery.
You can make your device connectable, discoverable,
everything else you'd expect out of a Bluetooth Stack.
If you want to play with low levels of Bluetooth, you can
use L2CAP Protocol, which we give you access to.
You can create L2CAP sockets.
You can receive connections on them.
It's all extremely simple to do.
Whenever data arrives, a call back gets called and you can
process it.
And you can send data back with a simple function call.
The data is sent asynchronously.
So, in fact, you don't have to keep it around.
You don't have to worry.
It'll get sent whenever it's needed to.
You just call one function.

And this is something you'd use, for example, to implement
Bluetooth HID, if you want to have the ADK
pretend to be a keyboard.

But, of course, the way Bluetooth discovers what
service your device has is SDP.
It allows devices to query and receive responses about what
services your device supports.
We have a fully working SDP server in our device that
supports the entire SDP spec.
So you can discover services on here.
The API is, once again, extremely simple.
You can just add and remove
descriptors using two functions.
And as soon as you add a descriptor, it begins being
And, of course, the ADK source code includes examples of
this, because that is how the phone application communicates
with the ADK.

For virtual serial ports, of course, we have RFCOMM, which
acts to you just like a serial port.
You'll get a call back when data arrives.
You can call a function to send data.
And, once again, the example is in the ADK.
And we support multiple connections.
And it's actually quite fast.
So I've tried making a small ADK application that just
pipes data back to you.
And we got one megabit full duplex throughput through this
chip and through the entire ADK code stack.
ERIC SCHLAEPFER: So kind of what this means for you guys
is that not only is this protocol stack completely
exposed to all of you-- you guys can look through all the
lower layers, all the upper layers--
but RFCOMM is a great way to get started with it.
So if all of these acronyms don't really make a whole lot
of sense to you, if that's something you don't want to
dig into, then you can just look at this example we have
on this slide right here.
And using RFCOMM, which is the simplest serial protocol, is
literally that simple.
So it's very scalable.
DMITRY GRINBERG: And we've tried this with multiple OSes,
not just Android.
It works with Linux and a few other OSes
we've tried as well.
And the other thing we added to the ADK this
year is A2DP support.
So the ADK is actually a fully working Bluetooth speaker.
We have an SBC decoder in here.
It supports mono, all three stereo versions, everything
you'd need out of a Bluetooth device.
And we've also tested it with multiple OSes, including
Android and Linux.
And it does work.
ERIC SCHLAEPFER: Would you like to demonstrate that now?
DMITRY GRINBERG: I don't know if I have any--
I guess I can play some alarms, sure.
ERIC SCHLAEPFER: Let's give it a shot.
I'm not sure what the 2.4 gigahertz spectrum looks like
in here, but we'll see what happens.
DMITRY GRINBERG: We'll find out soon enough.

ERIC SCHLAEPFER: So let's consider this a stress test of
the Bluetooth Stack.
So if all these people with Bluetooth-connected phones out
here, and I can imagine 2.4 gigahertz right now, let's
take a look and see if this will--
DMITRY GRINBERG: I want to see what ring tone I can grab.
ERIC SCHLAEPFER: I hope you've already paired with it,
because you're going to get a very long list of devices.
DMITRY GRINBERG: I imagine so, yes.
There, well, I guess it's not very loud.
But you can hear it.

ERIC SCHLAEPFER: And it's ringing.

Your alarm clock is ringing.
DMITRY GRINBERG: It's not playing out of my phone.
You heard it out of the ADK.
And on the phone side, the Bluetooth
is very, very simple.
For example, here is an RFCOMM sample for you.
And it's very easy to make this work.
This is literally the code you need to communicate with the
ADK in the simplest form.
You create a connection.
And, as you see, we do a discovery using this UUID.
This is just a UUID you create yourself.
And as long as it matches on the ADK side and your Android
side, the connection will be made.
And then you get an input stream and an output stream.
So in Java, you just send bytes and receive bytes.
There's no further complications
for you to deal with.

One of the other additions this year to the ADK, as
you've just seen, is sound.
And we've made it really, really easy for
everyone to use this.
So the audio data is piped to the audio digital analog
converter using DMA.
So your code doesn't have to conform to any timing
requirements or really do anything complicated.
It just works.
The API is very simple, as you can see.
You can just enqueue an audio buffer.
And that buffer gets played whenever the audio hardware
gets to it.
And the code will block until it's time to do that.
Or you can use instead a [? TryAddBuffer ?]
And that way you can know if the current audio buffer is
already full.
The thing you see there with a source is one of the
interesting things about ADK.
We didn't want to put a full audio mixer in it, not because
we couldn't.
But we just didn't think it was appropriate.
So instead, there is some code in here to do audio lock out.
So there's a fixed priority of services.
For example, Alarm overrides anything else.
So if you try to play a file while the alarm is going on,
alarm wins and your data gets dropped.
And, of course, this is all code you can modify.
So if you want to add your own audio mixer,
you're free to do so.
ERIC SCHLAEPFER: What this means for the people that are
going to use it as an alarm clock before starting to hack
on it is that if you set up, and you've got music playing
on it, and then the alarm goes off, the alarm will interrupt
the music just like you would expect it to.
DMITRY GRINBERG: And we went a little further than that,
because no one likes uncompressed audio.
So as Eric previously mentioned, we did have an Ogg
decoder in here now.
So the alarms that are in the device are Ogg format.
And the API for that is extremely simple.
The simplest way is just to call Play Ogg
and give it a path.
That's all you have to do.
The audio will just start playing.
Also you can do it in the background if you wanted to.
And we also have a global volume control.

For storage, we have a MicroSD slot on the device.
And all the devices have MicroSD in them already.
And the API is very simple, as you would expect.
There's an SD driver in place and a FAT16, 32, and 12
driver built in.
It's got all the functions you'd expect.
You can open files, close files, read them, write them,
you can create directories.
A few things that most embedded file system drivers
don't have, you can also format a card or move files.
And this is all, once again, code you get, code you can
modify, reuse, whatever you want.
Now I want to hand it over to Travis to talk about some of
the USB things.
So the ADK also has USB, as it did last
year and similar today.
Dmitry is going to show us the two ports on the back.
That's the inside of it.
There are two USB ports on this device.
The first one is used for programming.
It looks like a standard FTDI bay serial port.
That's the one you use for debugging and--
ERIC SCHLAEPFER: I think you're on the wrong side.
ERIC SCHLAEPFER: There you go.
DMITRY GRINBERG: This thing's upside down.
It's really hard.
See, so there's two ports here.
They're both micro USB.
The other one was one that's really interesting.
That's a USB host port.
So on ADK 1.0, there was a--
same thing, USB host.
But it was implemented as an external chip that actually
handled most of it.
For this time around, we actually pulled the host stack
into the ARM processor.
In the case in this particular ARM, it had on-the-go USB
So we put it in host mode and implemented the stack.
So the full source is available.
It's running on the ARM.
It does everything that we'll talk about here in a minute.
If you've never used an Android accessory protocol, it
actually shows up in an inverted way that
you normally expect.
The device implements host, the accessory device.
And the phone or tablet or round sphere of something
shows up as an actual device to the ADK.
And, really, the nitty gritty details is there's a little
handshake at the beginning.
And then it ends up exporting to bulk endpoints.
And it's just data in and out.
It's very similar to what we did last year.
And then it's up to you the format whatever
protocol you want.
ERIC SCHLAEPFER: So Travis, you did mention a sphere.
And what you're referring to is the Nexus Q demo that's
happening right now on the third floor with that giant
ball and the robot arm and all of that.
That's all being done through an ADK 2.0 from a Nexus Q
using the Android Open Accessory protocol.
So actually, if you look there, there's a ball--
And that's running an Arduino sketch that was written a
couple weeks ago.
You've actually already seen one.
And most people hadn't recognized that it was
actually an ADK.
ERIC SCHLAEPFER: It was at that point I really
appreciated the power and simplicity of Arduino, because
we were down to the wire.
And I had to get this thing done.
And so, I just whipped up a quick sketch.
And it worked great, as you can see if you go up to the
third floor.
Go ahead.
TRAVIS GEISELBRECHT: Oh, and so also, here's
the list of the API.
It's a very simple API on the device side.
For the accessory protocol, most of the actual API is
setting the different strings, which is what your device
would show up to.
There's a list of strings that you can match against, where
you can name yourself, you know, in this case, ADK 2012
or My Cool Widget.
And that's exactly how the app on Android side will know
which app to connect to or what the protocol version is.
So most of the API is just for setting those strings.
And at the very bottom, you basically have three calls,
are you connected, send data, receive data.
There's not much to it.
It doesn't format it.
It's just a string of bytes.
It's up to you to define whatever protocol you want.
In our case, we actually developed about a 10 or 15 op
code, send and receive protocol to support all the
sensors and what not on that.
And we used the same protocol to punch over
Bluetooth as well.
So it's quite straightforward.
ERIC SCHLAEPFER: So you can look at the sketch that we'll
provide with the full source code and see that as an
example of sort of a medium complexity example of
transferring data back and forth over USB.
And this is actually, essentially,
the minimum set up.
You'll see at the top, we initialized the ADK and set
the accessory strings for whatever your device
will show up as.
And then in the main loop, you basically are just testing,
are you connected, are you not?
Send data, process it, send it back.
There's not much to it.
It's a little bit more complexity
on the Android side.
But this, of course, is not any different from last year.
This accessory protocol's been in Android since Gingerbread.
But, for the most part, you set up the connection, and,
you do a little bit more error checking than on the slide,
but probably about twice as much code
in the final solution.
But then, at the bottom, you end up with two input streams.
Input, output stream, you punch protocol over that.
And that's pretty much it, not a lot to it.
There is a little bit of string matching that you do
inside the app to decide which device to connect to.
And, of course, Android lets you register a particular app
to start automatically when it sees
this particular accessory.
And that's all handled inside the manifest of the app.
ERIC SCHLAEPFER: So if you notice that the last two lines
look familiar, you're right, because we use the very same
stream mechanism for Bluetooth.
In fact, in our application, what we've done is we've
abstracted it and wrapped them in two different classes that
both inherit from a master class that
has two stream objects.
And that allows our ADK application to use either USB
or Bluetooth with exactly the same code.
And you, of course, can use that code in your
own projects as well.
TRAVIS GEISELBRECHT: And there's one more feature that
we added for this one.
And this is new since last year.
Part of a feature that was added in Jellybean is there is
a generic USB audio mechanism.
And it's an extension of the accessory protocol.
And, basically, it--
this is well, of course, documented
on the Android side.
There's actually no API involved, which is why there's
no code to actually show you.
But basically, it's a little handshake that happens when
the device goes into accessory mode.
And then the phone or tablet or round spherical thing turns
into a USB audio device, basically looks like a
microphone more or less to this.
It's full 16-bit, 44.1, PCM data, no compression or
anything like that.
And what we're using this device for is essentially an
example code.
Here is an example of how you would go implement it.
You might not even use this exact code.
But, you know, if you're designing something based on a
PIC or an AVR or something more exotic, you could also
use the same thing.
This is, of course, well-documented.
So this acts like an example to it.
And same thing with--
like I said, this is in Jellybean and above.
All devices have it.
If it's got Jellybean, it supports this protocol.
ERIC SCHLAEPFER: So what this means for all of you is that
you can take your Jellybean Nexus that you got here, plug
it into your ADK, and without any menus or configuration or
anything, you can immediately begin playing
audio through it.

TRAVIS GEISELBRECHT: Yeah, you'll see a little pop up
that says, connected as an audio device.
And then that's it.
ERIC SCHLAEPFER: And then it just works.
All right.
So, I'm going to hand it back over to Eric, who's going to
go through the rest of the fun gadgets you can do with it.
ERIC SCHLAEPFER: The pretty lights, let's talk about
blinking lights.
There are 64 RGB LEDs on this guy, six 7-segment digits, two
colons that you can control separately, eight icon
indicators, and 12 party mode lights.
I can't wait to see what you guys do with those.
That'll be fun.
Actually, I think Dmitry might have done a little
bit of a demo here.
So let's go and switch over to that camera and take a look.
So, he's actually been busy coding up a bunch
of different demos.

Dmitry, that looks really good.
He's been going through so many different visualization
algorithms over the last couple of days.
I'd just look over his desk and, oh, look at that.
There's another neat pattern, very cool.
So I'd love to see what you guys come up with as well.
Please go and record videos.
Put them up on YouTube.
I look forward to seeing all of that.
So the API to control those LEDs is very straightforward.
Since we handle all the LED muxing and the LED controller
in the background through an interrupt-based system,
there's really not a whole lot you have to do.
Just ledWrite, put in the index of the LED and the red,
green, and blue values, and then it just sort
of magically happens.
And you don't have to worry about anything.
If you want to get more complicated, you could use the
ledDrawLetter function and put it in essentially ASCII value,
and that will show up on the digit that you've selected.
Now, granted, it's a 7-segment display.
So certain letters, like M and N and some of those other
tricky ones, we can't display.
But we do our best.
So, play with it and see what you think.
And those are the LEDs.
Let's talk about the capacitive touch sensors.
They are actually 12 buttons, one each for the up and down
on each segment.
And what that allows you to do is, if you're in clock mode,
you can set the clock just by touching the top or the bottom
of each digit.
Dmitry, did want to demonstrate that?
ERIC SCHLAEPFER: OK, let's switch to the camera and take
a look here.
It's a little hard to talk about it but--
DMITRY GRINBERG: I can try setting that time.
There's 11:00, 10:00.
You can also just do it quicker.

ERIC SCHLAEPFER: And let me tell you, this is great
because I have one of those old alarm clocks at home,
where it's got the hour button and the minute button.
And then you're hitting the button.
And you're like, OK, I'm getting there, getting there,
get-- oh, I went too far.
Now you get to go all the way back around again.
DMITRY GRINBERG: It also works for setting the alarm and
enabling and disabling it.
So there's a lot you can do with those buttons.
We've also got a slider control on
the top of the device.
And so, we use that as a volume control.
And depending on the mode that you're in, it can also adjust
the color of the LEDs as well.
So, since we've got the demo screen up, you might want to
go to Color.
And we can take a look at that.
ERIC SCHLAEPFER: And so that just runs through all these
different colors, very pretty.
Thanks, Dmitry.
OK, let's talk about sensors.
You got a little bit of a preview of some of those
sensors when I was talking about it earlier.
There's a thermometer hygrometer device that will
give you the temperature as well as the relative humidity
in percent.
I think everybody that I showed it to came by and had
to breathe on it to see if their breath would increase
the humidity, which it did.
And, yes, I was able to saturate the sensor.
There's also a barometer that's in the device.
It's incredibly sensitive.
In fact, it's so sensitive to pressure that if I take an ADK
and I hold it up here, and then I drop it down here, it
can tell the difference in pressure.

We've also got-- thank you.
We've also got an accelerometer magnetometer.
So let's switch to the camera again.
And so, Dmitry's going to show us what that looks like on the
real time display.
DMITRY GRINBERG: So this is the device in
accelerometer mode.
So, blues are negative, reds are positive.
So I can rotate it and see the accelerations change.
And we can do the same for a magnetometer as well.
So I can attempt to find some direction of north here if I
knew how to interpret this data.

But it does show some random value.
So as far as looking cool goes, it works.

And the other sensors are here as well.
So there's the temperature, 26.3 Celsius.
Humidity, I'm not going to make Eric breathe on this.
We have the current pressure, proximity, and you already saw
the color matching mode.
ERIC SCHLAEPFER: Thanks, Dmitry.

It's funny, when we were doing some rehearsals for the demos,
we were running this off of a battery.
And he picked this up, and he literally threw it at me.
But it was in accelerometer mode.
And all the numbers went to zero because it's essentially
in free fall.
And so, of course, I was a little scared because here's
this thing flying through the air.
But then I'm looking at the LEDs.
Hey, they're all zero.
Physics works.
DMITRY GRINBERG: Unfortunately for you, he did not get hit.

ERIC SCHLAEPFER: OK, so the API that's
involved is very simple.
And it actually handles all the calibration calculations,
of which there are many.
Especially that barometer, there's a lot of number
crunching that we had to do to get real numbers.
But the good news for you guys is that all that
code has been done.
It's all written.
And the API is very simple.
You just make a function call here to,
for example, baroRead.
And you just pass in pressure and temperature, and it will
go in and take those pointers and put numbers in them.
And now you've got the pressure and the temperature.
It's very simple.
All right, Dmitry's going to talk about the sample code for
the clock sketch in the Arduino.
So the code of everything that I'm demonstrating here, this
is all built in.
We're giving this code to you of course.
And there's a few interesting things to look into that.
And there's absolutely no way I can go through all of it or
even a large piece of it.
The interesting thing to mention here, if you've ever
used Arduino before, is a lot of this stuff happens in the
Some of it's interrupt driven.
Some of it is not.
So we actually have a small cooperative multitasking
system behind the scenes to let everything happen behind
scenes, like Bluetooth and USB.
So, once in a while, you have to call ADK event process,
which just allows the ADK to process all of
its background work.
And you can do that whenever you're in a busy loop or in
some other such place.
And if you don't do that, bad things will happen.
So please do.
ERIC SCHLAEPFER: So, just to go back to that, the
multitasking thing sounds complicated.
Like, do I really have to worry about that?
Or is it as simple as making that function call every once
in a while?
DMITRY GRINBERG: So, if you don't want to play around with
multitasking, you just make that function call and
everything works.
If you want to, you can play around with the multitasking.
And it's actually very simple.
There's two functions, really, if you care about.
One to launch a thread and one to yield.
And the thread dies just whenever you
return from that function.
So if you want to use it, go ahead.
It is in the code.
And the other example here is how we display the time.
And it is just these few lines.
I skipped the minutes and seconds.
But you just get the RTC and display them.
The next line you see there is how the alarm sounds are
played for the alarm.
And, also, we have an alarm preview that
does that as well.
So if I go to the alarm mode--
I don't think we have a microphone on anymore.
But it does do that using the Ogg play background.
As soon as I let go, it gets canceled.
And also, we have the Process USB accessory function, which
handles the USB messages that arrive.
That gets called in the main loop, unlike the USB code,
which gets called from the USB--
or, sorry, Bluetooth code, which gets
called from the callback.
This is actually that callback.
And the data arrives.
And we pass it to adkProcessCommand, which just
processes the command received and sends back a response.
That function's actually in common between
Bluetooth and USB.
So protocol is the same.
So when you're writing your Android application, you
shouldn't need to know or care how you're
connected to the ADK.
Everything should work exactly the same.
DMITRY GRINBERG: We were really hoping you guys have a
lot of questions.
So let's have it.
ERIC SCHLAEPFER: So where there are microphones in the
middle of the room here-- so if you have a question, please
come up and ask it.
And we'll do our best to answer.

AUDIENCE: Shut up and take my money.
AUDIENCE: No, it's a really impressive piece of [? kit. ?]
I actually had a couple questions about the--
I'm a big Arduino fan.
What are you guys running in the Arduino?
Like, what Arduino are you running?
ERIC SCHLAEPFER: What Arduino are we running?
AUDIENCE: With respect to, you know, its amount of
Is it a--
let's take it apart.
ERIC SCHLAEPFER: OK, so I think what you're asking is,
this is a 32-bit device.
And it's clearly running under the Arduino IDE.
So what Arduino is it based on?
ERIC SCHLAEPFER: And the answer is actually that it's
kind of its own thing.
It's similar in certain ways to the Arduino Due.
But it's definitely not the same thing.
It's kind of its own animal.
But it still retains the ease of use that
you get with Arduino.
And so, if you go to our website and you download all
of that stuff, you can just select Google ADK 2.0 and then
just start running sketches on it.
AUDIENCE: So you have your own built like the [INAUDIBLE]
ERIC SCHLAEPFER: Right, exactly.
Now, you won't necessarily be able to run all that ADK 2.0
code on an Arduino Due when it hits the market, right?
So they are different devices.
TRAVIS GEISELBRECHT: We did work with Arduino for this.
Just the timing worked out to where this comes out a little
bit before they have their ARM-based things.
I don't know the timing on that.
But when they do, these ought to be pretty close.
So this is kind of a preview release of Arduino for ARM.
AUDIENCE: It's really, really impressive.
This segment [INAUDIBLE]
TRAVIS GEISELBRECHT: I mean, it's very close.
So this won't be--
this is not some strange fork.
It's based very, very closely [INAUDIBLE]
DMITRY GRINBERG: We also do have a build without Arduino,
just a basic make file build that we'll be providing as
well for those who don't want to use the
Arduino ID for some reason.
Thank you very much, guys.
You crushed it.
ERIC SCHLAEPFER: All right, next question.
DMITRY GRINBERG: Let's go with the person in the front--
ERIC SCHLAEPFER: Up front, please.
DMITRY GRINBERG: --alternate.
So last year's ADK was really more of like a prototype
board, which other manufacturers would then
create their own variations, maybe at differing cost, price
points, or whatever.
But this year's ADK seems to be more of a finished product.
I was wondering, what is the plan for supporting this
outside of your product going forward?
Are other manufacturers expected to
produce a final good?
Or are they producing boards, which then we then build upon?
And the second part the question is, what, if any, of
your convenience code can be shared for ADK 2012 that's not
manufactured by Google?
ERIC SCHLAEPFER: OK, so we've got a two-part question here.
The first part, the PC board files-- and that includes the
schematics and the layouts and all of that--
all that's done in EAGLE.
And that's completely open source.
So anybody else is free to make a copy of that and begin
manufacturing it.
For the second part of the question, I think Dmitry here
can answer that.
DMITRY GRINBERG: The source code is also free.
You're free to use it.
The licensing is very friendly.
I don't think we have any code that makes you pay for it.
We don't have any code that you have to open
your source code for.
So you can grab our code, use it however you please.
I believe the licenses are all in there.
And the code is going to be made available, I believe,
right after this talk.
TRAVIS GEISELBRECHT: Yeah, right about now.
DMITRY GRINBERG: So if you want to grab the Bluetooth
stack, or you want to grab Travis' USB host code, or you
want to grab some of the sensor calibration code, you
just grab it and use it by yourself.
ERIC SCHLAEPFER: So, for example, what specific license
do you use for the BSD stack-- or the BTstack?
DMITRY GRINBERG: The BTstack, I think, is actually licensed
Apache or BSD or something of the sort.
So it's usable for anyone.
Next question, please--
ERIC SCHLAEPFER: --in the back.
You're welcome.
Anyone in the back?
Nobody in the back.
ERIC SCHLAEPFER: Next person up front.
AUDIENCE: I wonder if you could talk about the
hackability of the Nexus Q and how you guys came up with that
demo and how you would write an application for just a
simple Arduino--
not an ADK--
interfacing with the Nexus Q.
ERIC SCHLAEPFER: So the important thing to recognize
is that the Nexus Q runs full Android.
And so, it's perfectly capable of running Android
And it also has the Android Open Accessory protocol in it.
And so we essentially worked with it just like we would
work with a phone.
DMITRY GRINBERG: The main point being there's absolutely
nothing special being done for it.
You don't have to do anything.
It just works.
Thanks for a great presentation.
I'm more of a software guy than electronic guy.
So maybe my question could be very silly.
But I heard that there is a problem with USB host that
it's also charging the phone.
So its problem that you shouldn't charge the accessory
from battery because you'll run out fast of the battery.
So is it true?
And if yes, is it a better way to make accessories that work
only with phone and are not connected to electricity?
I'll take this question, Travis.
So it's kind of a known issue with the way that USB
accessories work.
And, essentially, what happens is the phone becomes a
And the accessory becomes the host.
And because of that relationship, the way that USB
works, the accessory, then, has to provide power to the
host, which is a little strange.
And the reason has to do with sort of the lack of adoption
of USB On-The-Go, which I think is rather unfortunate.
But it's the world that we live in, and we have
to deal with it.
At the same time, though, a redemptive factor is that
Bluetooth is getting more and more popular, especially for
And so, I think that it's OK that USB has its limitations
because I want people to focus on developing Bluetooth
Wireless really is the future.
And that's where we need to be focusing our new development.
And it's more fun, too.

AUDIENCE: I was wondering, the USB audio API that was just
announced in [INAUDIBLE], it didn't really have any
documentation for it.
And I just wanted to ask if you know whether it only
allows Google Play to stream music out that.
TRAVIS GEISELBRECHT: Oh no, not at all.
All audio on the phone goes through it at that point.
It basically turns it into a--
So any app.
TRAVIS GEISELBRECHT: Yeah, any app, everything that plays
sound goes through it.
And it--
ERIC SCHLAEPFER: So, notifications, alarms, you
could even use it like a speaker phone, right?
And this is fully documented on Android's side under the
accessory protocol--
I don't know if it's under Jellybean docs or somewhere
along those lines, but--
ERIC SCHLAEPFER: It should be on there right now.
There is documentation up on the website now.
TRAVIS GEISELBRECHT: There's actually no API for it because
it either works or it doesn't.
DMITRY GRINBERG: Any output you do on audio goes through
the device as long as it's plugged in.
AUDIENCE: And isochronous mode, is that going to be
supported, you think?
AUDIENCE: Isochronous mode for high sample rate USB
TRAVIS GEISELBRECHT: At the moment, I believe it is fixed
at 44.1 16 bit--
DMITRY GRINBERG: I think he's asking about the packet types
being used on USB.
Sorry, sorry.
Yes, it's all isochronous.
It looks like a standard USB audio, nothing
particularly funny.
But it does use isochronous transfers.
In this particular case, at 44.1 16 bit, I think it's 192
bytes every frame.
AUDIENCE: I was just curious--
I'm not sure if I heard correctly-- its Cortex, which
actual package?
ERIC SCHLAEPFER: Well, you can certainly open it
up and take a look.
We're using the SAM3X processor from Atmel.
AUDIENCE:: OK, cool.
And is everything pinned out?
ERIC SCHLAEPFER: Most things are pinned out.
There's a couple of things that aren't because, well, we
ran out of Arduino pins.
AUDIENCE: OK, great.
Thank you.
but Eric spent a lot of time making sure all the more
interesting things are available for you.
So the things missing might be just some bare GPIOs.
ERIC SCHLAEPFER: That's a good point.
And we really didn't have time to mention it in the actual
But when I went through and planned out which pins went
out to which Arduino pins, I was very careful to make sure
that all the interesting pins that have hardware accelerated
functions actually go out to Arduino pins.
So, for example, the SAM3X actually can support an
external Ethernet FI.
And so, I made sure that all those connections made it out
to Arduino pins.
So that means that somebody-- maybe even one of you-- could
make an Ethernet shield for this device very easily.
AUDIENCE: And could we actually flash our own
firmware too?
DMITRY GRINBERG: Oh, of course.
AUDIENCE: So all the code for this is out too [INAUDIBLE]
DMITRY GRINBERG: The code is out.
The tools are out.
You can grab one and flash it five minutes from now.
TRAVIS GEISELBRECHT: It's very simple actually.
One of the two ports acts like a serial
port, the debug board.
And the Atmel ROM has a loader mode.
It's well understood.
There's an open source tool called BOSSA out there that
people use to update these things.
And, yeah, absolutely, you're flashing it from
zero right on up.
DMITRY GRINBERG: One addition to that is we have our own
tool called the ADK 2.0 Tool, which is just used
to erase the chip.
It just so happens that whenever you plug this into
certain platforms that aren't Linux, the device gets erased
all by itself because those platforms insist on twiddling
the control lines in the serial port.
So we have an extra little microcontroller on the board
to avoid such unpleasantries.
So there is a tool called the ADK 2.0 Tool, which we're
releasing in source and binary, which you use then to
erase the device.
Once it's erased, the Atmel bootloader takes over and you
can load your own firmware.
ERIC SCHLAEPFER: It's actually kind of a fun hack because
we're using the control lines.
And one of them becomes a clock line.
The other one becomes a data line.
And we actually clock a little magic number into this tiny
little microprocessor.
And when it sees the right code, then it
tweaks the erase pin.
And so you don't have to interact with any physical
buttons to erase the code at all.
AUDIENCE: My question is about the NFC.
According to the document at the developer site, using by
NFC, lock the device and unlock the device [INAUDIBLE].
So my question is, [? from your ?]
[? call ?]
can [? interrupt ?] with some other devices through NFC or
DEP or some protocol?
So the question has to do with NFC.
And we have an NFC Tag on the device.
And that's a passive tag.
And what it does is it sends your phone to Google Play to
download the application.
We didn't lock it.
So it's in read/write mode, which means you could peel it
off and put something else on it if you want to.
The ADK itself doesn't really support NFC at this point.
Although if you're interested, you may be able to put
together a shield for us, which would be awesome.

AUDIENCE: Have you guys explored the possibility of
building a REST API to allow, maybe, HTML, JavaScript
I know with Raspberry Pi I've explored that.
And it's really accelerated prototyping.
DMITRY GRINBERG: Well, I mean, this would make a little more
sense if we had a network-connected device.
But we don't actually have Wi-Fi on this device.
So maybe once we have Wi-Fi--
AUDIENCE: I actually meant on the Android side of it.
So the actual server, REST, API would reside on the
Android device.
And you could actually have HTML5 apps.
They would interact.
DMITRY GRINBERG: I don't think any of us have
thought about it.
But you can implement it.
I mean, the API to talk to this is available, so there's
no reason you can't do it.
And then we can come and ask you questions about it.
TRAVIS GEISELBRECHT: No, but I'll bring that up as
something to talk to the--
ERIC SCHLAEPFER: I like that idea though.
TRAVIS GEISELBRECHT: --accessory developers though,
yeah, absolutely.
DMITRY GRINBERG: That could be pretty interesting.
AUDIENCE: Can you speak a little bit about battery life
and power consumption?
Of course, it depends what it's running.
But, for instance, are there low power modes?
And what are some figures for battery life and power
DMITRY GRINBERG: So, I don't think we ever meant this to be
a battery-powered device.
There's a hole in back for all the cables, including a power.
But I have run this off battery.
And it runs.
I don't think we've actually measured the battery
I don't think it was ever meant to be such a thing.
ERIC SCHLAEPFER: So, just to talk about the electrical
aspect of that, you could certainly take the base shield
and power that from a battery.
The SAM3X device actually includes a fairly complicated
power management device that will allow you to go in and
throttle the clock down.
So it's actually got a full-blown clock tree.
And there's a lot of stuff going on in there.
Most of that complexity is available if you
want to hack on it.
But for people that just want to get it working as an alarm
clock or play with Arduino, it's all hidden.
So you don't have to worry about it if you don't want to.
But if you do you want to worry about power consumption,
there are definitely ways to go in there and tweak that.
Now, obviously, if you're running all 64 RGB LEDs and
got some bass thumping on this thing, it's really not going
to last that long.
DMITRY GRINBERG: It does work on battery though.
So I can actually show that.

ERIC SCHLAEPFER: Oh, look at that.
DMITRY GRINBERG: You can do it.
AUDIENCE: So you guys mentioned just a minute ago
that you could have one of these flashed in five minutes.
So I'm just kind of curious.
I came in a little late.
So maybe you said it.
But what's the availability on these devices?
And how can we get our hands on them?
DMITRY GRINBERG: I believe all you already will get your
hands on it.
ERIC SCHLAEPFER: That's actually a really good segue.
Since we're nearing the end of the session, everybody in this
room is going to get their own ADK.
AUDIENCE: Just a question out of curiosity.
You said you checked the Bluetooth connection with
various other platforms.
Does that include a major rivaling
mobile operating system?
DMITRY GRINBERG: I don't have a Windows Phone.
So I can't tell you that.
DMITRY GRINBERG: However, it does work with another rival
operating system.
I actually use mine at home to play music off of my iPhone.
ERIC SCHLAEPFER: Is that the one from a certain Cupertino
fruit company?
AUDIENCE: Thank you.

AUDIENCE: Are you providing any reference
schematics or PCV docs?
So, they're all being posted on the
website in EAGLE format.
So you can pull them up in the free version of EAGLE and
start hacking away.

AUDIENCE: What's the current and future status of
availability of shields for this?
So, I mean, it's a fairly standard pin
out, it looks like.
But I'm just wondering if you can sort of talk about what's
out there that can be already plugged into this today.
ERIC SCHLAEPFER: So the device is compatible with any Arduino
Version 3.0 shield and that's because
it's a 3.3-volt device.
And so any shield that wants to use that needs to have its
own on-board level shifters.
And so the V3.0 Arduino shield format includes that inner
So there's a reference pin that you use to set the
reference voltage and communicate
that onto the shield.
And so if you have a V3.0 shield, you plug it in, it
should just work.
AUDIENCE: How much memory do we have on
the outer unit itself?
DMITRY GRINBERG: So there's a few memories here.
So let me go over them.
The SD card the units come with, I
believe, is four gigabytes.
The device itself has 512 megabytes of flash for storing
code and constant data.
DMITRY GRINBERG: Oh, I'm sorry, 512 kilobytes.
Wishful thinking, I must say.
And the device itself has 100 kilobytes of RAM as well.
There's 96 contiguous kilobytes for--
and there's also four more in the NAND controller, which
we're not using.
So you can use those as well.
So it's about 100 kilobytes of RAM total.
AUDIENCE: OK, great.
AUDIENCE: Hi, could you also elaborate on availability for
things like educational discounts or just general
consumer buying the device in the future, what the plans are
going forward?
ERIC SCHLAEPFER: At this point, it's a giveaway for
Google I/O. There may be some future plans.
All I can say is, stay tuned.
AUDIENCE: OK, thanks.

Any more questions?
DMITRY GRINBERG: I think there's a person raising their
hand right there.
ERIC SCHLAEPFER: I don't see any hands.
DMITRY GRINBERG: Must have been stretching.
All right.
Thank you very much.
And before you guys leave the room, please note that for the
giveaway there are going to be people by the
doors holding cards.
Be sure to grab a card because that is your ticket for your
free ADK that you can get at the stuff booth
on the first floor.
Thank you for coming.