Introduction to Bluetooth Low Energy – 50.000 ft:
Bluetooth Low Energy (BLE) is based on Bluetooth classic. However, in Bluetooth low energy protocol, energy matters more than anything else! The BLE protocol is based on the most basic and important principle: low power consumption. A BLE device can be powered for a year; non-stop, by using only a tiny battery.
Peripheral and Central
In BLE, a peripheral is like a server. A peripheral is waiting for central to connect and start exchange data. Peripheral examples include smartwatches, fitness trackers, a keyring tracker, a medical health monitor device and so much more. On the other hand, a central device is the device tat initiates the connection to a peripheral, like a Smartphone – even though a smartphone can act either as peripheral or a central. The Peripheral may offer some services and the Central may request (from) or send information to those services (if permission is granted). An example of this kind of service is the Heart Rate Service (HRS). In short, the HRS is a service found on a peripheral and is able to inform the central about the beats of the heart. Some peripherals, support authentication by using a 6-digit PIN.
A Peripheral may offer one or more services to a central. Each service has a specific service ID, which is a Universally Unique Identifier (UUID). Finally, each service may have one or no characteristics.
Each characteristic is identified by its UUID. The other end (peer), for example, the central, may request or send values to the characteristic. Note that each characteristic has some properties. Also, the developer may set some permissions for reading or writing. For example, reading requests may be retrieved only via an encrypted connection. Moreover, some characteristic values are not allowed to be retrieved unless a condition has occurred (i.e a secret is given – protocol specific).
The Bluetooth SIG Standard has defined some standard properties required for all characteristics to have. Some basic properties are defined below:
- Read: The characteristic is readable – One may request to read its value
- Write: The characteristic is writable – One may request to write a value to it
- Write Command: The characteristic accepts writing commands
- Notification & Indication Support – When notification or indication is enabled, the other peer is notified when the value has changed.
A Peripheral usually offers some services and each service may contain some characteristics. Each peer may send information to the other peer through characteristics by using the Read or Write property.
A peripheral is a device that is waiting for connections. Just like a server. In order for the central to discover the peripheral, the peripheral has to transmit information that a central will be able to receive and get notified about peripheral’s presence. That information is available in what is called advertisement. The peripheral starts a BLE advertisement by sending advertisement packets in 3 main BLE channels while waiting for a central to connect. Once a central is connected, the BLE Advertisement stops as the mode of the peripheral is changed. The advertisement contains a lot of information regarding the state of the device such as TX Power, Service data, manufacturer data, device name and much more.