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 @@ -143,9 +143,17 @@ unsigned long TimeServiceClass::getTime()
143143 sync ();
144144 }
145145
146- /* Read time from RTC */
147- unsigned long utc = getRTC ();
148- return isTimeValid (utc) ? utc : EPOCH_AT_COMPILE_TIME;
146+ /* Use RTC time if has been configured at least once */
147+ if (_last_sync_tick) {
148+ return getRTC ();
149+ }
150+
151+ /* Return the epoch timestamp at compile time as a last line of defense
152+ * trying to connect to the server. Otherwise the certificate expiration
153+ * date is wrong and we'll be unable to establish a connection. Schedulers
154+ * won't work correctly using this value.
155+ */
156+ return EPOCH_AT_COMPILE_TIME;
149157}
150158
151159void TimeServiceClass::setTime (unsigned long time)
@@ -157,7 +165,7 @@ bool TimeServiceClass::sync()
157165{
158166 _is_rtc_configured = false ;
159167
160- unsigned long utc = EPOCH_AT_COMPILE_TIME ;
168+ unsigned long utc = EPOCH ;
161169 if (_sync_func) {
162170 utc = _sync_func ();
163171 } else {
@@ -308,12 +316,8 @@ unsigned long TimeServiceClass::getRemoteTime()
308316 }
309317 }
310318
311- /* Return the epoch timestamp at compile time as a last
312- * line of defense. Otherwise the certificate expiration
313- * date is wrong and we'll be unable to establish a connection
314- * to the server.
315- */
316- return EPOCH_AT_COMPILE_TIME;
319+ /* Return known invalid value because we are not connected */
320+ return EPOCH;
317321}
318322
319323#endif /* HAS_TCP */
You can’t perform that action at this time.
0 commit comments