In this tutorial, we explain a short program showing how to send data to a smartphone or tablet.

Flow control

We have presented bluetooth low energy (BLE) in tutorial C-09. But we have to stress the fact that REOBoard's module needs flow control to work properly. You have been warned.

The module

REOBoard BlueTooth can send only 20 bytes messages for the time being. We will implement a 20-byte string with an incermenting / decermenting value. REOBoard's bluetooth (BlueGiga BLE112) has limitation in terms of throughput. If you intend to transmit video or even audio, that's a bad choice. The total throughput is low, and BlueTooth low energy is not made for high bit rates, but for low energy only. It's a good choice for sparse short commands or low bit rate measurements.

The program

This tutorial will reuse C-09 source code, but we will implement a simple message which just displays an incrementing number. When sending 0x01, the increment will change to decrement, and when sending 0x02, it will change back to increment. 0x00 resets the counter.

There will be one timer interrupt for the message sending, and one for the UART receiver.

Setting the timer with interrupt as well as setting the UART are already described in previous tutorials. As there are 2 interrupt routines, we will also make them mutually exclusive with _DINT() and _EINT();

The results

Getting the incrementing number string can be done with iOS BLExplr or any equivalent. Sending commands is done as in the BlueTooth tutorial (C-09).

The following oscilloscope screens show what happens with flow control. The blue curve shows when the module allows bytes to be sent to it. In this case, it's always allowed.

Flow1

 

 

 

 

 

 

 

 

 

 

 

 

The next screen copy shows the transmission when the module forbids it for a while. The blue curve shows that the module's CTS is high for a while, therefore nothing is sent. The consequence is that the transmission is a little bit longer.

Flow2

  

 

 

 

 

 

 

 

 

 

Download the C code

A summary of the first tutorials has been added as a downloadable zip file here.