mirror of
https://github.com/esphome/esphome.git
synced 2024-11-26 00:48:19 +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() {
|
||||
ESP_LOGI(TAG, "Forcing a reboot...");
|
||||
for (auto *comp : this->components_)
|
||||
comp->on_shutdown();
|
||||
for (auto it = this->components_.rbegin(); it != this->components_.rend(); ++it) {
|
||||
(*it)->on_shutdown();
|
||||
}
|
||||
arch_restart();
|
||||
}
|
||||
void Application::safe_reboot() {
|
||||
ESP_LOGI(TAG, "Rebooting safely...");
|
||||
for (auto *comp : this->components_)
|
||||
comp->on_safe_shutdown();
|
||||
for (auto *comp : this->components_)
|
||||
comp->on_shutdown();
|
||||
run_safe_shutdown_hooks();
|
||||
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_() {
|
||||
for (auto *obj : this->components_) {
|
||||
if (obj->has_overridden_loop())
|
||||
|
|
|
@ -161,14 +161,7 @@ class Application {
|
|||
|
||||
void safe_reboot();
|
||||
|
||||
void run_safe_shutdown_hooks() {
|
||||
for (auto *comp : this->components_) {
|
||||
comp->on_safe_shutdown();
|
||||
}
|
||||
for (auto *comp : this->components_) {
|
||||
comp->on_shutdown();
|
||||
}
|
||||
}
|
||||
void run_safe_shutdown_hooks();
|
||||
|
||||
uint32_t get_app_state() const { return this->app_state_; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue