Wednesday, May 9, 2012

Android Bluetooth App Development Test Fixture

The standard android app development environment as of May 2012 doesn't appear to allow Bluetooth.  It appears that you have to use a virtual environment.  I chose Oracle VM VirtualBox as my test bed.  Below are my notes on getting this to work.

Basic Virtual Box Setup

Download the eeepc version of Android from Google following this guys instructions.

Here is the summary of the Oracle Virtual Box Settings I used:

General

  • Name: "name for this instance"
  • Operating system: Linux
  • Version: Other Linux

Storage

  • Add eeepc.iso image as cd rom device

Network

  • Attached to: Bridged Adapter
  • Name: etho
  • Adapter Type PCnet-FASTIII (AM79C973)

USB

  • Check Enable USB Controler

Allowing USB devices requires that you add your user account to "vboxusers" as root with usermod -a -G vboxusers username then log out and back in again!


Start the virtual box and let Android boot.

Brining up Networking 

Ronubo has a good guide, here is the summary
Bring up a terminal prompt in Android (there's one there somewhere).
Bring up the interface with:
  • netcfg eth0 dhcp  # brings up eth0 and gets dhcp address
  • route  add default gw xxx.xxx.xxx.xxx dev eth0 
  • setprop net.dns1  10.1.1.13  # Nubo DNS1
  • setprop net.dns2  10.1.1.12 # Nubo DNS2
  • setprop net.dns3  8.8.4.4 # Google DNS
I only used one DNS server (Google) and that seemed to work
If you've completed the above you should be able to browse the net

Here's a hint alt+F1 and alt+F7 toggle terminal window/ gui


If Android goes to sleep its hard to wake up.  From Virtual box send the shutdown signal, then use the mouse to unlock the device (wierd)

Unfortunately none of this can be saved if you stop the machine,  I suggest taking a snapshot at some point and use that (untested).

Setting up ADB Connection 

On the Linux host – connect to ADB as follows:
On this example, our Android IP address is 192.168.1.109/2 , ADB server runs on port 5555 (by default), so in order to connect to the target via adb we do this on the Linux host:

adb connect 192.168.1.109:5555

After that the Eclipse environment should be able to download and debug using the Virtual box environment.

Getting the USB Bluetooth to work

I had some difficulty getting Bluetooth to work.  It ended up that it was a little touchy about which USB-Bluetooth device it would work with.  I ended up with a Zonet device.  I was able to pair with a bluetooth serial device after turning on the Bluetooth from within Android.

No comments:

Post a Comment