Bluetooth Low Energy


Bluetooth Low Energy (a.k.a Bluetooth LE, BTLE, Bluetooth Smart)

UART access over BLE

Overview

If you want to receive console outputs from an updated app, it is possible to do so over the BLE UART Service. For instance, the default app that comes bundled with the boot loader generates regular pings on the RX characteristic of the UARTService. These pings can be received using several UART apps, such as Nordic's nRF UART.

Please note:

  • Presently, you cannot have more than one active connection to a BLE device. For example, if you're working with a heart-rate application and you've connected to it using nRF UART for console output, then you cannot simultaneously connect to it from another heart-rate phone app.
  • Console messages are sent in notification packets of up to 20 bytes; this limit is imposed by the Bluetooth standard. Longer messages need to be cropped into a sequence of 20-byte packets.
  • Output buffers internal to the UARTService are flushed upon encountering a newline character; the receiving UART application should be able to stitch together cropped portions of longer messages.

Using the UART Service

The following program illustrates the use of UARTService to redirect something like printf() to use the BLE transport.

Import programBLE_UARTConsole

A console service.

code changes needed to redirect console output to UART Service

#if NEED_CONSOLE_OUTPUT
#define DEBUG(STR) { if (uart) uart->write(STR, strlen(STR)); }
#else
#define DEBUG(...) /* nothing */
#endif /* #if NEED_CONSOLE_OUTPUT */


    uart = new UARTService(ble);
    DEBUG("ping\r\n");

You will also need to include UARTService.h.