Use arch_restart to restart ESP

This commit is contained in:
Edward Firmo
2024-04-30 10:57:17 +02:00
parent d4118e27e1
commit 1ef00adbfc
2 changed files with 9 additions and 31 deletions

View File

@@ -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

View File

@@ -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;
}