From 969f71338a8be0b6ef242008beb2e0c48cb2fb5c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 10 Sep 2026 10:04:49 -0500 Subject: [PATCH] [esp32_ble_tracker] Clear scan failure latches when the stack goes down A set-param or start failure latched by the old stack was otherwise handled against the next one as a spurious stop and restart. --- esphome/components/esp32_ble_client/ble_client_base.h | 2 +- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/esphome/components/esp32_ble_client/ble_client_base.h b/esphome/components/esp32_ble_client/ble_client_base.h index 3e7b010fbb..fbd405156a 100644 --- a/esphome/components/esp32_ble_client/ble_client_base.h +++ b/esphome/components/esp32_ble_client/ble_client_base.h @@ -140,7 +140,7 @@ class BLEClientBase : public espbt::ESPBTClient, public Component { uint8_t pending_notify_regs_{0}; bool auto_connect_{false}; bool paired_{false}; - // Always set by release_services(); the stack's GATT database must not be walked after it + // Set by release_services() on RAM-cache builds; the stack's GATT database must not be walked after it bool services_released_{false}; // 8 bytes used, no padding diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp index 59b65352b1..b4b793b4d0 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp @@ -234,6 +234,9 @@ void ESP32BLETracker::ble_before_disabled_event_handler() { if (this->scanner_state_ != ScannerState::IDLE) { this->cleanup_scan_state_(true); } + // A failure latched by the old stack must not be handled against the next. + this->scan_start_failed_ = ESP_BT_STATUS_SUCCESS; + this->scan_set_param_failed_ = ESP_BT_STATUS_SUCCESS; this->ble_was_disabled_ = true; }