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.
Example
To connect to a server device with <bt_address> 6D:38:AF:C6:B5:62, run the following command:
Sample output
Start Bluetooth Low Energy GATT scan
To start a Bluetooth Low Energy GATT scan, run the following command from the bluetoothctl menu:
To get the scan results, the remote device must advertise using any Bluetooth Low Energy application.
Sample output
Stop Bluetooth Low Energy GATT scan
To stop a Bluetooth Low Energy GATT scan, run the following command from the bluetoothctl menu:
Sample output
Get the list of attributes
To get the list of attributes of the remote device, run the following command from the menu gatt menu:
Parameters
<bt_address> is the address of the remote device.
Example
To list the attributes of the remote device with the address 6D:38:AF:C6:B5:62, run the following command:
Sample output
To get the information of an attribute, run the following command from the menu gatt menu:
Parameters
<attribute/UUID> is the UUID or the attribute path.
Example
To get the information of an attribute with the UUID 00002b29-0000-1000-8000-00805f9b34fb, run the following command:
Sample output
Select an attribute
To select the attribute using the UUID or path, run the following command from the menu gatt menu:
Parameters
<attribute/UUID> is the UUID or path of the attribute.
Example
-
To select an attribute using the UUID
00006677-0000-1000-8000-00805f9b34fb, run the following command:
Sample output
-
To select an attribute using the attribute path
/org/bluez/hci0/dev_6C_5F_B9_ED_5B_48/service0001/char0002, run the following command:
Sample output
Read a characteristic value
To read a characteristic value, do the following from the menu gatt menu:
-
Select the intended attribute.
-
Read the selected attribute by running the following command:
Sample output
Write a characteristic value
To write a characteristic value, do the following from the menu gatt menu:
-
Select the intended attribute.
-
Write a value to the selected attribute by running the following command:
Parameters
<value> is the value you intend to write.
Example
To write the attribute value as 0x11, run the following command:
Sample output
Read a descriptor value
To read a descriptor value, do the following from the menu gatt menu:
-
Select the intended attribute.
-
Read the selected attribute by running the following command:
Sample output
Write a descriptor value
To write a descriptor value, do the following from the menu gatt menu:
-
Select the intended attribute.
-
Write a value to the selected attribute by running the following command:
Parameters
<value> is the value you intend to write.
Example
To write the attribute value as 0x11, run the following command:
Sample output
Read an encrypted characteristic value
To read an encrypted characteristic value, do the following from the menu gatt menu:
-
Select the intended attribute.
-
Read the selected attribute by running the following command:
-
Enter
yes when prompted to confirm the reading.
Sample output
Write an encrypted characteristic value
To write an encrypted characteristic value, do the following from the menu gatt menu:
-
Select the intended attribute.
-
Write a value to the selected attribute by running the following command:
Parameters
<value> is the value you intend to write.
Example
To write the attribute value as 0x11, run the following command:
-
Enter
yes when prompted to confirm writing.
Turn on notifications for an attribute
To turn on notifications for an attribute, do the following from the menu gatt menu:
-
Select the intended attribute.
-
Enable notifications for the attribute by running the following command:
You get notifications of any changes to the attribute.
Sample output
Turn off notifications for an attribute
To turn off notifications for an attribute, do the following from the menu gatt menu:
-
Select the intended attribute.
-
Disable notifications for the attribute by running the following command:
Sample output