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 @@ -144,9 +144,17 @@ unsigned long TimeServiceClass::getTime()
144
144
sync ();
145
145
}
146
146
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;
150
158
}
151
159
152
160
void TimeServiceClass::setTime (unsigned long time)
@@ -158,7 +166,7 @@ bool TimeServiceClass::sync()
158
166
{
159
167
_is_rtc_configured = false ;
160
168
161
- unsigned long utc = EPOCH_AT_COMPILE_TIME ;
169
+ unsigned long utc = EPOCH ;
162
170
if (_sync_func) {
163
171
utc = _sync_func ();
164
172
} else {
@@ -310,12 +318,8 @@ unsigned long TimeServiceClass::getRemoteTime()
310
318
}
311
319
}
312
320
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;
319
323
}
320
324
321
325
#endif /* HAS_NOTECARD || HAS_TCP */
You can’t perform that action at this time.
0 commit comments