diff --git a/WLAN_Thermometer.ino b/WLAN_Thermometer.ino index 42ffdba..bb8133c 100644 --- a/WLAN_Thermometer.ino +++ b/WLAN_Thermometer.ino @@ -118,16 +118,19 @@ void setup() lcd.setCursor(0, 3); lcd.print("Getting time..."); DateTime.setTimeZone(1); - DateTime.begin(NTP_TIMEOUT); - while (!DateTime.isTimeValid()) - { + DateTime.begin(); + /* while (!DateTime.isTimeValid()) + { DEBUG_MSG("Failed to get time from server.\n"); DateTime.forceUpdate(); + }*/ + if (DateTime.isTimeValid()) + { + if (is_wintertime(DateTime.getTime()) == false) + add_summertime = 1; + else + add_summertime = 0; } - if (is_wintertime(DateTime.getTime()) == false) - add_summertime = 1; - else - add_summertime = 0; // create a degree sign lcd.createChar(0, (uint8_t*)degree_sign); @@ -155,8 +158,21 @@ void setup() void loop() { + static uint32_t next_time_check; + sched.scheduler(); + if (!DateTime.isTimeValid() && millis() - 10000 > next_time_check) + { + next_time_check = millis(); + DateTime.setTimeZone(1); + DateTime.forceUpdate(); + if (is_wintertime(DateTime.getTime()) == false) + add_summertime = 1; + else + add_summertime = 0; + } + WiFiClient client = server.available(); // Listen for incoming clients if (client) { // If a new client connects, @@ -248,24 +264,27 @@ void loop() } client.println("\n"); - DateTimeParts p = DateTime.getParts(); - char dt[21]; - - if (is_wintertime(DateTime.getTime()) == false) - add_summertime = 1; - else - add_summertime = 0; - - client.println("