Find and connect to a BLE peripheral, identify its GATT characteristic, and verify that notifications arrive when the peripheral sends data.
1. Prepare the equipment
Use a Linux system with a Bluetooth controller, a running BlueZ service, and a peripheral that supports notifications. A heart-rate sensor or an ESP32 running a GATT server works. An ESP32 can send a periodic counter so you can check that updates keep arriving.
2. Scan and connect
Start bluetoothctl and enter these commands.
list
show
power on
scan le
Record the peripheral address and replace the placeholder below.
connect AA:BB:CC:DD:EE:FF
info AA:BB:CC:DD:EE:FF
scan off
Check for Connected: yes. If the characteristic requires pairing, run agent on and default-agent, then use pair AA:BB:CC:DD:EE:FF with the real address. Check info and reconnect if necessary.
3. Find the characteristic
A GATT service groups related functionality. A characteristic exposes a value that can support reading, writing, or notifications. List the attributes in bluetoothctl.
menu gatt
list-attributes
Find the full object path of the target characteristic. For a standard heart-rate sensor, look for Heart Rate Measurement, UUID 00002a37-0000-1000-8000-00805f9b34fb. For a custom ESP32 service, use the firmware’s UUID.
Select the characteristic and inspect its properties. Replace the example path with the full path returned by list-attributes.
select-attribute /org/bluez/hci0/dev_AA_BB_CC_DD_EE_FF/serviceXXXX/charYYYY
attribute-info
| Characteristic flag | Operation |
|---|---|
read |
Run read to retrieve one value |
notify or indicate |
Run notify on to subscribe to updates |
4. Receive a notification
notify on
Have the peripheral generate data. Start the ESP32 counter or take a heart-rate measurement. Keep bluetoothctl open and look for changes to Value. After receiving several updates, stop the subscription and disconnect.
notify off
back
disconnect AA:BB:CC:DD:EE:FF
quit
If no value changes appear, verify the selected characteristic’s flags and check that the peripheral is sending notifications.
5. Follow notifications into userspace
Before subscribing, start a monitor in another terminal.
sudo busctl monitor org.bluez
Turn notifications on again. Find the target characteristic path and the Value property in the org.freedesktop.DBus.Properties interface’s PropertiesChanged signal.
For a programming exercise, write a D-Bus client that invokes StartNotify() on org.bluez.GattCharacteristic1, handles the corresponding PropertiesChanged signals in its event loop, and decodes the bytes according to the peripheral’s protocol.
6. Integrate with Yocto
Include the controller’s kernel support, firmware, initialization settings, the BlueZ service, and bluetoothctl. On a freshly booted image, verify controller discovery, LE scanning, connection, characteristic discovery, and notifications. Reconnect after a disconnect and confirm that you can subscribe again.
Reference BlueZ bluetoothctl GATT submenu