check return value before timeout

This commit is contained in:
Tomas Jakstas 2020-03-22 12:27:38 +02:00
parent d2161a6717
commit 348058b00e

View File

@ -99,7 +99,7 @@ bool NTPClient::forceUpdate(uint16_t timeout) {
do { do {
delay ( 10 ); delay ( 10 );
cb = this->_udp->parsePacket(); cb = this->_udp->parsePacket();
if (millis() - current > timeout) return false; // timeout after 1000 ms if (cb == 0 && millis() - current > timeout) return false;
} while (cb == 0); } while (cb == 0);
this->_lastUpdate = millis() - (10 * (timeout + 1)); // Account for delay in reading the time this->_lastUpdate = millis() - (10 * (timeout + 1)); // Account for delay in reading the time