Skip to content

Commit

Permalink
Keep time in case of sync failure.
Browse files Browse the repository at this point in the history
Before, in case of a failure system time was set to 0
  • Loading branch information
gmag11 committed May 1, 2017
1 parent 2227eb5 commit cf929e1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/ESPNTPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ time_t NTPClient::getTime()
setSyncInterval(getShortInterval()); // Fast refresh frequency, until successful sync
if (onSyncEvent)
onSyncEvent(noResponse);
return 0;
if (!_firstSync) // first sync is not set
return 0;
else
return now();
}

if (onSyncEvent)
Expand All @@ -146,8 +149,11 @@ time_t NTPClient::getTime()
DEBUGLOG("-- NTP Error. WiFi not connected.\r\n");
if (onSyncEvent)
onSyncEvent(noResponse);
return 0;
}
if (!_firstSync) // first sync is not set
return 0;
else
return now();
}
}

bool NTPClient::begin(String ntpServerName, int timeOffset, bool daylight)
Expand Down

0 comments on commit cf929e1

Please sign in to comment.