Don't set time if NTP wasn't successful.
This commit is contained in:
parent
06839fa806
commit
15838abd5a
1 changed files with 5 additions and 4 deletions
|
@ -122,13 +122,14 @@ void Watchy::SyncNTPTime()
|
|||
NTPClient timeClient(ntpUDP, NTP_SERVER, 0);
|
||||
timeClient.begin();
|
||||
bool success = timeClient.forceUpdate();
|
||||
if (!success) {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Failed to get NTP time");
|
||||
}
|
||||
if (success) {
|
||||
tmElements_t tm;
|
||||
breakTime((time_t)timeClient.getEpochTime(), tm);
|
||||
m_RTC.set(tm);
|
||||
} else {
|
||||
Serial.begin(9600);
|
||||
Serial.println("Failed to get NTP time");
|
||||
}
|
||||
}
|
||||
|
||||
void Watchy::DisconnectWiFi()
|
||||
|
|
Loading…
Reference in a new issue