GATT protocol
GATT is a protocol style of exchange data over the wireless Bluetooth connection that is introduced for BLE 4.0.
The Bluetooth connection can consist of many services. A service is like data channel or view as a data object passing to and from the Bluetooth device. Inside each service can consist of many data attributes which is also known as the characteristic. Characteristic is simply the data that is associated with a standard defined label.
GATT protocol
- Service 1
- Characteristic 1A
- Characteristic 1B
- Characteristic 1C
- Service 2
- Characteristic 2A
- Service 3
- Characteristic 3A
- Characteristic 3B
Reference on GATT:
https://www.oreilly.com/library/view/getting-started-with/9781491900550/ch04.html
Topic:
– Handler (16 bit ID as and address for the attribute) <- is it address for the Service?
– Permission
– UUID identify the data attribute type in the data block.
Hands-on GATT protocol
One useful tool in learning the new GATT Protocol designed for Bluetooth Low Energy (BLE4.0 and above) is using the nRF Connect’s Bluetooth Low Energy apps from Nordic. You can install the nRF Connect software to have access to this app.
The following example uses nRF52840 Dongle as a sniffer.
When in the BLE apps, select the dongle device to start.
On the right side, click on the button <Start scan> to scan for nearby Bluetooth devices.
Bluetooth devices is constantly sending our advertisement broadcast so that other Bluetooth client can detect it and be able to connect to it.
In the following example, a BLE device is detected by the scan process. The device name ending with “…..-172AFE04”. Select the device and click on the <Connect> button.
Device Name: …..-172AFE04
Address: D4:ED:17:2A:FE:04
Address type: RandomStatic
Services: Battery Service
Appearance: 00-00
The column on the left represents the nRF52840-Dongle which is now a Central Bluetooth device. The right column is displaying the connected Bluetooth Peripheral (server) device name “…..-172AFE04”. The central is a Bluetooth client device which can connect to one or more peripheral devices. Each peripheral (server) can only accept one connection from the central (client) Bluetooth device. Once the peripheral is connected, they will stop their advertisement broadcast. Other Bluetooth devices will not be able to see and connect to them.
In the connected peripheral Bluetooth device with name ending with “…..-172AFE04”, along the connection line, there is a lock icon. Hover your mouse to check up the connection information. The configuration icon inside the device box have option that allows you to disconnect the Bluetooth connection of the central device to the peripheral device.
Inside the peripheral device, you will notice the following section of data. These are the GATT Services available from this server peripheral Bluetooth device.
- Generic Access
- Generic Attribute
- FFE0
- FFE5
- Legacy DFU
Generic Access
Type UUID: 0x1800
Characteristic | Value |
Device Name | …..-172AFE04 |
Appearance | 00 00 |
Peripheral Preferred Connection Parameters (optional) | 20 00 30 00 00 00 90 01 |
Peripheral Privacy Flag (optional) |
Generic Attribute
Type UUID: 0x1801
Characteristic | Value |
Service Changed (optional) |
GATT Service: FFE0
Type UUID: 0xFFE0
Characteristic is FFE4.
is a notify service.
Characteristic User Description
64 65 76 69 63 2D 3E 70 68 6F 6E 65
which represent a string
“devic->phone“
Client Characteristic Configuration
00 00
GATT Service: FFE5
Type UUID: 0xFFE5
Characteristic is FFE9.
is a writeWoResp write service.
Characteristic User Description
70 68 6F 6E 65 2D 3E 64 65 76 69 63 65
which represent a string
“phone->device“
Legacy DFU
GATT Service in detail (xml)
An overview of the service “generic-access” data structure.
Max data size of an attribute is 512 bytes
Reference:
https://www.bluetooth.com/specifications/gatt/services/