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 @@ -279,24 +279,24 @@ bool TimeServiceClass::connected()
279279unsigned long TimeServiceClass::getRemoteTime ()
280280{
281281 if (connected ()) {
282- /* At first try to see if a valid time can be obtained
283- * using the network time available via the connection
284- * handler.
285- */
286- unsigned long const connection_time = _con_hdl->getTime ();
287- if (isTimeValid (connection_time)) {
288- return connection_time;
289- }
290-
291282#ifndef __AVR__
292- /* If no valid network time is available try to obtain the
293- * time via NTP next.
283+ /* At first try to obtain a valid time via NTP.
284+ * This is the most reliable time source and it will
285+ * ensure a correct behaviour of the library.
294286 */
295287 unsigned long const ntp_time = NTPUtils::getTime (_con_hdl->getUDP ());
296288 if (isTimeValid (ntp_time)) {
297289 return ntp_time;
298290 }
299291#endif
292+
293+ /* As fallback if NTP request fails try to obtain the
294+ * network time using the connection handler.
295+ */
296+ unsigned long const connection_time = _con_hdl->getTime ();
297+ if (isTimeValid (connection_time)) {
298+ return connection_time;
299+ }
300300 }
301301
302302 /* Return the epoch timestamp at compile time as a last
You can’t perform that action at this time.
0 commit comments