File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -102,8 +102,6 @@ bool NTPClient::forceUpdate() {
102102 timeout++;
103103 } while (cb == 0 );
104104
105- this ->_lastUpdate = millis () - (10 * (timeout + 1 )); // Account for delay in reading the time
106-
107105 this ->_udp ->read (this ->_packetBuffer , NTP_PACKET_SIZE);
108106
109107 unsigned long highWord = word (this ->_packetBuffer [40 ], this ->_packetBuffer [41 ]);
@@ -112,6 +110,15 @@ bool NTPClient::forceUpdate() {
112110 // this is NTP time (seconds since Jan 1 1900):
113111 unsigned long secsSince1900 = highWord << 16 | lowWord;
114112
113+ // Fixed upstream bug
114+ // See https://github.com/arduino-libraries/NTPClient/pull/211
115+ // che - 20250304
116+ if (secsSince1900 == 0 ) {
117+ // Invalid response from NTP server -> ignore
118+ return false ;
119+ }
120+
121+ this ->_lastUpdate = millis () - (10 * (timeout + 1 )); // Account for delay in reading the time
115122 this ->_currentEpoc = secsSince1900 - SEVENZYYEARS;
116123
117124 return true ; // return true after successful update
You can’t perform that action at this time.
0 commit comments