Close

Deciphering BLE Characteristics

A project log for Pi Chart

A wireless nautical chart plotter based on a Raspberry Pi and a sunlight readable screen.

erland-lewinErland Lewin 03/21/2016 at 22:361 Comment

I'm trying to decipher how the output from gatttool corresponds to the information in my Location and Navigation service.

The Location and Navigation Service has assigned number 0x1819.

The Location and Speed Characteristic has assigned number 0x2A67.

When I look at characteristic with handle 0x0010, gatttool says:

[F4:8C:27:CA:16:7E][LE]> char-desc 0x0010 0x0010

handle: 0x0010, uuid: 00002a67-0000-1000-8000-00805f9b34fb

However, trying to read the characteristic fails:

[F4:8C:27:CA:16:7E][LE]> char-read-hnd 0x0010

Error: Characteristic value/descriptor read failed: Attribute can't be read

However, I can read the characteristic before and after:

[F4:8C:27:CA:16:7E][LE]> char-read-hnd 0x0011

Characteristic value/descriptor: 00 00

[F4:8C:27:CA:16:7E][LE]> char-read-hnd 0x000f

Characteristic value/descriptor: 10 10 00 67 2a

But writing to 0x0011 got me notifications!

[F4:8C:27:CA:16:7E][LE]> char-write-req 0x0011 0100

Characteristic value was written successfully

Notification handle = 0x0010 value: 84 00 91 75 da f9 87 1c d6 23

Notification handle = 0x0010 value: 58 10 46 05 00 79 31 df 07 07 08 0c 2b 21

Notification handle = 0x0010 value: 84 00 91 75 da f9 87 1c d6 23

Notification handle = 0x0010 value: 58 10 46 05 00 f1 31 df 07 07 08 0c 2b 21

...

Victory!

Reverse engineering this data shows that the compass values are in bytes 15 and 16 (0-indexed, LSB first). There are two bytes between longitude and elevation that I don't know what they are (58 10).

Discussions

Brook Patten wrote 03/22/2016 at 12:56 point

I found gatttool unintuitive too,  It's really much easier to understand if you just use dbus directly to scan, invoke connect on the device, then read the properties etc, and it corresponds more directly with how you will do it when you go to do it in code.  I don't know if you have a gui installed but if you do just install d-feet and browse to org.bluez and poke around in there.

  Are you sure? yes | no