mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 15:38:11 +01:00
Defer the stop_poller
call from setup
. Call get_update_interval
from the base class.
This commit is contained in:
parent
d426cae2f3
commit
df801778b3
1 changed files with 9 additions and 5 deletions
|
@ -38,10 +38,13 @@ void SNTPComponent::setup() {
|
|||
}
|
||||
}
|
||||
#ifdef USE_ESP_IDF
|
||||
// We can't call `stop_poller` here because it will be started after `setup` call. So defer the execution.
|
||||
this->defer([this] {
|
||||
// Stop the puller to prevent periodically update calls. IDF Handles periodic updates by itself.
|
||||
// The user still able to call `update` to trigger manual update.
|
||||
this->stop_poller();
|
||||
esp_sntp_set_sync_interval(this->get_update_interval());
|
||||
});
|
||||
esp_sntp_set_sync_interval(time::RealTimeClock::get_update_interval());
|
||||
#endif
|
||||
|
||||
sntp_init();
|
||||
|
@ -110,7 +113,8 @@ void SNTPComponent::loop() {
|
|||
/**
|
||||
Sets the update interval calling `sntp_set_sync_interval()`.
|
||||
|
||||
Calls `sntp_restart()` if update interval is less then it was before as ESP IDF according documentation. Without this cal interval will be updated only after previously scheduled update.
|
||||
Calls `sntp_restart()` if update interval is less then it was before as ESP IDF according documentation. Without this
|
||||
cal interval will be updated only after previously scheduled update.
|
||||
*/
|
||||
void SNTPComponent::set_update_interval(uint32_t update_interval) {
|
||||
const auto previous_sync_interval = sntp_get_sync_interval();
|
||||
|
|
Loading…
Reference in a new issue