Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/utility/ATT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@ bool ATTClass::discoverDescriptors(uint16_t connectionHandle, BLERemoteDevice* d
BLERemoteCharacteristic* nextCharacteristic = (j == (characteristicCount - 1)) ? NULL : service->characteristic(j + 1);

reqStartHandle = characteristic->valueHandle() + 1;
reqEndHandle = nextCharacteristic ? nextCharacteristic->valueHandle() : serviceEndHandle;
reqEndHandle = nextCharacteristic ? nextCharacteristic->startHandle() - 1 : serviceEndHandle;

if (reqStartHandle > reqEndHandle) {
continue;
Expand All @@ -1749,8 +1749,14 @@ bool ATTClass::discoverDescriptors(uint16_t connectionHandle, BLERemoteDevice* d
}

if (responseBuffer[0] == ATT_OP_FIND_INFO_RESP) {
uint16_t lengthPerDescriptor = responseBuffer[1] * 4;
uint8_t uuidLen = 2;
uint8_t format = responseBuffer[1];

if (format != 0x01 && format != 0x02) {
return false;
}

uint16_t lengthPerDescriptor = (format == 0x01) ? 4 : 18;
uint8_t uuidLen = (format == 0x01) ? 2 : 16;

for (int i = 2; i < respLength; i += lengthPerDescriptor) {
struct __attribute__ ((packed)) RawDescriptor {
Expand Down
Loading