Bluetooth Low Energy Quick Start Guide

Introduction

This document serves as a Quick Start Guide for anyone who wants to setup BLE connectivity in order to utilize this technology with Novacura Flow.

BLE (Bluetooth Low Energy)

BLE or formerly known as Bluetooth Low Energy is a low power wireless communication technology that can be used over a short distance to enable smart devices to communicate. Compared to Classic Bluetooth, BLE is intended to provide considerably reduced power consumption and cost while maintaining similar capabilities. Therefore, BLE is especially well suited for sensors, actuators and other IoT devices that require periodic transfer of data while maintaining extremely low power consumption. There are many use cases of BLE in industrial settings such as Asset Tracking, Internal Navigation, Security, Advertising & etc.

BLE uses a Client/Server or Central/Peripheral model.

  • Central (Client) - A device that initiates request and accepts responses.

    • Examples: computer, smartphone

  • Peripheral (Server) - A device that receives requests and returns responses.

    • Examples: a temperature sensor

Advertising is how devices are found in BLE. Peripherals (Server) advertises its availability for connection by broadcasting packets of data at regular intervals. The Central (Client) scans for nearby peripherals and when it finds a device (Peripheral) it wants to connect to, it initiates a connection. Once connected the Central (Client) can begin exchanging information with the Peripheral (Server).

Peripheral vs Central

To demonstrate the concept of Peripheral/Central model we can use two smart phones. One will act as Server and the other will act as Client.

Peripheral Device (Server)

BLE device that advertises its availability for connection. Usually, it is a sensor or some form of IoT device. For demonstration purpose we will use an Android smartphone to act as Peripheral with the help of a third-party app available in the market.

On your Android device:

  • Click on Battery and you will be asked to turn on Bluetooth if not already done.

  • Now the device is ready to act as a Peripheral. As long as you are on the above screen, the Peripheral device will advertise the Battery Service with battery level. You can set the battery level by editing the numeric value or by dragging the progress bar.

  • According to the BLE Simulator app source code the battery level is an Integer ranged between 1-100 and transmitted as a single Byte. This piece of information is important since we need set a compatible data format at the receiving end (Central device).

Central Device (Client)

BLE device that connects to the Peripheral. This can be a PC, Tablet, or a smartphone. In Flow context, the device which runs flow (ex - Flow mobile Client) always acts as Central (Client). For demonstration purpose we will use the other smartphone to act as Central (Client) with the help of a third-party app available in the market.

On another Android or iOS device:

  • Install the App LightBlue for Android or iOS.

  • Open the App and you will be asked to turn on Bluetooth if not already done. You will see a screen with list of Peripheral devices with a CONNECT button right next to it.

  • Select your Peripheral device and click on the CONNECT button. Now the Central (Client) is connected to the Peripheral (Server).

  • Scroll down and select the Battery Service.

  • Click on the SUBSCRIBE button.

  • Now go back to the Peripheral device and click on the NOTIFY button. You should see battery level visible in Hex data format in the Client Device. For example, if the battery level set in Peripheral is 80 the corresponding Hex value is 50. Please refer this conversion table for more info on the data formats and conversion.

  • You can change the data format by simply clicking on the Data format dropdown. For string values, you can use UTF-8 String. If you choose Binary, data will be visible in Binary format.

  • For dealing with numeric values there are 4 combinations. There is Little-Endian & Big- Endian which corresponds to the Byte order. This is applicable for large number and floating-point values involving multiple Bytes of data. To Read more on the topic, refer to this article. The Signed & Unsigned corresponds to positive and negative numbers.

  • In our Battery Service use case, the battery level is an Integer ranged between 1-100 (always a positive value) and transmitted as a single Byte. Hence no matter what you choose among the Unsigned Little-Endian, Signed Little-Endian, Unsigned Big-Endian or Signed Big-Endian. It will be always the same. For example, if you choose Signed Big-Endian you will see the battery level changed to 80. Refer this online converter for more info.

References

Last updated