mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2025-01-15 22:12:08 +01:00
Fix crash when retrieving descriptors.
If more than one descriptor is found the task would be released beofore the process completed causing a race condition.
This commit is contained in:
parent
fa468d360a
commit
0b543d9f62
2 changed files with 6 additions and 8 deletions
|
@ -72,14 +72,8 @@ int NimBLERemoteCharacteristic::descriptorDiscCB(
|
|||
const auto pChr = (NimBLERemoteCharacteristic*)pTaskData->m_pInstance;
|
||||
const NimBLEUUID* uuidFilter = filter->uuid;
|
||||
|
||||
if (error->status == BLE_HS_ENOTCONN) {
|
||||
NIMBLE_LOGE(LOG_TAG, "<< Descriptor Discovery; Not connected");
|
||||
NimBLEUtils::taskRelease(*pTaskData, error->status);
|
||||
return error->status;
|
||||
}
|
||||
|
||||
if (pChr->getHandle() != chr_val_handle) {
|
||||
rc = BLE_HS_EDONE; // descriptor not for this characteristic
|
||||
return 0; // Descriptor not for this characteristic
|
||||
}
|
||||
|
||||
if (rc == 0) {
|
||||
|
@ -92,6 +86,7 @@ int NimBLERemoteCharacteristic::descriptorDiscCB(
|
|||
}
|
||||
|
||||
pChr->m_vDescriptors.push_back(new NimBLERemoteDescriptor(pChr, dsc));
|
||||
return 0;
|
||||
}
|
||||
|
||||
NimBLEUtils::taskRelease(*pTaskData, rc);
|
||||
|
|
|
@ -147,7 +147,10 @@ int NimBLERemoteService::characteristicDiscCB(uint16_t conn_handle,
|
|||
const ble_gatt_error* error,
|
||||
const ble_gatt_chr* chr,
|
||||
void* arg) {
|
||||
NIMBLE_LOGD(LOG_TAG, "Characteristic Discovery >>");
|
||||
NIMBLE_LOGD(LOG_TAG,
|
||||
"Characteristic Discovery >> status: %d handle: %d",
|
||||
error->status,
|
||||
(error->status == 0) ? chr->def_handle : -1);
|
||||
auto pTaskData = (NimBLETaskData*)arg;
|
||||
const auto pSvc = (NimBLERemoteService*)pTaskData->m_pInstance;
|
||||
|
||||
|
|
Loading…
Reference in a new issue