File tree 2 files changed +13
-6
lines changed
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) {
60
60
this ->_udpSetup = true ;
61
61
}
62
62
63
- void NTPClient::forceUpdate () {
63
+ bool NTPClient::forceUpdate () {
64
64
#ifdef DEBUG_NTPClient
65
65
Serial.println (" Update from NTP Server" );
66
66
#endif
@@ -73,7 +73,7 @@ void NTPClient::forceUpdate() {
73
73
do {
74
74
delay ( 10 );
75
75
cb = this ->_udp ->parsePacket ();
76
- if (timeout > 100 ) return ; // timeout after 1000 ms
76
+ if (timeout > 100 ) return false ; // timeout after 1000 ms
77
77
timeout++;
78
78
} while (cb == 0 );
79
79
@@ -88,14 +88,17 @@ void NTPClient::forceUpdate() {
88
88
unsigned long secsSince1900 = highWord << 16 | lowWord;
89
89
90
90
this ->_currentEpoc = secsSince1900 - SEVENZYYEARS;
91
+
92
+ return true ;
91
93
}
92
94
93
- void NTPClient::update () {
95
+ bool NTPClient::update () {
94
96
if ((millis () - this ->_lastUpdate >= this ->_updateInterval ) // Update after _updateInterval
95
97
|| this ->_lastUpdate == 0 ) { // Update if there was no update yet.
96
98
if (!this ->_udpSetup ) this ->begin (); // setup the UDP client if needed
97
- this ->forceUpdate ();
99
+ return this ->forceUpdate ();
98
100
}
101
+ return true ;
99
102
}
100
103
101
104
unsigned long NTPClient::getRawTime () {
Original file line number Diff line number Diff line change @@ -46,13 +46,17 @@ class NTPClient {
46
46
/* *
47
47
* This should be called in the main loop of your application. By default an update from the NTP Server is only
48
48
* made every 60 seconds. This can be configured in the NTPClient constructor.
49
+ *
50
+ * @return true on success, false on failure
49
51
*/
50
- void update ();
52
+ bool update ();
51
53
52
54
/* *
53
55
* This will force the update from the NTP Server.
56
+ *
57
+ * @return true on success, false on failure
54
58
*/
55
- void forceUpdate ();
59
+ bool forceUpdate ();
56
60
57
61
String getDay ();
58
62
String getHours ();
You can’t perform that action at this time.
0 commit comments