Skip to content

Commit 3074107

Browse files
committed
Fix discovery of descriptors
The 'nextCharacteristic' selection was wrong. Thus, when using nextCharacteristic for taking the end handle for the request, the end handle of the current characteristic was taken. This resulted in the following condition to be true: (reqStartHandle > reqEndHandle) For such reason, in many cases the descriptors were not retrieved. Specifically, all the characteristics of a service, except the last one, will result without descriptors. This will result in an error where trying to subscribe to a characteristic which has a descriptor before the CCCD one. (for instance the User Description Descriptor) In case the subscription is made on a characteristic having the CCCD as first descriptor there are no errors, because if no descriptors are found the write request, needed for the subscription, will be made to the char value handle + 1.
1 parent 95ce2e1 commit 3074107

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/utility/ATT.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ bool ATTClass::discoverDescriptors(uint16_t connectionHandle, BLERemoteDevice* d
15611561

15621562
for (int j = 0; j < characteristicCount; j++) {
15631563
BLERemoteCharacteristic* characteristic = service->characteristic(j);
1564-
BLERemoteCharacteristic* nextCharacteristic = (j == (characteristicCount - 1)) ? NULL : service->characteristic(j);
1564+
BLERemoteCharacteristic* nextCharacteristic = (j == (characteristicCount - 1)) ? NULL : service->characteristic(j + 1);
15651565

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

0 commit comments

Comments
 (0)