From bbeb0461c497fa1960ef681ecf0dc5d50a2bb49e Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Sat, 8 Jun 2019 16:47:04 +0200 Subject: [PATCH] Work around ESP32 BLE issue (#626) --- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp index 5ef814c2ba..043fdb409d 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp @@ -1,5 +1,6 @@ #include "esp32_ble_tracker.h" #include "esphome/core/log.h" +#include "esphome/core/application.h" #ifdef ARDUINO_ARCH_ESP32 @@ -162,6 +163,11 @@ void ESP32BLETracker::start_scan(bool first) { esp_ble_gap_set_scan_params(&this->scan_params_); esp_ble_gap_start_scanning(this->scan_interval_); + + this->set_timeout("scan", this->scan_interval_ * 2000, [] () { + ESP_LOGW(TAG, "ESP-IDF BLE scan never terminated, rebooting to restore BLE stack..."); + App.reboot(); + }); } void ESP32BLETracker::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) {