mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 23:18:10 +01:00
Fix / Reverse order shutdown (#3585)
This commit is contained in:
parent
0a4213182e
commit
34adbf0588
2 changed files with 14 additions and 14 deletions
|
@ -125,19 +125,26 @@ void IRAM_ATTR HOT Application::feed_wdt() {
|
||||||
}
|
}
|
||||||
void Application::reboot() {
|
void Application::reboot() {
|
||||||
ESP_LOGI(TAG, "Forcing a reboot...");
|
ESP_LOGI(TAG, "Forcing a reboot...");
|
||||||
for (auto *comp : this->components_)
|
for (auto it = this->components_.rbegin(); it != this->components_.rend(); ++it) {
|
||||||
comp->on_shutdown();
|
(*it)->on_shutdown();
|
||||||
|
}
|
||||||
arch_restart();
|
arch_restart();
|
||||||
}
|
}
|
||||||
void Application::safe_reboot() {
|
void Application::safe_reboot() {
|
||||||
ESP_LOGI(TAG, "Rebooting safely...");
|
ESP_LOGI(TAG, "Rebooting safely...");
|
||||||
for (auto *comp : this->components_)
|
run_safe_shutdown_hooks();
|
||||||
comp->on_safe_shutdown();
|
|
||||||
for (auto *comp : this->components_)
|
|
||||||
comp->on_shutdown();
|
|
||||||
arch_restart();
|
arch_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::run_safe_shutdown_hooks() {
|
||||||
|
for (auto it = this->components_.rbegin(); it != this->components_.rend(); ++it) {
|
||||||
|
(*it)->on_safe_shutdown();
|
||||||
|
}
|
||||||
|
for (auto it = this->components_.rbegin(); it != this->components_.rend(); ++it) {
|
||||||
|
(*it)->on_shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Application::calculate_looping_components_() {
|
void Application::calculate_looping_components_() {
|
||||||
for (auto *obj : this->components_) {
|
for (auto *obj : this->components_) {
|
||||||
if (obj->has_overridden_loop())
|
if (obj->has_overridden_loop())
|
||||||
|
|
|
@ -161,14 +161,7 @@ class Application {
|
||||||
|
|
||||||
void safe_reboot();
|
void safe_reboot();
|
||||||
|
|
||||||
void run_safe_shutdown_hooks() {
|
void run_safe_shutdown_hooks();
|
||||||
for (auto *comp : this->components_) {
|
|
||||||
comp->on_safe_shutdown();
|
|
||||||
}
|
|
||||||
for (auto *comp : this->components_) {
|
|
||||||
comp->on_shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t get_app_state() const { return this->app_state_; }
|
uint32_t get_app_state() const { return this->app_state_; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue