- Notifications
You must be signed in to change notification settings - Fork220
Fix find info resp when called on non-descriptor attributes#148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
src/utility/ATT.cpp Outdated
@@ -683,7 +683,8 @@ void ATTClass::findInfoReq(uint16_t connectionHandle, uint16_t mtu, uint8_t dlen | |||
BLELocalAttribute* attribute = GATT.attribute(i); | |||
uint16_t handle = (i + 1); | |||
bool isValueHandle = (attribute->type() == BLETypeCharacteristic) && (((BLELocalCharacteristic*)attribute)->valueHandle() == handle); | |||
int uuidLen = isValueHandle ? 2 : attribute->uuidLength(); | |||
bool isDescriptor = attribute->type() == BLETypeDescriptor; | |||
int uuidLen = isValueHandle ? 2 : (isDescriptor ? attribute->uuidLength() : BLE_ATTRIBUTE_TYPE_SIZE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I don't think this is correct. If it's a value handle, it should use the attribute's UUID length right?
If we align it with theif
logic on 703, value and descriptor handles memcpy the UUID data, so the uuidLen should reflect as such. Otherwise use the type size of 2
intuuidLen= (isValueHandle||isDescriptor) ?attribute->uuidLength() :BLE_ATTRIBUTE_TYPE_SIZE;// also can update the if on 703 to matchif (isValueHandle||isDescriptor) {// add the UUID}else {// add the type}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yes you're definitely right!
I'm going to update the PR
Before this fix, if the 'ATT information request' was called on an handle belonging to a non-descriptor attribute, then the response would contain the uuid of the actual attribute's type but with the format of the attribute uuid (0x01 for 16 bit length, 0x02 for 128 bit length).So, for instance, if the info request was performed on an handle belonging to a service with a uuid of 128 bit, then the response would have been malformed because the size of the attribute's type is 16 bit.
ThomasGerstenberg left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Before this fix, if the
ATT information request
was called on an handle belonging to a non-descriptor attribute, then the response would contain the uuid of the actual attribute's type but with the format of the attribute uuid (0x01 for 16 bit length, 0x02 for 128 bit length).So, for instance, if the info request was performed on an handle belonging to a service with a uuid of 128 bit, then the response would have been malformed because the size of the attribute's type is 16 bit.
From issue discovered by@ThomasGerstenberg
#147