Keep correct update interval

This commit is contained in:
Anton Sergunov 2024-06-07 06:36:42 +00:00
parent 0b22fc946a
commit e51ecb8b22

View file

@ -122,11 +122,11 @@ void SNTPComponent::loop() {
} }
#ifdef USE_ESP_IDF #ifdef USE_ESP_IDF
void SNTPComponent::set_update_interval(uint32_t update_interval) { void SNTPComponent::set_update_interval(uint32_t update_interval) {
time::RealTimeClock::set_update_interval(update_interval);
const auto previous_sync_interval = sntp_get_sync_interval(); const auto previous_sync_interval = sntp_get_sync_interval();
sntp_set_sync_interval(update_interval); sntp_set_sync_interval(update_interval);
const auto new_sync_interval = sntp_get_sync_interval(); const auto new_sync_interval = sntp_get_sync_interval();
time::RealTimeClock::set_update_interval(new_sync_interval);
if (previous_sync_interval > new_sync_interval) { if (previous_sync_interval > new_sync_interval) {
this->set_timeout(FORCE_UPDATE_SCHEDULE, new_sync_interval, [] { sntp_restart(); }); this->set_timeout(FORCE_UPDATE_SCHEDULE, new_sync_interval, [] { sntp_restart(); });