File tree 1 file changed +14
-10
lines changed
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()
143
143
sync ();
144
144
}
145
145
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;
149
157
}
150
158
151
159
void TimeServiceClass::setTime (unsigned long time)
@@ -157,7 +165,7 @@ bool TimeServiceClass::sync()
157
165
{
158
166
_is_rtc_configured = false ;
159
167
160
- unsigned long utc = EPOCH_AT_COMPILE_TIME ;
168
+ unsigned long utc = EPOCH ;
161
169
if (_sync_func) {
162
170
utc = _sync_func ();
163
171
} else {
@@ -308,12 +316,8 @@ unsigned long TimeServiceClass::getRemoteTime()
308
316
}
309
317
}
310
318
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;
317
321
}
318
322
319
323
#endif /* HAS_TCP */
You can’t perform that action at this time.
0 commit comments