# 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) <a href="#toc80884393" id="toc80884393"></a>

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 <a href="#toc80884394" id="toc80884394"></a>

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) <a href="#toc80884395" id="toc80884395"></a>

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:

* Install the App [BLE Peripheral Simulator](<https://play.google.com/store/apps/details?id=io.github.webbluetoothcg.bletestperipheral >)
* Open the App and you should see a screen similar to the one below.

|                                  |
| -------------------------------- |
| ![](/files/avfnawyd56qn0OEFoxh7) |

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

|                                  |                                  |
| -------------------------------- | -------------------------------- |
| ![](/files/wYPR1XDYu7XWtVfTIuTV) | ![](/files/tIRgjvuDEHrRoGjryU3B) |

* 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](https://github.com/WebBluetoothCG/ble-test-peripheral-android/blob/master/app/src/main/java/io/github/webbluetoothcg/bletestperipheral/BatteryServiceFragment.java) 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) <a href="#toc80884396" id="toc80884396"></a>

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](https://play.google.com/store/apps/details?id=com.punchthrough.lightblueexplorer\&hl=en_US) or [iOS](https://apps.apple.com/us/app/lightblue/id557428110).
* 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.

|                                  |                                  |
| -------------------------------- | -------------------------------- |
| ![](/files/YrSE1gYE35BkcwpkaYA0) | ![](/files/j57jVscHsU0u1j40r3rP) |

* Select your Peripheral device and click on the CONNECT button. Now the Central (Client) is connected to the Peripheral (Server).&#x20;

|                                  |
| -------------------------------- |
| ![](/files/jI4TeJDEnIsCfELfhizw) |

* Scroll down and select the Battery Service.
* Click on the SUBSCRIBE button.

|                                  |
| -------------------------------- |
| ![](/files/nU1vUqTsV99NbO3yxryR) |

* 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](http://www.zytrax.com/tech/protocols/hex.html) for more info on the data formats and conversion.

|                                                              |   |
| ------------------------------------------------------------ | - |
| \<img src="/files/3UdUCLyrLdKY8ff4Kxb0" alt="Waterfall chart |   |

Description automatically generated" data-size="original"> | \<img src="/files/BkIOUKVzChQysmqr4xMn" alt="Graphical user interface, text, application

Description automatically generated" data-size="original"> |

* 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](https://betterexplained.com/articles/understanding-big-and-little-endian-byte-order/). 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](https://www.scadacore.com/tools/programming-calculators/online-hex-converter/) for more info.

|                                                                                          |   |
| ---------------------------------------------------------------------------------------- | - |
| \<img src="/files/3krzfxIfr1xomir61dGK" alt="Graphical user interface, text, application |   |

Description automatically generated" data-size="original"> | \<img src="/files/IIG3dvwdu3gwpwgW3UId" alt="Graphical user interface, text, application

Description automatically generated" data-size="original"> |

### References <a href="#toc80884405" id="toc80884405"></a>

* [Bluetooth Low Energy - Wikipedia ](https://en.wikipedia.org/wiki/Bluetooth_Low_Energy)
* [Bluetooth Special Interest Group](https://www.bluetooth.com/learn-about-bluetooth/tech-overview/)
* [What is BLE?](https://www.ruralsourcing.com/centare-is-now-rural-sourcing/)
* [Bluetooth low energy Services, a beginner's tutorial ](https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-services-a-beginners-tutorial)
* [BLE in IoT](https://www.u-blox.com/en/publication/white-paper/use-case-possibilities-bluetooth-low-energy-iot-applications)
* [A Complete Guide to BLE Beacons ](https://blog.beaconstac.com/2018/08/ble-made-simple-a-complete-guide-to-ble-bluetooth-beacons/)
* [iOS BLE Simulator](https://www.u-blox.com/en/publication/white-paper/use-case-possibilities-bluetooth-low-energy-iot-applications)
* [Hexadecimal, Decimal and Binary](http://www.zytrax.com/tech/protocols/hex.html)&#x20;
* [Understanding Big- and Little-Endian Byte Order ](https://stackoverflow.com/questions/247873/signed-versus-unsigned-integers)
* [Online Hex Converter ](https://www.scadacore.com/tools/programming-calculators/online-hex-converter/)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.novacura.com/extensibility-and-integration/products/studio/applications/workflow/how-to-guides/bluetooth-low-energy-quick-start-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
