shmuelzon / esp32-ble2mqtt

A BLE to MQTT bridge running on an ESP32
MIT License
682 stars 108 forks source link

Support repeating UUIDs #182

Closed dakhnod closed 1 year ago

dakhnod commented 1 year ago

I am building a peripheral supporting the Automation IO service, which could lead to multiple characteristics within one service with identical UUIDs, which is perfectly fine with the BLE specification. That does seem to break your code, though. My suggestion would be to publish repeating UUID's with a suffux, e.g. "0x0001", "0x0001_1", "0x0001_2", etc.

Thanks for your work in any case, feel free to discuss the idea with me.

shmuelzon commented 1 year ago

I knew a requirement like this would come by sooner or later... :)

I'm generally OK with adding suffixes to repeating UUID to distinguish between the different ones but it would be quite a code change for all the functions that rely on the characteristic's UUID only. Now they'll need something else in addition like the index or whatever of the repeating characteristic. I understand that repeating characteristics will have different handle numbers but do you know if they have a single "characteristic client config" or one per repeating characteristic?

dakhnod commented 1 year ago

I can confirm that every characteristic has it's own subset of descriptors. They are not shared, even if the UUID repeats.

shmuelzon commented 1 year ago

OK, I'll see what I can do on a side branch and will probably need your help to test/debug as I don't have any devices with repeating UUIDs

dakhnod commented 1 year ago

If you want you can leave the implementation to me, since I already have experience with that. Also, I am somewhat familiar with your code already.

shmuelzon commented 1 year ago

That would probably get it done faster :) I'm, basically, imagining adding an index field to each characteristic and the functions that handle characteristics (converting it to a name and back, etc.). If you have any other thoughts or would like to share your work even before it's complete, I'd be happy to take a look.

dakhnod commented 1 year ago

Got it: https://github.com/shmuelzon/esp32-ble2mqtt/pull/183

shmuelzon commented 1 year ago

Closed by #183