File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ void NTPClient::begin(int port) {
6060 this ->_udpSetup = true ;
6161}
6262
63- void NTPClient::forceUpdate () {
63+ bool NTPClient::forceUpdate () {
6464 #ifdef DEBUG_NTPClient
6565 Serial.println (" Update from NTP Server" );
6666 #endif
@@ -73,7 +73,7 @@ void NTPClient::forceUpdate() {
7373 do {
7474 delay ( 10 );
7575 cb = this ->_udp ->parsePacket ();
76- if (timeout > 100 ) return ; // timeout after 1000 ms
76+ if (timeout > 100 ) return false ; // timeout after 1000 ms
7777 timeout++;
7878 } while (cb == 0 );
7979
@@ -88,14 +88,17 @@ void NTPClient::forceUpdate() {
8888 unsigned long secsSince1900 = highWord << 16 | lowWord;
8989
9090 this ->_currentEpoc = secsSince1900 - SEVENZYYEARS;
91+
92+ return true ;
9193}
9294
93- void NTPClient::update () {
95+ bool NTPClient::update () {
9496 if ((millis () - this ->_lastUpdate >= this ->_updateInterval ) // Update after _updateInterval
9597 || this ->_lastUpdate == 0 ) { // Update if there was no update yet.
9698 if (!this ->_udpSetup ) this ->begin (); // setup the UDP client if needed
97- this ->forceUpdate ();
99+ return this ->forceUpdate ();
98100 }
101+ return true ;
99102}
100103
101104unsigned long NTPClient::getRawTime () {
Original file line number Diff line number Diff line change @@ -46,13 +46,17 @@ class NTPClient {
4646 /* *
4747 * This should be called in the main loop of your application. By default an update from the NTP Server is only
4848 * made every 60 seconds. This can be configured in the NTPClient constructor.
49+ *
50+ * @return true on success, false on failure
4951 */
50- void update ();
52+ bool update ();
5153
5254 /* *
5355 * This will force the update from the NTP Server.
56+ *
57+ * @return true on success, false on failure
5458 */
55- void forceUpdate ();
59+ bool forceUpdate ();
5660
5761 String getDay ();
5862 String getHours ();
You can’t perform that action at this time.
0 commit comments