Skip to content

Commit

Permalink
use ESP8266_MAX_DELAY_TIME_MS to prevent watchdog reset
Browse files Browse the repository at this point in the history
  • Loading branch information
PRosenb committed May 29, 2019
1 parent d63d7d4 commit 8fbee52
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
3 changes: 3 additions & 0 deletions DeepSleepScheduler_esp_definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#ifndef ESP32_TASK_WDT_TIMER_NUMBER
#define ESP32_TASK_WDT_TIMER_NUMBER 3
#endif
#ifndef ESP8266_MAX_DELAY_TIME_MS
#define ESP8266_MAX_DELAY_TIME_MS 7000
#endif

private:
void init();
Expand Down
17 changes: 3 additions & 14 deletions DeepSleepScheduler_esp_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,23 +267,12 @@ void Scheduler::sleep(unsigned long durationMs, bool queueEmpty) {
}
#endif

#ifdef ESP8266_MAX_DELAY_TIME_MS
if (durationMs > ESP8266_MAX_DELAY_TIME_MS) {
durationMs = ESP8266_MAX_DELAY_TIME_MS;
}
#endif
if (durationMs > ESP8266_MAX_DELAY_TIME_WDT_MS) {
long durationMsRemaining = durationMs;
while (durationMsRemaining > ESP8266_MAX_DELAY_TIME_WDT_MS) {
durationMsRemaining -= ESP8266_MAX_DELAY_TIME_WDT_MS;
delay(ESP8266_MAX_DELAY_TIME_WDT_MS);
ESP.wdtFeed();
}
delay(durationMsRemaining);
ESP.wdtFeed();
} else {
delay(durationMs);
}

delay(durationMs);
ESP.wdtFeed();
}
#endif
// -------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ HIGH = active, LOW = sleeping
- `#ESP32_TASK_WDT_TIMER_NUMBER`: Specifies the timer number to be used for task supervision. Default is 3.

#### ESP8266 specific options ####
- `ESP8266_MAX_DELAY_TIME_MS`: The maximum time in milliseconds the CPU will be delayed while no task is scheduled. Default is infinite. Set this value if you expect interrupts while no task is running.
- `ESP8266_MAX_DELAY_TIME_MS`: The maximum time in milliseconds the CPU will be delayed while no task is scheduled. Default is 7000 due to the watchdog timeout of 8 seconds. Set this value lower if you expect interrupts while no task is running.

## Implementation Notes ##
### General ###
Expand Down

0 comments on commit 8fbee52

Please sign in to comment.