[safe_mode] Uncover silent error in safe-mode (#18749)

Co-authored-by: Oliver Kleinecke <kleinecke.oliver@googlemail.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
Oliver Kleinecke
2026-09-01 09:12:49 -04:00
committed by GitHub
co-authored by Oliver Kleinecke pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Jonathan Swoboda
parent fe3788ff47
commit 68ffd5a773
+11 -4
View File
@@ -255,12 +255,17 @@ bool SafeModeComponent::should_enter_safe_mode(uint8_t num_attempts, uint32_t en
}
void SafeModeComponent::write_rtc_(uint32_t val) {
this->rtc_.save(&val);
global_preferences->sync();
if (!this->rtc_.save(&val)) {
ESP_LOGE(TAG, "Failed to set rtc value (%" PRIu32 ")", val);
return;
}
if (!global_preferences->sync()) {
ESP_LOGE(TAG, "Failed to persist rtc value (%" PRIu32 ")", val);
}
}
uint32_t SafeModeComponent::read_rtc_() {
uint32_t val;
uint32_t val = 0;
if (!this->rtc_.load(&val))
return 0;
return val;
@@ -272,7 +277,9 @@ void SafeModeComponent::clean_rtc() {
// before sync, the boot wasn't really successful anyway and the counter should
// remain incremented.
uint32_t val = 0;
this->rtc_.save(&val);
if (!this->rtc_.save(&val)) {
ESP_LOGE(TAG, "Failed to clear boot loop counter");
}
}
void SafeModeComponent::on_safe_shutdown() {