GATT Operation Flowcharts#
Introduction#
Bluetooth Low Energy (BLE) defines a framework for a wide variety of communication schemes. It allows devices to discover each other, broadcast data, establish connections, and many other fundamental operations.
The objective of this page is to focus on the procedures defined for the "Generic Attribute Profile" (GATT) of the BLE stack.
Sequence diagrams are used to describe these procedures comprehensively, focusing on the following items:
BGAPI function calls.
Messages exchanged over the air.
Events raised by the BLE stack.
This content does not expose the Bluetooth stack packet management nor does it describe the host controller interface (HCI).
This content assumes that the necessary Bluetooth hardware is used, such as an EFR32 SoC or a BGM module.
Generic Attribute Profile (GATT) Operations#
GATT provides a framework for all profiles defined either by the Bluetooth SIG or by the user. Bluetooth profiles are implemented using a hierarchical structure:
Services: A collection of GATT entries, grouping together attributes that are related to each other.
Characteristics: Data containers. A characteristic consists of a declaration (a label) and a value.
Descriptors: Placed under a characteristic, they provide additional information about the characteristic and its values.
GATT database
*--> Services
|
--> Characteristics (always placed under a service)
|
--> Descriptors (always placed under a characteristic)
The BLE specification refers to all the attributes within a single service as the service definition.
Primary Service Discovery#
A primary service is the standard type of GATT service that includes relevant, standard functionality exposed by the GATT server. In other words, a service is a collection of characteristics. As a result, when a connection is established, it is necessary for the GATT client to be able to discover the available services.
The procedure iterates through all available services of the GATT database, an sl_bt_evt_gatt_service
event is generated for each primary service discovered. After the end of the list is reached, an sl_bt_evt_gatt_end_procedure
is raised by the stack.
After a client has obtained the handle range for a service, a similar procedure exists to retrieve a full list of the characteristics under that service.
Characteristics#
As mentioned earlier, characteristics are data containers. They consist of a declaration (a label) and a value.
There are multiple types of characteristics:
'hex' or 'utf-8' characteristics, which consist of hex or utf-8 values maintained internally by the BLE stack.
'user' characteristics, which are maintained at the application level. In other words, it is the responsibility of the application to perform the appropriate actions when a Read/Write command is received.
Moreover, on a given characteristic, different types of read/write operations can be performed. The following procedures are discussed here:
Read/Write on user characteristic.
Long read/write on user characteristic.
Notifications and Indications
The following sub-procedures are not discussed:
Read multiple characteristics
Write without response
Signed write without response
Reliable writes
For more information on these procedures, see the BLE core specification and Different Characteristic Value Types.