diff --git a/NTPClient.cpp b/NTPClient.cpp old mode 100755 new mode 100644 index b435855..5cb257e --- a/NTPClient.cpp +++ b/NTPClient.cpp @@ -173,14 +173,35 @@ void NTPClient::setTimeOffset(int timeOffset) { this->_timeOffset = timeOffset; } +long NTPClient::getTimeOffset() { + return this->_timeOffset; +} + void NTPClient::setUpdateInterval(unsigned long updateInterval) { this->_updateInterval = updateInterval; } +unsigned long NTPClient::getUpdateInterval() { + return this->_updateInterval; +} + void NTPClient::setPoolServerName(const char* poolServerName) { this->_poolServerName = poolServerName; } +const char *NTPClient::getPoolServerName() { + return this->_poolServerName; +} + +void NTPClient::setPoolServerIP(IPAddress poolServerIP) { + this->_poolServerIP = poolServerIP; + this->_poolServerName = NULL; +} + +IPAddress NTPClient::getPoolServerIP() { + return this->_poolServerIP; +} + void NTPClient::sendNTPPacket() { // set all bytes in the buffer to 0 memset(this->_packetBuffer, 0, NTP_PACKET_SIZE); @@ -210,3 +231,7 @@ void NTPClient::setRandomPort(unsigned int minValue, unsigned int maxValue) { randomSeed(analogRead(0)); this->_port = random(minValue, maxValue); } + +void NTPClient::setLastUpdate(unsigned long sec) { + this->_lastUpdate = sec; +} \ No newline at end of file diff --git a/NTPClient.h b/NTPClient.h old mode 100755 new mode 100644 index a31d32f..76451b9 --- a/NTPClient.h +++ b/NTPClient.h @@ -44,6 +44,23 @@ class NTPClient { */ void setPoolServerName(const char* poolServerName); + /** + * Get time server name + */ + const char *getPoolServerName(); + + /** + * Set time server IP + * + * @param poolServerIP + */ + void setPoolServerIP(IPAddress poolServerIP); + + /* + * Get time server IP + */ + IPAddress getPoolServerIP(); + /** * Set random local port */ @@ -91,12 +108,22 @@ class NTPClient { */ void setTimeOffset(int timeOffset); + /** + * Get the time offset + */ + long getTimeOffset(); + /** * Set the update interval to another frequency. E.g. useful when the * timeOffset should not be set in the constructor */ void setUpdateInterval(unsigned long updateInterval); + /** + * Get the update interval + */ + unsigned long getUpdateInterval(); + /** * @return time formatted like `hh:mm:ss` */ @@ -111,4 +138,9 @@ class NTPClient { * Stops the underlying UDP client */ void end(); + + /** + * Set the last update time + */ + void setLastUpdate(unsigned long sec); };