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);
|
NTPClient timeClient(ntpUDP, NTP_SERVER, 0);
|
||||||
timeClient.begin();
|
timeClient.begin();
|
||||||
bool success = timeClient.forceUpdate();
|
bool success = timeClient.forceUpdate();
|
||||||
if (!success) {
|
if (success) {
|
||||||
|
tmElements_t tm;
|
||||||
|
breakTime((time_t)timeClient.getEpochTime(), tm);
|
||||||
|
m_RTC.set(tm);
|
||||||
|
} else {
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
Serial.println("Failed to get NTP time");
|
Serial.println("Failed to get NTP time");
|
||||||
}
|
}
|
||||||
tmElements_t tm;
|
|
||||||
breakTime((time_t)timeClient.getEpochTime(), tm);
|
|
||||||
m_RTC.set(tm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Watchy::DisconnectWiFi()
|
void Watchy::DisconnectWiFi()
|
||||||
|
|
Loading…
Reference in a new issue