Fix / Reverse order shutdown (#3585)

This commit is contained in:
RoboMagus 2022-06-21 01:26:34 +02:00 committed by GitHub
parent 0a4213182e
commit 34adbf0588
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View file

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

View file

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