Prerequisites
Before you begin, set up the device as described in Set up the device for Bluetooth Low Energy GATT functions.Connect to a remote device
To connect to a remote device, run the following command from thebluetoothctl menu:
<bt_address> is the Bluetooth address of the remote device.
To get the Bluetooth address of the remote device, run a Bluetooth Low Energy GATT scan.
<bt_address> 6D:38:AF:C6:B5:62, run the following command:
Add a primary service
To add a primary service to the GATT server, run the following command from themenu gatt menu:
FF01 and the handle is 30, run the following command:
Add a characteristic
To add a characteristic to a service of the server, run the following command from themenu gatt menu:
<Flags> are the flag values of the characteristic. For values, see Flag values.
Example
The UUID of a service is FF02, the flags are read,write,notify, and the handle is 31. To add a characteristic, run the following command:
Add a descriptor
To add a descriptor to a characteristic in the server, run the following command from themenu gatt menu:
<Flags> are the flag values of the descriptor. For values, see Flag values.
Example
The UUID of a service is FF03, the flags are read,write, and the handle is 33. To add a descriptor, run the following command:
Add an included service
Before you begin, add the intended services as primary services. To add an included service to another service, run the following command from themenu gatt menu:
FF01 and 1112, respectively. To add the service 1112 as an included service to the service FF01, run the following command:
Register an application
To publish the services that are available or added to the server, run the following command from themenu gatt menu:
FF01. To publish the services that are available or added to the server, run the following command:
Start an advertisement
To start a GATT advertisement, run the following command from thebluetoothctl menu:
Disconnect a remote device
To disconnect a remote device, run the following command from thebluetoothctl menu:
<bt_address> is the Bluetooth address of the remote device.
Example
To disconnect a client with <bt_address> 6D:38:AF:C6:B5:62, run the following command:
Flag values
The value of<Flags> can be:
broadcast | authenticated-signed-writes | encrypt-authenticated-read | encrypt-authenticated-notify |
|---|---|---|---|
read | extended-properties | encrypt-authenticated-write | secure-notify |
write | reliable-write | secure-read | encrypt-indicate |
write-without-response | writable-auxiliaries | secure-write | encrypt-authenticated-indicate |
notify | encrypt-read | authorize | secure-indicate |
indicate | encrypt-write | encrypt-notify |

