File tree Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Expand file tree Collapse file tree 1 file changed +13
-16
lines changed Original file line number Diff line number Diff line change @@ -206,31 +206,28 @@ unsigned long TimeService::getRemoteTime()
206
206
#include " ../../AIoTC_Config.h"
207
207
#ifndef HAS_LORA
208
208
209
- if (_con_hdl == nullptr )
210
- return EPOCH_AT_COMPILE_TIME;
211
-
212
- /* At first try to see if a valid time can be obtained
213
- * using the network time available via the connection
214
- * handler.
215
- */
216
- unsigned long const connection_time = _con_hdl->getTime ();
217
- if (isTimeValid (connection_time)) {
218
- return connection_time;
219
- }
209
+ if (isConnected ()) {
210
+ /* At first try to see if a valid time can be obtained
211
+ * using the network time available via the connection
212
+ * handler.
213
+ */
214
+ unsigned long const connection_time = _con_hdl->getTime ();
215
+ if (isTimeValid (connection_time)) {
216
+ return connection_time;
217
+ }
220
218
221
219
#ifndef __AVR__
222
- /* If no valid network time is available try to obtain the
223
- * time via NTP next.
224
- */
225
- if (_con_hdl->getStatus () == NetworkConnectionState::CONNECTED) {
220
+ /* If no valid network time is available try to obtain the
221
+ * time via NTP next.
222
+ */
226
223
unsigned long const ntp_time = NTPUtils::getTime (_con_hdl->getUDP ());
227
224
if (isTimeValid (ntp_time)) {
228
225
return ntp_time;
229
226
}
230
- }
231
227
#endif
232
228
233
229
#endif /* ifndef HAS_LORA */
230
+ }
234
231
235
232
/* Return the epoch timestamp at compile time as a last
236
233
* line of defense. Otherwise the certificate expiration
You can’t perform that action at this time.
0 commit comments