mirror of
https://github.com/esphome/esphome.git
synced 2026-09-03 03:26:02 +00:00
[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:
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
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user