File tree Expand file tree Collapse file tree 1 file changed +17
-18
lines changed Expand file tree Collapse file tree 1 file changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -206,27 +206,26 @@ unsigned long TimeService::getRemoteTime()
206206#include " ../../AIoTC_Config.h"
207207#ifndef HAS_LORA
208208
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 (connected ()) {
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+ }
220218
221219#ifndef __AVR__
222- /* If no valid network time is available try to obtain the
223- * time via NTP next.
224- */
225- unsigned long const ntp_time = NTPUtils::getTime (_con_hdl->getUDP ());
226- if (isTimeValid (ntp_time)) {
227- return ntp_time;
228- }
220+ /* If no valid network time is available try to obtain the
221+ * time via NTP next.
222+ */
223+ unsigned long const ntp_time = NTPUtils::getTime (_con_hdl->getUDP ());
224+ if (isTimeValid (ntp_time)) {
225+ return ntp_time;
226+ }
229227#endif
228+ }
230229
231230#endif /* ifndef HAS_LORA */
232231
You can’t perform that action at this time.
0 commit comments