Skip to content

Commit

Permalink
2022-11-02 - BLE Client Fix deadlock if connection lost while readVal…
Browse files Browse the repository at this point in the history
…ue. Releases BLE read semaphore on BLE target disconnect to avoid deadlock on read process

espressif/arduino-esp32#7319
  • Loading branch information
DamianSuess committed Jan 8, 2023
1 parent 5896b2b commit c094cde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/BLEAdvertisedDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ std::string BLEAdvertisedDevice::toString() {
res += ", serviceData: " + getServiceData(i);
}
}
return res;
return res;
} // toString

uint8_t* BLEAdvertisedDevice::getPayload() {
Expand Down
4 changes: 3 additions & 1 deletion src/BLERemoteCharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,11 @@ void BLERemoteCharacteristic::gattClientEventHandler(esp_gattc_cb_event_t event,
break;

case ESP_GATTC_DISCONNECT_EVT:
// Cleanup semaphores to avoid deadlocks.
m_semaphoreReadCharEvt.give(1);
m_semaphoreWriteCharEvt.give(1);
break;

default:
break;
} // End switch
Expand Down

0 comments on commit c094cde

Please sign in to comment.