@@ -37,23 +37,38 @@ NTPClient::NTPClient(UDP& udp, const char* poolServerName) {
3737
3838NTPClient::NTPClient (UDP& udp, IPAddress poolServerIP) {
3939 this ->_udp = &udp;
40- this ->_poolServerIP = poolServerIP;
40+ this ->_poolServerIP = poolServerIP;
4141 this ->_poolServerName = NULL ;
4242}
4343
44- NTPClient::NTPClient (UDP& udp, const char * poolServerName, int timeOffset) {
44+ NTPClient::NTPClient (UDP& udp, const char * poolServerName, long timeOffset) {
4545 this ->_udp = &udp;
4646 this ->_timeOffset = timeOffset;
4747 this ->_poolServerName = poolServerName;
4848}
4949
50+ NTPClient::NTPClient (UDP& udp, IPAddress poolServerIP, long timeOffset){
51+ this ->_udp = &udp;
52+ this ->_timeOffset = timeOffset;
53+ this ->_poolServerIP = poolServerIP;
54+ this ->_poolServerName = NULL ;
55+ }
56+
5057NTPClient::NTPClient (UDP& udp, const char * poolServerName, long timeOffset, unsigned long updateInterval) {
5158 this ->_udp = &udp;
5259 this ->_timeOffset = timeOffset;
5360 this ->_poolServerName = poolServerName;
5461 this ->_updateInterval = updateInterval;
5562}
5663
64+ NTPClient::NTPClient (UDP& udp, IPAddress poolServerIP, long timeOffset, unsigned long updateInterval) {
65+ this ->_udp = &udp;
66+ this ->_timeOffset = timeOffset;
67+ this ->_poolServerIP = poolServerIP;
68+ this ->_poolServerName = NULL ;
69+ this ->_updateInterval = updateInterval;
70+ }
71+
5772void NTPClient::begin () {
5873 this ->begin (NTP_DEFAULT_LOCAL_PORT);
5974}
@@ -179,7 +194,11 @@ void NTPClient::sendNTPPacket() {
179194
180195 // all NTP fields have been given values, now
181196 // you can send a packet requesting a timestamp:
182- this ->_udp ->beginPacket (this ->_poolServerName , 123 ); // NTP requests are to port 123
197+ if (this ->_poolServerName ) {
198+ this ->_udp ->beginPacket (this ->_poolServerName , 123 );
199+ } else {
200+ this ->_udp ->beginPacket (this ->_poolServerIP , 123 );
201+ }
183202 this ->_udp ->write (this ->_packetBuffer , NTP_PACKET_SIZE);
184203 this ->_udp ->endPacket ();
185204}
0 commit comments