3
\$\begingroup\$

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.

\$\endgroup\$
3
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Thank you for the thorough explanation. I downloaded the "Cable replacement application note" but was not able to find documentation for it aside from the comments in the code. It does shed some light for me and I will be doing tests today. Another question - I understand that Bluetooth 4.0 dual mode is NOT Low Energy? Having said that, would dual mode still work on the iPhone 4S/5 without requiring the MFI license? Cheers, Jason \$\endgroup\$ – user15564 Oct 25 '12 at 17:54
  • \$\begingroup\$ So dual mode aka Bluetooth Smart Ready can be used in both modes simultaneously, that is it supports Bluetooth ("classic") and Bluetooth Smart ("low energy"). If you need a custom app that uses classic profiles such as support for SPP, you need to go through MFI. However when you use only low energy features, MFI is not required. MFI is also not needed if your device only needs for example HID or Hands Free Profile and is content with the drivers IOS provides. \$\endgroup\$ – Mikko Virkkilä Oct 25 '12 at 19:11
  • \$\begingroup\$ Thanks for all the information, definitely clears things up. I've been doing a lot of research and have come up with many different figures on maximum application throughput using BTLE. From one source I reckoned it mentioned up to 256K baud but another mentioned that the 4S will only take in up to a measured 36K baud.. Would you have any knowledge on this? Thank you! \$\endgroup\$ – user15564 Oct 26 '12 at 17:05
0
\$\begingroup\$

Coming straight to the point:

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?

When you build the .bgproj file using BleUpdate utility, it generates a .txt file along with the .hex. This text file has a list of all attributes and their ids. These ids is what you pass as an argument to the write function.

ble_cmd_attclient_write_command(connection,atthandle,data_len,data_data)

atthandle should be the id that you obtain from .txt file.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.