fix(weather): recover from permanent lockup after max retries (closes #9)

After 3 consecutive API failures, weatherRetry.reset() was never called
and weatherState stayed WEATHER_FAILED permanently. Both the retry path
and periodic refresh path require WEATHER_IDLE, so no new requests were
ever made — even after the API recovered.

Fix: when maxRetriesReached(), reset weatherRetry and set weatherState
back to WEATHER_IDLE so the next periodic refresh interval (default 30min)
triggers a fresh attempt automatically.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alex Petrochenko
2026-05-18 14:52:42 +01:00
co-authored by Claude Sonnet 4.6
parent e4ef5c8e07
commit 2f3814c225
+8 -2
View File
@@ -96,7 +96,10 @@ void ICACHE_FLASH_ATTR onWeatherResponse(void* optParm, AsyncHTTPRequest* reques
weatherRetry.scheduleRetry();
if (weatherRetry.maxRetriesReached()) {
Serial.println("Weather max retries reached");
// Reset so periodic refresh can retry after weatherInterval — prevents permanent lockup
Serial.println("Weather max retries reached, resetting for next interval");
weatherRetry.reset();
weatherState = WEATHER_IDLE;
} else {
unsigned long backoff = weatherRetry.getBackoffDelay() / 1000;
Serial.printf(" Retry scheduled in %lu seconds\n", backoff);
@@ -113,7 +116,10 @@ void ICACHE_FLASH_ATTR onWeatherResponse(void* optParm, AsyncHTTPRequest* reques
weatherRetry.scheduleRetry();
if (weatherRetry.maxRetriesReached()) {
Serial.println("Weather max retries reached");
// Reset so periodic refresh can retry after weatherInterval — prevents permanent lockup
Serial.println("Weather max retries reached, resetting for next interval");
weatherRetry.reset();
weatherState = WEATHER_IDLE;
} else {
unsigned long backoff = weatherRetry.getBackoffDelay() / 1000;
Serial.printf(" Retry scheduled in %lu seconds\n", backoff);