a second for reading CCCD in theory, but which is never executed
a third one for reading Characteristic Value
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.
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.