ukBaz / python-bluezero

A simple Python interface to Bluez
MIT License
387 stars 112 forks source link

Cannot advertise multiple primary services #355

Closed ArchTonIO closed 2 years ago

ArchTonIO commented 2 years ago

So, I'm working on a Raspberry Pi 4, I'm building a simple BLE device to get some led turned on and read some buttons value from an Android app. I started from the cpu_temperature.py example and modified it as follows: I have two services: one is the led service(write), the other is the button service(read), I setted both services to primary=True to advertise them. Now, if I have only one service setted to primary=True it works just fine, but if I set both at True i get the error: "Failed to register advertisement: org.bluez.Error.Failed: Failed to parse advertisement.". The script still runs but the peripheral is not advertised at all and I can't see it from the app. What causes the problem? How can I solve it?

ukBaz commented 2 years ago

This could be a duplicate of #354

I suspect the issue is that advertising two services with custom (128-bit) UUIDs is filling the space for the advert. You could have the LED and Button as two characteristics on one service.

ArchTonIO commented 2 years ago

Can I use the short UUID to solve this ?

ukBaz commented 2 years ago

The challenge with that is that the 16-bit UUIDs are reserved by the Bluetooth SIG

ArchTonIO commented 2 years ago

I found something online and yes... they are reserved, so I will simply use one service with more characteristics, thanks you for explaining me the issue