Skip to main content

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 the bluetoothctl menu:
Parameters <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.
Example To connect to a client with <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 the menu gatt menu:
Example If the UUID of the service is FF01 and the handle is 30, run the following command:
Sample output

Add a characteristic

To add a characteristic to a service of the server, run the following command from the menu gatt menu:
Parameters <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:
Sample output

Add a descriptor

To add a descriptor to a characteristic in the server, run the following command from the menu gatt menu:
Parameters <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:
Sample output

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 the menu gatt menu:
Example Consider two primary services with the UUID FF01 and 1112, respectively. To add the service 1112 as an included service to the service FF01, run the following command:
Sample output

Register an application

To publish the services that are available or added to the server, run the following command from the menu gatt menu:
Example The UUID of the service is FF01. To publish the services that are available or added to the server, run the following command:
Sample output

Start an advertisement

To start a GATT advertisement, run the following command from the bluetoothctl menu:
Sample output

Disconnect a remote device

To disconnect a remote device, run the following command from the bluetoothctl menu:
Parameters <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: