diff options
-rw-r--r-- | HouseControl.ino | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/HouseControl.ino b/HouseControl.ino index 2c6f70a..2dbf282 100644 --- a/HouseControl.ino +++ b/HouseControl.ino @@ -120,7 +120,8 @@ struct st_door garageDoor1; struct st_door garageDoor2; EthernetUDP NTPSocket; -time_t lastNTPtime = 0; +time_t lastNTPtime = 0; +time_t lastNTPquery = 0; //Server telnetServer(23); WebServer httpServer("", 80); @@ -174,6 +175,9 @@ bool str_to_mac(byte *buf, byte *mac) { // send an NTP request to the time server at the given address void sendNTPpacket() { + // update query time... + lastNTPquery = time; + // Packet buffer byte pb[48]; // set all bytes in the buffer to 0 @@ -512,7 +516,8 @@ void loop() { time = now(); - if ((time - lastNTPtime) >= 600) + // query time every 10 minutes, but only once a minute till we get a response + if ((((time - lastNTPtime) >= 600) || lastNTPtime == 0) && ((time - lastNTPquery) >= 60)) sendNTPpacket(); if (NTPSocket.parsePacket() >= 46) |