From cf929e154aa724472b195469e971e5c92f211c51 Mon Sep 17 00:00:00 2001 From: German Martin Date: Mon, 1 May 2017 08:41:19 +0200 Subject: [PATCH] Keep time in case of sync failure. Before, in case of a failure system time was set to 0 --- src/ESPNTPClient.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ESPNTPClient.cpp b/src/ESPNTPClient.cpp index c6c065f..be106a6 100644 --- a/src/ESPNTPClient.cpp +++ b/src/ESPNTPClient.cpp @@ -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) @@ -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)