Remove .begin() from API

This commit is contained in:
Fabrice Weinberg 2015-12-12 17:21:39 +01:00
parent eae9724b10
commit 7f05bf9e4d
4 changed files with 3 additions and 27 deletions

View File

@ -42,16 +42,6 @@ NTPClient::NTPClient(const char* poolServerName, int timeOffset, int updateInter
this->_updateInterval = updateInterval;
}
void NTPClient::begin() {
#ifdef DEBUG_NTPClient
Serial.println("Begin NTPClient");
Serial.print("Start udp connection on port: ");
Serial.println(this->_port);
#endif
this->_udp.begin(this->_port);
this->forceUpdate();
}
void NTPClient::forceUpdate() {
#ifdef DEBUG_NTPClient
Serial.println("Update from NTP Server");
@ -86,8 +76,9 @@ void NTPClient::forceUpdate() {
}
void NTPClient::update() {
unsigned long runtime = millis();
if (runtime - this->_lastUpdate >= this->_updateInterval && this->_updateInterval != 0) {
if ((millis() - this->_lastUpdate >= this->_updateInterval) // Update after _updateInterval
|| this->_lastUpdate == 0) { // Update if there was no update yet.
if (this->_lastUpdate == 0) this->_udp.begin(this->_port); // Start _udp if there was no update yet.
this->forceUpdate();
}
}

View File

@ -32,13 +32,6 @@ class NTPClient {
NTPClient(const char* poolServerName, int timeOffset);
NTPClient(const char* poolServerName, int timeOffset, int updateInterval);
/**
* Starts the NTPClient
* This will create the UDP Socket and get the first update from the NTP server. This must be called after
* a WiFi connection is established.
*/
void begin();
/**
* This should be called in the main loop of your application. By default an update from the NTP Server is only
* made every 60 seconds. This can be configured in the NTPClient constructor.

View File

@ -17,10 +17,6 @@ void setup(){
delay ( 500 );
Serial.print ( "." );
}
// Start the NTPClient after an WiFi connection is established
timeClient.begin();
}
void loop() {

View File

@ -17,10 +17,6 @@ void setup(){
delay ( 500 );
Serial.print ( "." );
}
// Start the NTPClient after an WiFi connection is established
timeClient.begin();
}
void loop() {