Skip to content

Commit c094cde

Browse files
committed
2022-11-02 - BLE Client Fix deadlock if connection lost while readValue. Releases BLE read semaphore on BLE target disconnect to avoid deadlock on read process
espressif/arduino-esp32#7319
1 parent 5896b2b commit c094cde

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/BLEAdvertisedDevice.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ std::string BLEAdvertisedDevice::toString() {
571571
res += ", serviceData: " + getServiceData(i);
572572
}
573573
}
574-
return res;
574+
return res;
575575
} // toString
576576

577577
uint8_t* BLEAdvertisedDevice::getPayload() {

src/BLERemoteCharacteristic.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,11 @@ void BLERemoteCharacteristic::gattClientEventHandler(esp_gattc_cb_event_t event,
247247
break;
248248

249249
case ESP_GATTC_DISCONNECT_EVT:
250+
// Cleanup semaphores to avoid deadlocks.
251+
m_semaphoreReadCharEvt.give(1);
250252
m_semaphoreWriteCharEvt.give(1);
251253
break;
252-
254+
253255
default:
254256
break;
255257
} // End switch

0 commit comments

Comments
 (0)