From 15838abd5a47c2acab54a1d6e2fab08c3bd0be69 Mon Sep 17 00:00:00 2001 From: Lewis Jackson <> Date: Mon, 29 May 2023 20:34:13 +0300 Subject: [PATCH] Don't set time if NTP wasn't successful. --- src/Watchy.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Watchy.cpp b/src/Watchy.cpp index f2ba952..e3c95b4 100644 --- a/src/Watchy.cpp +++ b/src/Watchy.cpp @@ -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()