http://developer.android.com/guide/topics/usb/adk.html
--
Brian
Forget the ARM port of LUFA? most the cheap ARM microcontrollers have
USB host. Microcontrollers with USB host are cheap nowadays.
That would be easier from the accessory's perspective, but it's harder
for the phone manufacturer. Especially for the phones already released
with no host controller! This way the phone only needs to support
device mode, and switch out its VID/PID. Existing phones can run the
new controller code and get accessory support. All the actual
accessory protocol is done over basic USB bulk endpoints and the phone
is really the one in charge, despite the backwards host/device
relationship.
I think either AVR or ARM are good candidates for a single-chip
accessory solution, but I don't have an Android device either.
From the other direction, it would also be an interesting project to
write a LUFA "Android device" as a stand-in for the phone. Talk to it
via UART (PC->USB serial->UART->LUFA device), and it could speak Open
Accessory to the accessory host controller. All sorts of
possibilities.
--
Brian
Thanks to success of Android, here in Portugal I can by a very
expensive or very cheap model. I bought a cheaper one of 130€ but the
cheaper on the market was 99€!
The new models have dual core ARM, 1GB RAM, etc. We can use bluetooh
keyboard and mouse and there is a technology already on some TVs and
Android to send the video and audio wireless!! I bet this devices will
be soon our portable computers, where we can type on their small
screens while on travel and use larger external screens and keyboard
and mouse, all wireless!
There are already in the market netbook "shells" where we can connect
an Android phone and we end with a working netbook.
There are even wireless power chargers fir this kind of devices :-)
Android/smart phones are the future of computers, mainly because of
being portable and so every user will buy one and also because of
business models of apps.
I think its nice that android actually opened this up to developers and
it seems like a good candidate for deans host side work.
Don.
As user, I do not want to use wires with my Android phone, I expect
all to be wireless. I think USB wired connection will be useless in
near future and the Wireless USB or something other alike will be the
"thing".
Android have a very good support of bluetooth and wifi. For point to
point connections to hardware, I believe bluetooth is the best choice.
LUFA already have some experimental code for bluetooth...
For example, there is already a good project that provides Arduino +
Bluetooth + Android API, for controlling all kind of devices:
http://www.amarino-toolkit.net/
uint8_t ProcessDeviceDescriptor(void)
{
USB_Descriptor_Device_t DeviceDescriptor;
/* Send the request to retrieve the device descriptor */
if (USB_Host_GetDeviceDescriptor(&DeviceDescriptor) != HOST_SENDCONTROL_Successful)
{
//printf_P(PSTR("\r\nProcDevDsc #1 DevControlError : %d\r\n"), DevControlError);
return DevControlError;
}
/* Validate returned data - ensure the returned data is a device descriptor */
printf_P(PSTR("\r\nProcDevDsc #2 Header.Type: %d\r\n"), DeviceDescriptor.Header.Type);
if (DeviceDescriptor.Header.Type != DTYPE_Device)
return InvalidDeviceDataReturned;
/* Validate returned device Class, SubClass and Protocol values against the Bluetooth spec values */
printf_P(PSTR("\r\nProcDevDsc #3 VendorID: %d\r\n"), DeviceDescriptor.VendorID);
if (DeviceDescriptor.VendorID != ANDROID_VENDOR_ID)
return IncorrectAndroidDevice;
/* Check the product ID to determine if the Android device is in accessory mode */
printf_P(PSTR("\r\nProcDevDsc #4 ProductID: %d\r\n"), DeviceDescriptor.ProductID);
if ((DeviceDescriptor.ProductID != ANDROID_ACCESSORY_PRODUCT_ID) &&
(DeviceDescriptor.ProductID != ANDROID_ACCESSORY_ADB_PRODUCT_ID))
{
return NonAccessoryModeAndroidDevice;
}
return AccessoryModeAndroidDevice;
}
LUFA completely resets and drops off the USB Bus after telling
Android to switch to Accessory Mode whereas successful communication
just requires a delay between the Accessory Mode command and
subsequent communication.
http://developer.android.com/guide/topics/usb/adk.html#accessory-protocol
Once an ADK device has "Attached" to LUFA it should not "Unattach"
until it is physically unattached. In its current state
AndroidAccessoryHost needs to re-enumerate after the Accessory Mode
call. Dropping off the bus causes Android to reset its USB interface
from Accessory Mode.
I have included Nexus-Computing GmbH's USBTest and simplectrl.c which
allows Linux to act as a USB Accessory and demonstrates successful
communication.
http://android.serverbox.ch/?p=262
== Unsuccessful Communication between Nexus S and LUFA:
D/Tethering( 110): interfaceAdded :usb0
D/Vold ( 71): usb_mass_storage function disabled
D/UsbService( 110): entering USB accessory mode: UsbAccessory...
I/ActivityManager( 110): Starting: Intent { flg=0x10000000...
W/Vold ( 71): Ignoring unknown switch 'usb_connected'
I/ActivityManager( 110): Displayed com.android.systemui/.usb...
D/UsbService( 110): exited USB accessory mode
== Successful Communication between Nexus S and Linux (simplectrl.c):
D/Vold ( 71): USB disconnected
D/UsbService( 110): entering USB accessory mode: UsbAccessory...
I/ActivityManager( 110): Starting: Intent { flg=0x10000000...
W/Vold ( 71): Ignoring unknown switch 'usb_connected'
I/ActivityManager( 110): Displayed com.android.systemui/.usb...
E/Tethering( 110): active iface (usb0) reported as added, ignoring
D/Vold ( 71): USB connected
E/Tethering( 110): active iface (usb0) reported as added, ignoring
== Successful communication sequence (simplectrl.c) between Nexus S and Linux:
libusb_init(NULL);
handle = libusb_open_device_with_vid_pid(NULL, VID, PID)
libusb_claim_interface(handle, 0);
response = libusb_control_transfer(
handle, //handle
0xC0, //bmRequestType
51, //bRequest
0, //wValue
0, //wIndex
ioBuffer, //for data returned from Android device
2, //wLength
0 //timeout);
usleep(1000);
response = libusb_control_transfer(handle,0x40,52,0,0,(char*)manufacturer,strlen(manufacturer),0);
response = libusb_control_transfer(handle,0x40,52,0,1,(char*)modelName,strlen(modelName)+1,0);
response = libusb_control_transfer(handle,0x40,52,0,2,(char*)description,strlen(description)+1,0);
response = libusb_control_transfer(handle,0x40,52,0,3,(char*)version,strlen(version)+1,0);
response = libusb_control_transfer(handle,0x40,52,0,4,(char*)uri,strlen(uri)+1,0);
response = libusb_control_transfer(handle,0x40,52,0,5,(char*)serialNumber,strlen(serialNumber)+1,0);
libusb_control_transfer(handle,0x40,53,0,0,NULL,0,0); // accessory mode
//attempt to connect to new (Accessory Mode) PID
for(;;){
tries--;
if((handle=libusb_open_device_with_vid_pid(NULL,VID,ACCESSORY_PID))==NULL){
if(tries < 0) {
return -1;
}
}else{
break;
}
sleep(1);
}
libusb_claim_interface(handle, 0);
// first actual data transfer from device:
response = libusb_bulk_transfer(handle, IN, buffer, 8, &transferred, 0);
For viewing you can open the included Nexus S to Linux
(simplectrl.c) libpcap capture session with Wireshark
(http://www.wireshark.org/).
I am currently working on getting usbmon into Android to enable
further debugging and testing.
> --
> You received this message because you are subscribed to the Google Groups
> "LUFA Library Support List" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/lufa-support/-/FGbkr2EkKzYJ.
> To post to this group, send email to lufa-s...@googlegroups.com.
> To unsubscribe from this group, send email to
> lufa-support...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/lufa-support?hl=en.
>
Not much needed to be changed from the stock demo:
http://code.google.com/p/micropendous/source/browse/trunk/Micropendous/Firmware/AndroidAccessoryHost/AndroidAccessoryHost.c#68
http://code.google.com/p/micropendous/source/browse/trunk/Micropendous/Firmware/AndroidAccessoryHost/AndroidAccessoryHost.c#244
A quick video showcase:
http://www.youtube.com/watch?v=mtR_U0-gC1A
The firmware:
http://code.google.com/p/micropendous/downloads/detail?name=Micropendous-2011-11-26.zip
The DemoKit App:
https://dl-ssl.google.com/android/adk/adk_release_0512.zip
http://developer.android.com/guide/topics/usb/adk.html#running-demokit
http://micropendous.googlecode.com/svn/trunk/Micropendous/Firmware/AndroidAccessoryHost/AndroidDeviceSoftware/DemoKIT.apk