update time daily at 4 AM
This commit is contained in:
parent
b02c731e95
commit
8f706fe32f
@ -82,6 +82,9 @@ namespace Display {
|
||||
static int currentHour = -1;
|
||||
if (currentHour != hour()) {
|
||||
currentHour = hour();
|
||||
if (currentHour == 4) {
|
||||
Ntp::updateTime();
|
||||
}
|
||||
if (currentHour == 8) {
|
||||
Brightness::set(BRIGHTNESS_DAY);
|
||||
Wifi::reconnect();
|
||||
|
||||
@ -14,13 +14,11 @@ namespace Ntp {
|
||||
TimeChangeRule CET = { "CET ", Last, Sun, Oct, 3, 60 }; // Central European Standard Time
|
||||
Timezone CE(CEST, CET);
|
||||
|
||||
time_t updateTime() {
|
||||
void updateTime() {
|
||||
if (timeClient.forceUpdate()) {
|
||||
time_t newTime = CE.toLocal(timeClient.getEpochTime());
|
||||
setTime(newTime);
|
||||
return newTime;
|
||||
} else {
|
||||
return 0;
|
||||
Serial.println(asctime(localtime(&newTime)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -84,9 +84,7 @@ void onWifiConnected() {
|
||||
Wifi::printStatus();
|
||||
Ota::tLoop.enable();
|
||||
Mqtt::tReConnect.enable();
|
||||
if (time_t newTime = Ntp::updateTime()) {
|
||||
Serial.println(asctime(localtime(&newTime)));
|
||||
}
|
||||
Ntp::updateTime();
|
||||
}
|
||||
|
||||
void checkWifiCallback() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user