ukBaz / python-bluezero

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

Setting Manufacturer data in Advertiser only works if data is less than 3 bytes long #408

Closed maticsr closed 2 months ago

maticsr commented 2 months ago

Hello,

I have a case where I need to set the manufacturer data to a 16 bytes constant using the peripheral library.

After creating the peripheral class, I call the following function:

bridge.advert.manufacturer_data(77, [0x00, 0x01, 0x02, 0x03]) It basically works if the data array is 2 bytes or less. If the array is longer, the following error message is received: Failed to register advertisement: org.bluez.Error.Failed: Failed to parse advertisement.

Is this a bug or am I doing something wrong?

ukBaz commented 2 months ago

BLE advertisements have very limited space so my speculation is that you are running out of space. You can get more debug information by running the following in separate terminals:

maticsr commented 2 months ago

Thank you for a very prompt response. Running out of space was my first thought as well, I just didn't know how to approach it. Thanks for the debugging hint. Will test tonight.

ukBaz commented 2 months ago

You may also find https://github.com/ukBaz/python-bluezero/issues/355 a useful reference.

maticsr commented 2 months ago

I can confirm it was a running out of space issue. Removed some other data from advertising packet resolved it.