From a12c6b5f355f6f3ca47ffd47cd4eb1fed8840f34 Mon Sep 17 00:00:00 2001 From: dentra Date: Sun, 7 Aug 2022 22:57:43 +0300 Subject: [PATCH] Fix panic abort when BLEClient reconnects (#3594) --- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp index 9722104e25..82945dc771 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp @@ -100,7 +100,12 @@ void ESP32BLETracker::loop() { found = true; if (client->state() == ClientState::DISCOVERED) { esp_ble_gap_stop_scanning(); - if (xSemaphoreTake(this->scan_end_lock_, 10L / portTICK_PERIOD_MS)) { +#ifdef USE_ARDUINO + constexpr TickType_t block_time = 10L / portTICK_PERIOD_MS; +#else + constexpr TickType_t block_time = 0L; // PR #3594 +#endif + if (xSemaphoreTake(this->scan_end_lock_, block_time)) { xSemaphoreGive(this->scan_end_lock_); } }