Adam-Langley / pybleno

A direct port of the Bleno bluetooth LE peripheral role library to Python2/3
MIT License
68 stars 34 forks source link

Vendor-specific (long) Service UUIDs must be written in lowercase #45

Open mh- opened 4 years ago

mh- commented 4 years ago

Today I discovered - after quite some debugging - that vendor-specific (long) Service UUIDs must be written in lowercase. A BLE central will not find the service, if the declaration of a long UUID contains an uppercase hex digit. I suggest that this should be changed to accept any valid hex string.

To reproduce in a simple example, modify main.py in the "echo" example, line 26 to

                'uuid': '12345678-1234-1234-1234-1234567890AB',

(it should be a vendor-specific (long) uuid, and note the capital letters AB)

Then use gatttool -b <bdaddr> -I on another linux machine and enter the commands below:

$ gatttool -b B8:27:EB:5E:36:C7 -I

[B8:27:EB:5E:36:C7][LE]> connect
Attempting to connect to B8:27:EB:5E:36:C7
Connection successful

[B8:27:EB:5E:36:C7][LE]> primary 
attr handle: 0x0001, end grp handle: 0x0005 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x0006, end grp handle: 0x0009 uuid: 00001801-0000-1000-8000-00805f9b34fb
attr handle: 0x000a, end grp handle: 0x000d uuid: 12345678-1234-1234-1234-1234567890ab

[B8:27:EB:5E:36:C7][LE]> primary 12345678-1234-1234-1234-1234567890ab
Error: No service UUID found

The result should of course be

Starting handle: 0x000a Ending handle: 0x000d

I tried multiple versions of pybleno, raspbian, bluez and it happened on all of them, before I found the reason "upper case hex digit". The last versions were: pybleno 0.11, raspbian buster, bluez 5.52