diff --git a/src/local/BLELocalAttribute.h b/src/local/BLELocalAttribute.h index f68f256f..2af948c3 100644 --- a/src/local/BLELocalAttribute.h +++ b/src/local/BLELocalAttribute.h @@ -22,6 +22,8 @@ #include "utility/BLEUuid.h" +#define BLE_ATTRIBUTE_TYPE_SIZE 2 + enum BLEAttributeType { BLETypeUnknown = 0x0000, diff --git a/src/utility/ATT.cpp b/src/utility/ATT.cpp index 28c8d743..a1028f76 100644 --- a/src/utility/ATT.cpp +++ b/src/utility/ATT.cpp @@ -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 || isDescriptor) ? attribute->uuidLength() : BLE_ATTRIBUTE_TYPE_SIZE; int infoType = (uuidLen == 2) ? 0x01 : 0x02; if (response[1] == 0) { @@ -699,7 +700,7 @@ void ATTClass::findInfoReq(uint16_t connectionHandle, uint16_t mtu, uint8_t dlen memcpy(&response[responseLength], &handle, sizeof(handle)); responseLength += sizeof(handle); - if (isValueHandle || attribute->type() == BLETypeDescriptor) { + if (isValueHandle || isDescriptor) { // add the UUID memcpy(&response[responseLength], attribute->uuidData(), uuidLen); responseLength += uuidLen;