File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -207,24 +207,24 @@ unsigned long TimeService::getRemoteTime()
207207#ifndef HAS_LORA
208208
209209 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- }
218-
219210#ifndef __AVR__
220- /* If no valid network time is available try to obtain the
221- * time via NTP next.
211+ /* At first try to obtain a valid time via NTP.
212+ * This is the most reliable time source and it will
213+ * ensure a correct behaviour of the library.
222214 */
223215 unsigned long const ntp_time = NTPUtils::getTime (_con_hdl->getUDP ());
224216 if (isTimeValid (ntp_time)) {
225217 return ntp_time;
226218 }
227219#endif
220+
221+ /* As fallback if NTP request fails try to obtain the
222+ * network time using the connection handler.
223+ */
224+ unsigned long const connection_time = _con_hdl->getTime ();
225+ if (isTimeValid (connection_time)) {
226+ return connection_time;
227+ }
228228 }
229229
230230#endif /* ifndef HAS_LORA */
You can’t perform that action at this time.
0 commit comments