Fix characteristic discovery with no descriptors.

Avoid discovery of descriptors if there are no handles remaining.
This commit is contained in:
Guo-Rong 2025-01-16 12:01:47 +10:30 committed by h2zero
parent 57fe9cb77f
commit 8158a16fbf

View file

@ -101,6 +101,12 @@ int NimBLERemoteCharacteristic::descriptorDiscCB(
bool NimBLERemoteCharacteristic::retrieveDescriptors(const NimBLEUUID* uuidFilter) const { bool NimBLERemoteCharacteristic::retrieveDescriptors(const NimBLEUUID* uuidFilter) const {
NIMBLE_LOGD(LOG_TAG, ">> retrieveDescriptors() for characteristic: %s", getUUID().toString().c_str()); NIMBLE_LOGD(LOG_TAG, ">> retrieveDescriptors() for characteristic: %s", getUUID().toString().c_str());
// If this is the last handle then there are no descriptors
if (getHandle() == getRemoteService()->getEndHandle()) {
NIMBLE_LOGD(LOG_TAG, "<< retrieveDescriptors(): found 0 descriptors.");
return true;
}
NimBLETaskData taskData(const_cast<NimBLERemoteCharacteristic*>(this)); NimBLETaskData taskData(const_cast<NimBLERemoteCharacteristic*>(this));
desc_filter_t filter = {uuidFilter, &taskData}; desc_filter_t filter = {uuidFilter, &taskData};