BLE, gatttool & pexpect: how to get status of BLE device

126 Views Asked by At

I am new to BLE, and I try to interact with a recently bought Breurer BF720 body scale. Everything is extremely cryptic to me, but i had some success so far. Resources on the internet i have found and consulted are

Furthermore i managed to start a connection via

usr@raspi:~/myfiles/bt-scale $ gatttool -I -b <mac>
[<mac>][LE]> connect
Attempting to connect to <mac>
Connection successful

and extract primary & characteristics:

[<mac>][LE]> primary
attr handle: 0x0001, end grp handle: 0x000b uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x000c, end grp handle: 0x000f uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x0010, end grp handle: 0x0022 uuid: 0000180a-0000-1000-8000-00805f9b34fb
attr handle: 0x0023, end grp handle: 0x0025 uuid: 0000180f-0000-1000-8000-00805f9b34fb
attr handle: 0x0026, end grp handle: 0x0029 uuid: 00001805-0000-1000-8000-00805f9b34fb
attr handle: 0x002a, end grp handle: 0x0038 uuid: 0000181c-0000-1000-8000-00805f9b34fb
attr handle: 0x0039, end grp handle: 0x003e uuid: 0000181d-0000-1000-8000-00805f9b34fb
attr handle: 0x003f, end grp handle: 0x0044 uuid: 0000181b-0000-1000-8000-00805f9b34fb
attr handle: 0x0045, end grp handle: 0x005c uuid: 0000ffff-0000-1000-8000-00805f9b34fb
attr handle: 0x005d, end grp handle: 0x0062 uuid: 0000faa0-0000-1000-8000-00805f9b34fb

[<mac>][LE]> characteristics
handle: 0x0002, char properties: 0x02, char value handle: 0x0003, uuid: 00002a00-0000-1000-8000-00805f9b34fb
handle: 0x0004, char properties: 0x02, char value handle: 0x0005, uuid: 00002a01-0000-1000-8000-00805f9b34fb
handle: 0x0006, char properties: 0x0a, char value handle: 0x0007, uuid: 00002a02-0000-1000-8000-00805f9b34fb
handle: 0x0008, char properties: 0x08, char value handle: 0x0009, uuid: 00002a03-0000-1000-8000-00805f9b34fb
handle: 0x000a, char properties: 0x02, char value handle: 0x000b, uuid: 00002a04-0000-1000-8000-00805f9b34fb
handle: 0x000d, char properties: 0x20, char value handle: 0x000e, uuid: 00002a05-0000-1000-8000-00805f9b34fb
handle: 0x0011, char properties: 0x02, char value handle: 0x0012, uuid: 00002a23-0000-1000-8000-00805f9b34fb
handle: 0x0013, char properties: 0x02, char value handle: 0x0014, uuid: 00002a24-0000-1000-8000-00805f9b34fb
handle: 0x0015, char properties: 0x02, char value handle: 0x0016, uuid: 00002a25-0000-1000-8000-00805f9b34fb
handle: 0x0017, char properties: 0x02, char value handle: 0x0018, uuid: 00002a26-0000-1000-8000-00805f9b34fb
handle: 0x0019, char properties: 0x02, char value handle: 0x001a, uuid: 00002a27-0000-1000-8000-00805f9b34fb
handle: 0x001b, char properties: 0x02, char value handle: 0x001c, uuid: 00002a28-0000-1000-8000-00805f9b34fb
handle: 0x001d, char properties: 0x02, char value handle: 0x001e, uuid: 00002a29-0000-1000-8000-00805f9b34fb
handle: 0x001f, char properties: 0x02, char value handle: 0x0020, uuid: 00002a2a-0000-1000-8000-00805f9b34fb
handle: 0x0021, char properties: 0x02, char value handle: 0x0022, uuid: 00002a50-0000-1000-8000-00805f9b34fb
handle: 0x0024, char properties: 0x02, char value handle: 0x0025, uuid: 00002a19-0000-1000-8000-00805f9b34fb
handle: 0x0027, char properties: 0x1a, char value handle: 0x0028, uuid: 00002a2b-0000-1000-8000-00805f9b34fb
handle: 0x002b, char properties: 0x0a, char value handle: 0x002c, uuid: 00002a85-0000-1000-8000-00805f9b34fb
handle: 0x002d, char properties: 0x0a, char value handle: 0x002e, uuid: 00002a8c-0000-1000-8000-00805f9b34fb
handle: 0x002f, char properties: 0x0a, char value handle: 0x0030, uuid: 00002a8e-0000-1000-8000-00805f9b34fb
handle: 0x0031, char properties: 0x01, char value handle: 0x0032, uuid: 00002a99-0000-1000-8000-00805f9b34fb
handle: 0x0034, char properties: 0x02, char value handle: 0x0035, uuid: 00002a9a-0000-1000-8000-00805f9b34fb
handle: 0x0036, char properties: 0x28, char value handle: 0x0037, uuid: 00002a9f-0000-1000-8000-00805f9b34fb
handle: 0x003a, char properties: 0x02, char value handle: 0x003b, uuid: 00002a9e-0000-1000-8000-00805f9b34fb
handle: 0x003c, char properties: 0x20, char value handle: 0x003d, uuid: 00002a9d-0000-1000-8000-00805f9b34fb
handle: 0x0040, char properties: 0x02, char value handle: 0x0041, uuid: 00002a9b-0000-1000-8000-00805f9b34fb
handle: 0x0042, char properties: 0x20, char value handle: 0x0043, uuid: 00002a9c-0000-1000-8000-00805f9b34fb
handle: 0x0046, char properties: 0x0a, char value handle: 0x0047, uuid: 00000000-0000-1000-8000-00805f9b34fb
handle: 0x0049, char properties: 0x18, char value handle: 0x004a, uuid: 00000001-0000-1000-8000-00805f9b34fb
handle: 0x004d, char properties: 0x0a, char value handle: 0x004e, uuid: 00000002-0000-1000-8000-00805f9b34fb
handle: 0x0050, char properties: 0x0a, char value handle: 0x0051, uuid: 00000004-0000-1000-8000-00805f9b34fb
handle: 0x0053, char properties: 0x02, char value handle: 0x0054, uuid: 0000000b-0000-1000-8000-00805f9b34fb
handle: 0x0056, char properties: 0x08, char value handle: 0x0057, uuid: 00000005-0000-1000-8000-00805f9b34fb
handle: 0x0059, char properties: 0x18, char value handle: 0x005a, uuid: 00000006-0000-1000-8000-00805f9b34fb
handle: 0x005e, char properties: 0x04, char value handle: 0x005f, uuid: 0000faa2-0000-1000-8000-00805f9b34fb
handle: 0x0060, char properties: 0x12, char value handle: 0x0061, uuid: 0000faa1-0000-1000-8000-00805f9b34fb

However I just do not understand, how to use the tools available to me? what piece am I missing?

Question 1: How can find out what the individual primaries and characteristics mean? I cant find any vendor manual or such.

Question 2: How can I read status notifications (within gatttool)? From the bt-scale scale.py i can reproduce line 482 ff

# get scale status
child.sendline("char-write-req 0x002e E74F0000000000000000")

within gatttool

[<mac>][LE]> char-write-char-write-req 0x002e E74F0000000000000000
Characteristic value was written successfully

but in gatttool there is no other response than Characteristic value was written successfully. also "debugging" in python with

>>> child = pexpect.spawn('gatttool -I -b ' + <mac>)
>>> child.sendline('connect')
8
>>> child.sendline(cmd)
43
>>> child.readline()
'\x1b[?2004h[<mac>][LE]> connect\r\n'
>>> child.readline()
'\x1b[?2004l\rAttempting to connect <mac>:AC\r\n'
>>> child.readline()
'\x1b[?2004h[<mac>][LE]> \r\x1b[KConnection successful\r\n'
>>> child.readline()
'\x1b[0;94m[<mac>]\x1b[0m[LE]> char-write-req 0x002e E74F0000000000000000\r\n'
>>> child.readline()
'\x1b[?2004l\r\x1b[?2004h\x1b[0;94m[<mac>]\x1b[0m[LE]> \r\x1b[KCharacteristic value was written successfully\r\n'

results in nothing remotely similar to a status. Thanks for any help/ resource/ intuition on what i am doing wrong here.

0

There are 0 best solutions below