File tree 1 file changed +11
-11
lines changed
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()
207
207
#ifndef HAS_LORA
208
208
209
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
- }
218
-
219
210
#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.
222
214
*/
223
215
unsigned long const ntp_time = NTPUtils::getTime (_con_hdl->getUDP ());
224
216
if (isTimeValid (ntp_time)) {
225
217
return ntp_time;
226
218
}
227
219
#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
+ }
228
228
}
229
229
230
230
#endif /* ifndef HAS_LORA */
You can’t perform that action at this time.
0 commit comments