Arduino BLE Library

Description

The Bluetooth low energy (BLE) protocol starts with the version 4.0 of Bluetooth specification. Whilst the previous specifications allowed just to make a sort of wireless UART, this version allows a smarter resource usage. The result is a low power communication suitable for most of chips with restrict energy requirements.

The BLE Protocol is composed by multiple role. A BLE node can act as Peripheral, Central, Broadcaster and Observer.
The broadcaster role periodically sends out advertising packets with data. It doesn’t support the establishment of a connection. Theoretically, the broadcaster role could be used with transmitter-only radios.
The observer role listen for data embedded in advertising packets from broadcasting peers.
The central is a device capable of establishing multiple connections to peers. The central role is always the initiator of connections and essentially allows devices onto the network.
The peripheral uses advertising packets to allow centrals to find it and, subsequently, to establish a connection with it. The BLE protocol is optimized to require few resources for peripheral implementation, at least in terms of processing power and memory.
Central and peripheral have not to be mistaken with client and server. There is no connection between them. Both central and peripheral can be client, server or both depending on the application

Data structure

The BLE data structure is composed hierarchically. Attributes are the smallest data entity defined. The attributes are grouped into services, each of which can contain zero or more characteristics. These characteristics, in turn, can include zero or more descriptors.



Each service, characteristic and descriptor is identified by a UUID.
A Universally Unique IDentifier (UUID) is a 128-bit (16 bytes) number that is guaranteed (or has high probability) to be globally unique.
You can define your own UUID or use a standard one.
Each attribute can have a permission.
Permission are metadata that specify which operations can be executed on each particular attribute and with which specific security requirements.

Advertising

Advertising is the way in which peripheral let central know that it is available. In the advertising packet there are the main information about the peripheral. The advertising packet is 31-byte long and has to fit a particular format that reduce the effective number of information inside. If a central wants to have further information it can send a scan request to ask for another packet called scan response in order to have other 31-byte of information. If you don’t have so much data to transfer and the 31-byte (or 62 eventually) advertising packet is enough, you can implement the broadcaster role and transfer your data without establish a connection. If you have much more data to transfer, you have to implement the peripheral role to transfer them.
Further information about advertising can be found at this link that contain a basic introduction to this argument.

Further information

In this section we have tried to give a quick and simple introduction to the BLE standard. However BLE standard is much more extensive than this. If you want to deepen some argument here is the link to the BLE standard specification:
https://www.bluetooth.com/specifications/bluetooth-core-specification

Others useful information about BLE and how it works on nRF52 can be found on the Nordic Semiconductor website:
https://infocenter.nordicsemi.com/index.jsp

Nordic also supplies an useful application to interact via BLE with your board. With this application is possible to read and write characteristics and debug the BLE communication:
https://www.nordicsemi.com/eng/Products/Nordic-mobile-Apps/nRF-Connect-for-mobile-previously-called-nRF-Master-Control-Panel

Related Functions

This library is composed by multiple classes:

  • BLEPeripheralRole (or BLEPeripheral) used to enable the BLE module with the peripheral role
  • BLECentralRole used to enable the BLE module with the central role
  • BLECentralPeer (or BLECentral) that represents the device the peripheral is connected to
  • BLEPeripheralPeer that represents the device the central is connected to
  • BLEService used to enable services the board provides
  • BLECharacteristic used to enable characteristics the board offers
  • BLEDescriptor used to enable the description for the characteristic it refers to

Written by arduino.org