mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 02:36:35 +00:00
parent
bacb730b53
commit
a3964d1679
@ -48,6 +48,7 @@ struct RTC {
|
|||||||
uint32_t midnight = 0;
|
uint32_t midnight = 0;
|
||||||
uint32_t restart_time = 0;
|
uint32_t restart_time = 0;
|
||||||
uint32_t millis = 0;
|
uint32_t millis = 0;
|
||||||
|
uint32_t last_sync = 0;
|
||||||
int32_t time_timezone = 0;
|
int32_t time_timezone = 0;
|
||||||
uint8_t ntp_sync_minute = 0;
|
uint8_t ntp_sync_minute = 0;
|
||||||
bool midnight_now = false;
|
bool midnight_now = false;
|
||||||
@ -369,7 +370,8 @@ void RtcSecond(void)
|
|||||||
|
|
||||||
Rtc.millis = millis();
|
Rtc.millis = millis();
|
||||||
|
|
||||||
if (!Rtc.user_time_entry && !global_state.wifi_down) {
|
if (!Rtc.user_time_entry) {
|
||||||
|
if (!global_state.wifi_down) {
|
||||||
uint8_t uptime_minute = (uptime / 60) % 60; // 0 .. 59
|
uint8_t uptime_minute = (uptime / 60) % 60; // 0 .. 59
|
||||||
if ((Rtc.ntp_sync_minute > 59) && (uptime_minute > 2)) {
|
if ((Rtc.ntp_sync_minute > 59) && (uptime_minute > 2)) {
|
||||||
Rtc.ntp_sync_minute = 1; // If sync prepare for a new cycle
|
Rtc.ntp_sync_minute = 1; // If sync prepare for a new cycle
|
||||||
@ -382,6 +384,7 @@ void RtcSecond(void)
|
|||||||
if (Rtc.ntp_time > START_VALID_TIME) { // Fix NTP bug in core 2.4.1/SDK 2.2.1 (returns Thu Jan 01 08:00:10 1970 after power on)
|
if (Rtc.ntp_time > START_VALID_TIME) { // Fix NTP bug in core 2.4.1/SDK 2.2.1 (returns Thu Jan 01 08:00:10 1970 after power on)
|
||||||
ntp_force_sync = false;
|
ntp_force_sync = false;
|
||||||
Rtc.utc_time = Rtc.ntp_time;
|
Rtc.utc_time = Rtc.ntp_time;
|
||||||
|
Rtc.last_sync = Rtc.ntp_time;
|
||||||
Rtc.ntp_sync_minute = 60; // Sync so block further requests
|
Rtc.ntp_sync_minute = 60; // Sync so block further requests
|
||||||
if (Rtc.restart_time == 0) {
|
if (Rtc.restart_time == 0) {
|
||||||
Rtc.restart_time = Rtc.utc_time - uptime; // save first ntp time as restart time
|
Rtc.restart_time = Rtc.utc_time - uptime; // save first ntp time as restart time
|
||||||
@ -405,6 +408,12 @@ void RtcSecond(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((Rtc.utc_time > (1 * 60 * 60)) && (Rtc.last_sync < Rtc.utc_time - (1 * 60 * 60))) { // Every hour a warning
|
||||||
|
// Do not use AddLog_P2 here (interrupt routine) if syslog or mqttlog is enabled. UDP/TCP will force exception 9
|
||||||
|
PrepLog_P2(LOG_LEVEL_DEBUG, PSTR("NTP: Not synced"));
|
||||||
|
Rtc.last_sync = Rtc.utc_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Rtc.utc_time++; // Increment every second
|
Rtc.utc_time++; // Increment every second
|
||||||
Rtc.local_time = Rtc.utc_time;
|
Rtc.local_time = Rtc.utc_time;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user