Veethree D7 SDK
Loading...
Searching...
No Matches
Bluetooth Low Energy client

< Bluetooth

This is an example to connect to a BLE peripheral, query services and receive notifications.

Connect to a BLE peripheral

Before connecting to a BLE peripheral, open the D7 shell, enable Bluetooth and create a pairing request to the remote device using commands given in Bluetooth Basics.

Scan for the BLE peripheral on the D7:

$ btmgmt find -l

The scan returns a list of BLE peripherals and the response may look like:

hci0 dev_found: <MAC> type LE Public rssi -50 flags 0x0000
name <NAME>

Connect to the BLE peripheral:

$ gatttool -b <MAC> -I

if the scan reported a Random MAC address, instead of Public, pass -t random to the command. The flag -I starts an interactive session. Connect to the device:

[00:00:00:00:00:00][LE]> connect
Attempting to connect to 00:00:00:00:00:00
Connection successful

If connected to successfully, the session screen will show notifications when they occur from the remote device.

To list all primary services:

[00:00:00:00:00:00][LE]> primary

To list all characteristics:

[00:00:00:00:00:00][LE]> characteristics

To read a characteristic:

[00:00:00:00:00:00][LE]> char-read-hnd <CHAR VALUE HANDLE>

Note: Qt Bluetooth Low Energy Scanner provides GUI app to scan and browse BLE peripherals and this can be run on the D7 to view characteristics of scanned devices.