Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Android Open Accessory Programming with Arduino
This is the forum to discuss the Wrox book Professional Android Open Accessory Programming with Arduino by Andreas Goransson, David Cuartielles Ruiz; ISBN: 978-1-1184-5476-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Android Open Accessory Programming with Arduino section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 16th, 2013, 04:52 PM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default AoA using Android 4.2

Has anybody had luck using this books implementation of AoA using Android 4.2?

I believe the newer AoA2.0 (libraries-v2 directory) libraries for arduino are required.

Using the steps followed in the book (and the library directory suggested by the author), I have replaced usb.powerOn() in the setup loop with usb.begin(). The sketch compiled and loaded okay on my ArduinoADK, but when connected to my phone nothing happened - either with USB debugging on or off.

I attempted to use the newer v2 libraries, but they are significantly more complicated at first glance.

Any thoughts? I was hoping this book would clear up these issues, as these were the issues I was having earlier when attempting to use AoA. I would be extremely disheartened if the AoA implementation used is not compatible with the latest android software considering the recent publishing date.
 
Old February 20th, 2013, 10:20 AM
Registered User
Points: 17, Level: 1
Points: 17, Level: 1 Points: 17, Level: 1 Points: 17, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Same problem here

I also tried the temperature sensor example with a Nexus 7 tablet running Android 4.2.1.

In the Arduino Application, I also replaced the usb.powerOn() line by usb.begin(), I can successfully build and upload the Arduino Application.

I rebuilt the t.apk function with Eclipse with API 17 (Android 4.2)

here is the log from Eclipse when the application is downloaded
[2013-02-20 08:55:55 - Temperature Sensor] ------------------------------
[2013-02-20 08:55:55 - Temperature Sensor] Android Launch!
[2013-02-20 08:55:55 - Temperature Sensor] adb is running normally.
[2013-02-20 08:55:55 - Temperature Sensor] No Launcher activity found!
[2013-02-20 08:55:55 - Temperature Sensor] The launch will only sync the application package on the device!
[2013-02-20 08:55:55 - Temperature Sensor] Performing sync
[2013-02-20 08:55:55 - Temperature Sensor] Uploading Temperature Sensor.apk onto device '015d25687a202015'
[2013-02-20 08:55:56 - Temperature Sensor] Installing Temperature Sensor.apk...
[2013-02-20 08:55:57 - Temperature Sensor] Success!
[2013-02-20 08:55:57 - Temperature Sensor] \Temperature Sensor\bin\Temperature Sensor.apk installed on device
[2013-02-20 08:55:57 - Temperature Sensor] Done!

Is there a way to start the temperature sensor application Manually?

Thanks

cmassicot
 
Old February 20th, 2013, 10:41 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by cmassicot View Post
I rebuilt the t.apk function with Eclipse with API 17 (Android 4.2)

[2013-02-20 08:55:57 - Temperature Sensor] \Temperature Sensor\bin\Temperature Sensor.apk installed on device
[2013-02-20 08:55:57 - Temperature Sensor] Done!

Is there a way to start the temperature sensor application Manually?
I did not think of the error being on the android application side. I had assumed it was due to the tablet not recognizing the older AoA libraries.

The developer for the temperature application must have chosen to leave the launcher action out, so you can't launch it as a normal application. I assume that it only launches when it detects an android accessory with the details the author has entered in the Arduino code (make/model/etc).

I will have to dig through the android code a bit when I have some time and verify it matches up with the information in the arduino code. Been pretty busy, but will see if I can dig through it.
 
Old February 21st, 2013, 10:44 AM
Registered User
Points: 17, Level: 1
Points: 17, Level: 1 Points: 17, Level: 1 Points: 17, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default It Works!

I just recompiled the Arduino application with the USBHost libraries provided by the author and the temperature sensor example worked immediately.

here is a link to the library.

https://github.com/cmassicot/P2PMQTT..._Libraries.git

cmassicot
 
Old February 21st, 2013, 10:54 AM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by cmassicot View Post
I just recompiled the Arduino application with the USBHost libraries provided by the author and the temperature sensor example worked immediately.

here is a link to the library.

https://github.com/cmassicot/P2PMQTT..._Libraries.git

cmassicot
Recompiled the Arduino side... not the android side, correct?

I'll take a look at the library when I have some time, I appreciate it.
 
Old February 21st, 2013, 11:00 AM
Registered User
Points: 17, Level: 1
Points: 17, Level: 1 Points: 17, Level: 1 Points: 17, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Recompiled

Actually I recompiled both Arduino and Android code.

I recompiled the Arduino with the latest libraries provided and recompiled the temperature sensor project Android code with API 17.

The only thing that I modified in the Arduino code was the line usb.begin Android code, it currently runs on Android 4.2.2

cmassicot
 
Old March 6th, 2013, 10:11 PM
Registered User
Points: 18, Level: 1
Points: 18, Level: 1 Points: 18, Level: 1 Points: 18, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2013
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I found my issue, regardless of if I recompiled the android code to a newer SDK version.

After adding a few serial.print commands in my arduino code, I found that the board was not accepting my protocol version of my nexus 7 tablet. Digging through the AndroidAccessory.cpp file, I made the following modification:

Code:
bool AndroidAccessory::switchDevice(byte addr)

{
int protocol = getProtocol(addr);

if (protocol == 1) {
     Serial.print(F("device supports protcol 1\n"));
     } 
else if (protocol == 2) {
     Serial.print(F("device supports protocol 2\n"));
     }
else {
     Serial.print(F("could not read device protocol version\n"));
     return false;
     }
Since the newer devices will return a "2" when they support AoA 2, it is required to allow the old libraries to accept a 2, as opposed to only a 1.

Last edited by Heide264; March 6th, 2013 at 10:14 PM..




Similar Threads
Thread Thread Starter Forum Replies Last Post
New to Android Abhishek A S BOOK: Beginning Android Application Development 2 March 17th, 2013 08:13 AM
Android harfsaleh Linux 0 November 10th, 2012 03:56 PM
android and internet daniel.hlima BOOK: Professional Android 2 Application Development 0 April 18th, 2011 05:05 PM
Android SDK/Android.bat does not find SWT.jar file chaoticandroid BOOK: Professional Android 2 Application Development 1 March 23rd, 2011 06:39 PM
i am new to android janardhan BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 2 July 29th, 2010 03:37 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.