Reputation: 103
I am able to connect to and read vendor-specific characteristic values from a BLE device using gatttool on a Raspberry Pi 4B terminal command line, but I have a couple of issues.
A dialog appears, "Connection successful", with an OK button. I do not think this will be acceptable in production code.
I am unable to "unpair" or "remove" the device using gatttool.
I am able to connect to a BLE device using bluetoothctl on a Raspberry Pi 4B terminal command line (interactive), and can read generic characteristic values, but I cannot read vendor-specific characteristic values. I can, however, remove (unpair) the device using bluetoothctl.
Using gatttool: gatttool -t random -b E0:0D:10:F1:D5:FC --char-read -a 0x0014 returns the value of the characteristic.
Using bluetoothctl:
power on
scan on
pair E0:0D:10:F1:D5:FC
connect E0:0D:10:F1:D5:FC
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0001 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0027
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0001/char0002 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0029
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0001/char0002/desc0004 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char002b
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0001/char0005 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char002d
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0001/char0007 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char002f
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0031
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0011 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0033
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0013 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0035
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0015 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0037
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0017 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0039
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0019 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char003b
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char001b /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char003d
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char001d /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service003f
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char001f /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service003f/char0040
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0021 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service003f/char0042
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0023 /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service003f/char0042/desc0044
/org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0010/char0025
[rSY?1T5WpDnQg==r#nRoZXaLm1Dc5_]# select-attribute /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service10/char0013
[rSY?1T5WpDnQg==r#nRoZXaLm1Dc5_]#
I thought perhaps the prompt would change to the selected attribute.
[rSY?1T5WpDnQg==r#nRoZXaLm1Dc5_]# read No attribute selected [rSY?1T5WpDnQg==r#nRoZXaLm1Dc5_]#
I thought maybe the read command would return the value of the characteristic, but that did not happen.
However, when I select a generic attribute,
[rSY?1T5WpDnQg==r#nRoZXaLm1Dc5_:/service0001/char0005]# select-attribute /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0001/char0007 [rSY?1T5WpDnQg==r#nRoZXaLm1Dc5_:/service0001/char0007]# read Attempting to read /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0001/char0007 [CHG] Attribute /org/bluez/hci0/dev_E0_0D_10_F1_D5_FC/service0001/char0007 Value: fd df 10 72 3e f3 f0 84 b5 df 9e f1 3a a8 85 44 ...r>.......:..D fd df 10 72 3e f3 f0 84 b5 df 9e f1 3a a8 85 44 ...r>.......:..D
the prompt changes and the characteristic value is returned.
I was hoping to find a good GATT tutorial on the internet. So far, all I seem to be able to find is the man pages (https://www.mankier.com/1/bluetoothctl).
Does anyone have suggestions on what BLE GATT tool to use and how to use it or references to online documentation?
Upvotes: 0
Views: 564
Reputation: 1648
Before using a technology, you should try to understand it. Each BLE characteristic is described by different attributes, which might define a Characteristic as write-only, for example. However, you might want to start with the material provided by the Bluetooth SIG, for example: Intro to Bluetooth Generic Attribute Profile (GATT)
Upvotes: 0