Don't set time if NTP wasn't successful.

This commit is contained in:
Lewis Jackson 2023-05-29 20:34:13 +03:00
parent 06839fa806
commit 15838abd5a

View file

@ -122,13 +122,14 @@ void Watchy::SyncNTPTime()
NTPClient timeClient(ntpUDP, NTP_SERVER, 0);
timeClient.begin();
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.println("Failed to get NTP time");
}
tmElements_t tm;
breakTime((time_t)timeClient.getEpochTime(), tm);
m_RTC.set(tm);
}
void Watchy::DisconnectWiFi()