File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Expand file tree Collapse file tree 1 file changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -144,9 +144,17 @@ unsigned long TimeServiceClass::getTime()
144144 sync ();
145145 }
146146
147- /* Read time from RTC */
148- unsigned long utc = getRTC ();
149- return isTimeValid (utc) ? utc : EPOCH_AT_COMPILE_TIME;
147+ /* Use RTC time if has been configured at least once */
148+ if (_last_sync_tick) {
149+ return getRTC ();
150+ }
151+
152+ /* Return the epoch timestamp at compile time as a last line of defense
153+ * trying to connect to the server. Otherwise the certificate expiration
154+ * date is wrong and we'll be unable to establish a connection. Schedulers
155+ * won't work correctly using this value.
156+ */
157+ return EPOCH_AT_COMPILE_TIME;
150158}
151159
152160void TimeServiceClass::setTime (unsigned long time)
@@ -158,7 +166,7 @@ bool TimeServiceClass::sync()
158166{
159167 _is_rtc_configured = false ;
160168
161- unsigned long utc = EPOCH_AT_COMPILE_TIME ;
169+ unsigned long utc = EPOCH ;
162170 if (_sync_func) {
163171 utc = _sync_func ();
164172 } else {
@@ -310,12 +318,8 @@ unsigned long TimeServiceClass::getRemoteTime()
310318 }
311319 }
312320
313- /* Return the epoch timestamp at compile time as a last
314- * line of defense. Otherwise the certificate expiration
315- * date is wrong and we'll be unable to establish a connection
316- * to the server.
317- */
318- return EPOCH_AT_COMPILE_TIME;
321+ /* Return known invalid value because we are not connected */
322+ return EPOCH;
319323}
320324
321325#endif /* HAS_NOTECARD || HAS_TCP */
You can’t perform that action at this time.
0 commit comments