Skip to content

IOIO Over Bluetooth

ytai edited this page Oct 25, 2011 · 20 revisions

#IOIO Over Bluetooth

Introduction

Starting at Bootloader V3.0 + App V3.10, IOIO can communicate with your Android device over Bluetooth connection. This is achieved simply by attaching a standard Bluetooth dongle into the USB jack on the IOIO board. Not every possible dongle has been tested. The following ones have been verified to work:

The application code required to use IOIO over Bluetooth does not need to change when using AbstractIOIOActivity. Existing applications will need to be re-built against the new libraries according to the instructions below.

Note that Bluetooth is supported on Android API level 7 ("2.1-update1") and higher.

Credits

This feature uses code from the btstack Open-Source Project. This is an excellent library, especially suited for embedded devices, which enabled delivery of this feature in a timely manner. Special thanks go to Matthias Ringwald, the owner of btstack, for his wonderful code and time spent on supporting this integration!

Usage

Firmware

Use the IOIO Manager application in order to upgrade both the bootloader and the application-layer firmware. You will need bootloader V3.0 or greater and application V3.10 or greater. Both are available from the Downloads page. The bootloader has to be upgraded first. As a shortcut, an image bundle which includes both is provided. Note, however, that this process is slower than upgrading the bootloader first and then using it to upgrade the application.

Software

You will need to use IOIOLib V3.10 or higher (available from the Android Software column of the Downloads page). This new library only adds support for multiple connection channels in your application, but does not add Bluetooth functionality. In order to use Bluetooth, you need to also add the IOIOLibBT library to your application (from Eclipse: Project > Properties > Android > Add... > Choose IOIOLibBT after importing it to your workspace).

Last, you need to add the BLUETOOTH permission to your application (edit your application's AndroidManifest.xml file, in the "permissions" tab, add a uses-permission and select android.permission.BLUETOOTH).

Pairing

In order for your application to be able to identify your IOIO boards within range, they first need to be "paired" with your Android device. Pairing is a one-time process done per dongle. Once paired, your Android device is going to remember the specific dongle and will not require pairing again.

  • Power your IOIO board and attach the Bluetooth dongle to it.
  • On your Android device, go to Settings > Wireless & networks > Bluetooth settings menu. Make sure Bluetooth is enabled by checking the top box. Then hit "Scan for devices".
  • You should see a device called IOIO (xx:xx), where xx:xx are the last 4 digits of your IOIO's address. If you have more than one IOIO, each one will have a different address, making it possible to distinguish between them. The address comes from the dongle and not from the IOIO, so if you swap two dongles, the addresses will go with the dongles and not with the IOIOs.
  • Click the IOIO in order to pair. You will be asked for a PIN code. Enter 4545 (which is, by the way, what you get if you dial IOIO on a phone).
  • Your IOIO is now paired, until you manually Unpair it (by long clicking the device from the same screen).

Establishing a Connection

Simply open the application built as explained above. You can leave the Android device connected over USB to your development PC, thus read real-time logcat, debug the application, etc. Connection may take a few seconds.

If you have Android version less than 10 (2.3.3), you may be required to enter the PIN (4545) upon every connection. This is a limitation of these versions of Android (they cannot open an insecure connection), and at the time of writing this a workaround has not yet been found. You may want to change when IOIO gets connected / disconnected in your application, or prevent your Android from sleeping in such cases.

Caveats

  • Multi-IOIO support has not been thoroughly tested. If problems are found, they will hopefully be addressed down the road.
  • The latency over Bluetooth is significantly higher than of wired connections (order of 10's of ms).
  • The bandwidth (data rate) of Bluetooth is significantly lower than of wired connections (order of 10's of KB/sec). In practice, this means that bandwidth consuming features (e.g. Analog Input) may not work 100% smoothly. There is a plan to enable programmatic reduction of the analog sample rate in order to mitigate this limitation.