From 735ccffcc462ce90e0bd43f203ad52b4c1bda757 Mon Sep 17 00:00:00 2001 From: bitsy <36607587+bitsy@users.noreply.github.com> Date: Tue, 17 Sep 2019 10:14:28 -0700 Subject: [PATCH] Modified update(), forceUpdate() to return integer --- NTPClient.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/NTPClient.cpp b/NTPClient.cpp index 79924c7..18d0969 100644 --- a/NTPClient.cpp +++ b/NTPClient.cpp @@ -60,7 +60,7 @@ void NTPClient::begin(int port) { this->_udpSetup = true; } -bool NTPClient::forceUpdate() { +uint8_t NTPClient::forceUpdate() { #ifdef DEBUG_NTPClient Serial.println("Update from NTP Server"); #endif @@ -73,7 +73,7 @@ bool NTPClient::forceUpdate() { do { delay ( 10 ); cb = this->_udp->parsePacket(); - if (timeout > 100) return false; // timeout after 1000 ms + if (timeout > 100) return 0; // timeout after 1000 ms; return 0 if update fails timeout++; } while (cb == 0); @@ -89,16 +89,16 @@ bool NTPClient::forceUpdate() { this->_currentEpoc = secsSince1900 - SEVENZYYEARS; - return true; // return true after successful update + return 2; // return 2 if update occurs successfully } -bool NTPClient::update() { +uint8_t NTPClient::update() { if ((millis() - this->_lastUpdate >= this->_updateInterval) // Update after _updateInterval || this->_lastUpdate == 0) { // Update if there was no update yet. if (!this->_udpSetup) this->begin(); // setup the UDP client if needed return this->forceUpdate(); } - return false; // return false if update does not occur + return 1; // return 1 if update does not occur } unsigned long NTPClient::getEpochTime() const {