From 1ef00adbfc7ea9627699c39bbf4651b94bcae921 Mon Sep 17 00:00:00 2001 From: Edward Firmo <94725493+edwardtfn@users.noreply.github.com> Date: Tue, 30 Apr 2024 10:57:17 +0200 Subject: [PATCH] Use arch_restart to restart ESP --- esphome/nspanel_esphome_addon_upload_tft.yaml | 36 ++++--------------- esphome/nspanel_esphome_core.yaml | 4 +-- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/esphome/nspanel_esphome_addon_upload_tft.yaml b/esphome/nspanel_esphome_addon_upload_tft.yaml index cd9e39c..8812367 100644 --- a/esphome/nspanel_esphome_addon_upload_tft.yaml +++ b/esphome/nspanel_esphome_addon_upload_tft.yaml @@ -241,49 +241,27 @@ script: ESP_LOGD(TAG, "Disable BLE"); #ifdef USE_BLUETOOTH_PROXY ESP_LOGD(TAG, " Bluetooth proxy: %s", ble_proxy->has_active() ? "Active" : "Passive"); - while (ble_proxy->has_active() and - ble_proxy->get_bluetooth_connections_limit() != ble_proxy->get_bluetooth_connections_free()) { - ESP_LOGD(TAG, " BT proxy connections: %i of %i", - int(ble_proxy->get_bluetooth_connections_limit() - ble_proxy->get_bluetooth_connections_free()), - int(ble_proxy->get_bluetooth_connections_limit())); - if (ble_proxy->has_active()) { - ESP_LOGD(TAG, " BT proxy set passive mode..."); - ble_proxy->set_active(false); - } - #ifdef ARDUINO + if (ble_proxy->has_active()) { + ESP_LOGD(TAG, " BT proxy set passive mode..."); + ble_proxy->set_active(false); delay(1000); - #elif defined(USE_ESP_IDF) - vTaskDelay(pdMS_TO_TICKS(1000)); - #endif App.feed_wdt(); } #endif // USE_BLUETOOTH_PROXY ESP_LOGD(TAG, " Stopping BLE Tracker scan..."); ble_tracker->stop_scan(); - #ifdef ARDUINO delay(1000); - #elif defined(USE_ESP_IDF) - vTaskDelay(pdMS_TO_TICKS(1000)); - #endif App.feed_wdt(); ESP_LOGD(TAG, " Disabling BLE Tracker scan..."); ble_tracker->set_scan_active(false); - #ifdef ARDUINO delay(1000); - #elif defined(USE_ESP_IDF) - vTaskDelay(pdMS_TO_TICKS(1000)); - #endif App.feed_wdt(); if (ble_tracker->get_parent() != nullptr) { ESP_LOGD(TAG, " Disabling BLE..."); ble_tracker->get_parent()->disable(); + delay(1000); + App.feed_wdt(); } - #ifdef ARDUINO - delay(1000); - #elif defined(USE_ESP_IDF) - vTaskDelay(pdMS_TO_TICKS(1000)); - #endif - App.feed_wdt(); ble_tracker->dump_config(); #endif // USE_ESP32_BLE_CLIENT @@ -370,7 +348,7 @@ script: - switch.turn_off: screen_power - delay: 2s # Restart ESPHome - - lambda: App.safe_reboot(); + - lambda: arch_restart(); ### This code should never run - delay: 2s @@ -445,7 +423,7 @@ script: - delay: 5s - lambda: |- ESP_LOGI("addon_upload_tft.script.upload_tft_attempt", "Restarting ESPHome"); - App.safe_reboot(); + arch_restart(); select: - id: tft_file_model diff --git a/esphome/nspanel_esphome_core.yaml b/esphome/nspanel_esphome_core.yaml index d593ede..bcc7357 100644 --- a/esphome/nspanel_esphome_core.yaml +++ b/esphome/nspanel_esphome_core.yaml @@ -984,7 +984,7 @@ display: switch (component_id) { case 4: // Reboot button if (!touch_event) { // Release - App.safe_reboot(); + arch_restart(); } break; } @@ -993,7 +993,7 @@ display: switch (component_id) { case 9: // Reboot button if (!touch_event) { // Release - App.safe_reboot(); + arch_restart(); } break; }