Skip to content

IOIO Over Bluetooth

jeffeb3 edited this page Jul 12, 2012 · 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. Check this wiki page for devices that have been reported to work: Supported Bluetooth Donges

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 only 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!

Upgrade Instructions

This is a step-by-step video explaining how to upgrade your existing IOIO to support Bluetooth:

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.
  • 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. It is already known that when using more than one Bluetooth device simultaneously (as opposed to one Bluetooth and one ADB) there may be connection problems. Specifically, make sure your Android device is only paired to a single IOIO if you want problem-free connection. Otherwise, IOIO will try to establish a connection to every paired device and these attempts alone seem to be interfering with existing connections.
  • 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.

Troubleshooting

If you are having trouble with blue tooth, here are some things you can do with your current hardware to fix the problem:

  • Turn up the charge limiting dial.
  • Unpair, restart the phone, pair again.
  • Try pairing from your PC. You should get a serial port. Open a terminal on that port, see if you're getting a handshake message from the IOIO.

Hardware troubleshooting

If the above techniques don't work, or don't work well enough, changing the hardware may be the easiest solution.

  • Some dongles won't work with IOIO. For example if the dongle presents itself as a USB hub. See Supported Bluetooth Donges
  • Some Android versions and devices won't work with IOIO over Blueooth. Check if the device supports SPP (Serial Port Profile) and check this list: Supported Devices
  • Some dongles work with one Android device but not with an other. Because of this, please add your tested dongle with all information to the Supported Bluetooth Donges list.