ADK 1.0 devices fail to work with Jelly Bean, why?

天大地大妈咪最大 提交于 2019-12-07 04:45:16

问题


Just connected the tried and true ADK accessory to Nexus 7 and Galaxy Nexus - and it failed to connect with "could not read device protocol version" message. Thought that the board died, connected to Nexus S with ICS - worked just fine. Worked on Galaxy Nexus before Jelly Bean upgrade as well, so hardware failure can be ruled out.

I've been watching ADK announcements pretty closely, but don't remember reading or hearing anything about this particular change, nor backward compatibility of Android devices supporting ADK 2.0.

Accessory Development Kit 2011 Guide says "Protocol version 1 is supported by Android 2.3.4 (API Level 10) and higher. Protocol version 2 is supported by Android 4.1 (API Level 16) and higher", it doesn't say that version 1 is not supported by 4.1, and it would be pretty bizarre to find that existing hardware would be abandoned just like that.

What am I missing here? Is this a bug or a feature?


回答1:


The old ADK1 libraries released last year don't recognize the new AOA v2 protocol that JellyBean devices (Android 4.1 and up) speak. This was fixed in an updated ADK1 library release.

Go get the new ADK1 libraries:

  • http://developer.android.com/tools/adk/adk.html (look for "release_20120606" or higher in the zip download)

Update your ADK libraries and upload your ADK1 sketch. Note that the new libraries have been updated to work with Arduino 1.0 and higher, so you will probably have to update your Arduino IDE as well.




回答2:


In reply to @Chris Stratton, the issue is the original library was not written with future compatibility in mind.

The original library assumes (by way of the protocol == 1 check in switchDevice()) that future protocol versions will not be backward compatible. It appears from the 20120606 library version (by implication of the revised protocol >= 1 check in switchDevice()) that the intention is now that future library versions are expected to be backward compatible.

Unfortunately this means existing firmware compiled with the original version of the library are not compatible with Jelly Bean devices. The firmware needs to be recompiled with the new library version and re-uploaded to the accessory.

Note also that as I write this there is an error in the documentation where the "ADK package" link in the side bar links to the older library version, not the newer version linked in the body text. (I have added a bug for this: https://code.google.com/p/android/issues/detail?id=35463)

Additional information:

  • Note that http://developer.android.com/tools/adk/aoa2.html#detecting says: "Version 2.0 of the protocol is upwardly compatible, so accessories designed for the original accessory protocol still work with newer Android devices." But this ignores the issue with the original library.

  • Note also that the code in http://developer.android.com/tools/adk/adk.html#start-adk and http://developer.android.com/tools/adk/aoa2.html#detecting both use the protocol >= 1 incantation. (I can't verify this but given the original library didn't use this version of the check I think the ADK2011 documentation has been updated to use the new check.)




回答3:


I have managed to run the old ADK with my Jelly Beans device. Here are the details:

  • Running on Mac OS Mountain Lion
  • With Arduino Mega ADK
  • Samsung Galaxy S3 with 4.1.1

Steps:

  1. download darduino-1.0.1-macosx
  2. Empty the Documents/Arduino Folder
  3. Create a folder libraries in it
  4. Download the USB compatibilty files from labs.arduino.cc/uploads/ADK/GettingStarted/ArduinoADK-beta-001.zip.
  5. After unzipping copy the ArduinoADK-beta-001/libraries/UsbHost folder into the libraries folder mentioned above.
  6. Get the AndroidAccessory folder and copy it into libraries. Soory, Ican remember where I got it from. It is necessary so that the code can compile, because in knows what an Accesory is. This folder especially contains the AndroidAccessory.cpp and AndroidAccessory.h
  7. Start Ardoinu and for example upload the code to your board (Please insert # before the includes and definces, code format does not display it):

    include < Max3421e.h > include < Usb.h > include < AndroidAccessory.h > define ARRAY_SIZE 12;

    AndroidAccessory acc("Manufacturer", "Model", "Description", "Version", "URI", "Serial");

    char hello[12] = {'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'};

    void setup() { Serial.begin(115200); // acc.powerOn(); acc.begin(); }

    void loop() {

    if (acc.isConnected()) { for (int i=0; i < 12; i++) { Serial.print(hello[i]); delay(250); }

    Serial.println(); delay(250); } }

    1. When connecting the S3 via USB you should see the output in the Serial Monitor.

Best regards FL




回答4:


Simply changing the firmware from (protocol==1) check to (protocol>=1) worked for me (at least for enumeration - sending and receiving still needs to be tested). My hardware is LPC1768 mbed. (http://mbed.org/cookbook/mbed-with-Android-ADK)



来源:https://stackoverflow.com/questions/11563427/adk-1-0-devices-fail-to-work-with-jelly-bean-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!