Electronic – Bluetooth LE with BlueGiga devboard (BLE112)

bluetooth

This is my first post so please forgive me for any informality but I will get straight to my point.

I am trying to send RS-232 data (8N1 asynchronous at 115,200+ baud rate) from my PIC micro via bluetooth to a smartphone. I have done this successfully with Bluetooth 2.0 but that was easy since I was able to source BT 2.0 modules with an AT command set that allowed me to configure it to whatever baudrate I wanted. Now I am transitioning to Bluetooth LE (single mode) using the Blue Giga evaluation kit and BLE-112 module. I have a general idea of how to code the BLE-112 to receive serial data using its UART but not sure how to send that data to the radio. It looks like I'll have to save the received data into a GATT file after which it will be transmitted in one of the packets? Is there any way I can just stream data like I did with BT 2.0?

Lastly, I would be streaming the data to the Bluetooth module and I know that Bluetooth 4.0 dual mode may be the better option but this single mode version is what I have to work with at the moment.

Best Answer

As you probably know the BLE112 is a Bluetooth 4.0 single mode module, meaning it doesn't support/interoperate with Bluetooth devices older than version 4.0. The iPhone 4s and iPhone 5 are pretty much the most popular phones that have Bluetooth 4.0 support and provide APIs to use Bluetooth 4.0. Some android vendors have their own APIs such as Motrola for its Razr phone, but there is no Android API for Bluetooth 4.0. Currently any solution you make is not going to work with just any smartphone with Bluetooth.

Bluetooth 4.0 is also very different to older Bluetooths in the way it transmits and handles data. All data packets are only 20 bytes long. As you have read, at the heart of it is the slave device's (typically a sensor) GATT database which can be through of as a table with keys and values. Compared to the serial port profile (SPP) this is a very different way of thinking of data.

You can read and write the values (attributes) of the keys (attribute handles) locally (sensor / slave) or remotely (mobile phone). The idea with gatt is that instead of you writing your data like name,measurement,timestamp in one long data stream, you update the name attribute ("value"), measurement attribute and timestamp attribute in the sensor's local gatt. These changes then gets indicated to the mobile phone over the air. In short: Bluetooth 4.0 is not intended to be used for creating a data stream.

However, it is always possible to simulate or emulate streaming even when everything is packetized. Bluegiga provides a "Bluetooth Smart: Cable replacement application note" (registration required) which discusses exactly how to replace a UART cable with Bluetooth 4.0 and they give detailed explanations of how to accomplish that with the BLE112.

Update: Any device with Bluetooth and an Android version 4.3 or newer supports Bluetooth 4.0 natively. All the old vendor specific stacks have been deprecated in favor of the official support.