File tree 1 file changed +9
-2
lines changed 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -102,8 +102,6 @@ bool NTPClient::forceUpdate() {
102
102
timeout++;
103
103
} while (cb == 0 );
104
104
105
- this ->_lastUpdate = millis () - (10 * (timeout + 1 )); // Account for delay in reading the time
106
-
107
105
this ->_udp ->read (this ->_packetBuffer , NTP_PACKET_SIZE);
108
106
109
107
unsigned long highWord = word (this ->_packetBuffer [40 ], this ->_packetBuffer [41 ]);
@@ -112,6 +110,15 @@ bool NTPClient::forceUpdate() {
112
110
// this is NTP time (seconds since Jan 1 1900):
113
111
unsigned long secsSince1900 = highWord << 16 | lowWord;
114
112
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
115
122
this ->_currentEpoc = secsSince1900 - SEVENZYYEARS;
116
123
117
124
return true ; // return true after successful update
You can’t perform that action at this time.
0 commit comments