arduino-libraries / ArduinoBLE

ArduinoBLE library for Arduino
GNU Lesser General Public License v2.1
315 stars 205 forks source link

ATT Read by Type Request does not return Characteristic Descriptors #326

Open mringwal opened 1 year ago

mringwal commented 1 year ago

ATTClass::readByTypeReq has three code blocks:

The first two blocks are entered if attribute->type() == readByTypeReq->uuid. As attribute->type() is an enum, only UUIDs 2800 (BLETypeService), 2803 (BLETypeCharacteristic) work as expected. For any Characteristic Descriptor, e.g. CCCD 2902, the attribute->type() is 2900 (BLETypeDescriptor), so a query for 2902 is not handled although a CCCD is define.

As a consequence a "Write CCCD / Enable Notifications by BTstack" fails with Attribute not Found Error, as the Read By Type Req with UUID 2902 is not handled correctly / fails.

Maybe starting with a switch on attribute->type() and handling all three types might be a better way to implement this. I'm happy to explain in more detail if someone wants to fix this implementation.