Skip to content

Commit

Permalink
Add NTP failure mode reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
lbussy committed Apr 1, 2020
1 parent e488d3d commit f791f0b
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 105 deletions.
6 changes: 6 additions & 0 deletions src/ntp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ void setClock() {
configTime(GMT, 0, "pool.ntp.org", "time.nist.gov");
time_t nowSecs = time(nullptr);
time_t startSecs = time(nullptr);
int cycle = 0;
while (nowSecs < EPOCH_1_1_2019) {
cycle++;
if (nowSecs - startSecs > 9) {
if (cycle > 10) {
Log.warning(F("Unable to get time hack from %s, rebooting." CR), TIMESERVER);
ESP.restart();
}
#ifdef LOG_LEVEL
Serial.println();
#endif
Expand Down
Loading

0 comments on commit f791f0b

Please sign in to comment.