1

(Updated)

I am trying to communicate with a BLE device using command-line or program.

I have paired with this device, using bluetoothctl v5.50:

[bluetooth]# paired-devices
Device XX:XX:XX:XX:XX:XX Mydevice

But when I try to read its characteristics with gatttool, I get the answer Characteristic value/descriptor operation failed: Attribute requires authentication before read/write.

sudo gatttool -b XX:XX:XX:XX:XX:XX -I -t random --sec-level=high
[XX:XX:XX:XX:XX:XX][LE]> connect
Attempting to connect to d2:a7:4c:76:f3:e0
Connection successful
[XX:XX:XX:XX:XX:XX][LE]> char-read-hnd 0x000e
Error: Characteristic value/descriptor read failed: Attribute requires authentication before read/write
[XX:XX:XX:XX:XX:XX][LE]> 

I also tried with with bleah and I get the error Error from Bluetooth stack (comerr).

With bluetoothctl, list-attributes does not return anything. And I am unable to read standard characteristic such as 00002a00-0000-1000-8000-00805f9b34fb (Device Name):

[MyDevice]# list-attributes
[MyDevice]# attribute-info 00002a00-0000-1000-8000-00805f9b34fb
Attribute 00002a00-0000-1000-8000-00805f9b34fb not available

Note that the characteristics are readable (I enumerated the device with bleah): 0x000e has READ property.

Can somebody suggest a solution to read such characteristics?

user1381
  • 506
  • 1
  • 5
  • 19
  • Looks like characteristic level authorization/authentication is required. Can you please try the following two things:- 1) Use your phone to connect and read the characteristic (e.g. using the nRF Connect app) and see what happens, and 2) Use bluetoothctl command to read the characteristic value. See this link for more info https://docs.ubuntu.com/core/en/stacks/bluetooth/bluez/docs/reference/gatt-services – Youssif Saeed Jun 21 '19 at 07:14
  • I read the characteristics no problem on the phone *if I am paired*. With bluetoothctl, I do not receive the list of services and characteristics (I am paired and connected). If I issue `list-attributes MACaddress`, it does not respond at all. – user1381 Jun 21 '19 at 08:16
  • That is strange. Which version of BlueZ/bluetoothctl are you using? – Youssif Saeed Jun 21 '19 at 09:16
  • bluetoothctl v5.37 – user1381 Jun 21 '19 at 12:29
  • OK try with the latest version of BlueZ and bluetoothctl (v5.50) by getting the package from here (http://www.bluez.org/) and then follow the steps in this link to install BlueZ (https://stackoverflow.com/questions/22358286/how-to-rebuild-bluez/22989549#22989549) – Youssif Saeed Jun 22 '19 at 07:13
  • I have installed v5.50. It is the same problem. I can connect and pair to the device, but list-attributes does not show any attribute. Though bleah or gatttool do. If I try `attribute-info 00001800-0000-1000-8000-00805f9b34fb`, it answers `Attribute 00001800-0000-1000-8000-00805f9b34fb not available`. I'll be updating the description. – user1381 Jun 25 '19 at 07:45

0 Answers0