mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 17:27:59 +01:00
Special handlr for esp_idf
This commit is contained in:
parent
e7632ea16c
commit
ced4eea497
1 changed files with 5 additions and 1 deletions
|
@ -81,10 +81,12 @@ void SNTPComponent::update() {
|
|||
}
|
||||
#endif
|
||||
#if defined(USE_ESP_IDF)
|
||||
this->has_time_ = false;
|
||||
sntp_restart();
|
||||
#endif
|
||||
}
|
||||
void SNTPComponent::loop() {
|
||||
#if defined(USE_ESP_IDF)
|
||||
for (const auto &item : callback_args_) {
|
||||
switch (item.second) {
|
||||
case SNTP_SYNC_STATUS_RESET:
|
||||
|
@ -92,6 +94,7 @@ void SNTPComponent::loop() {
|
|||
break;
|
||||
case SNTP_SYNC_STATUS_COMPLETED:
|
||||
ESP_LOGD(TAG, "Time sync completed");
|
||||
this->has_time_ = true;
|
||||
this->time_sync_callback_.call();
|
||||
break;
|
||||
case SNTP_SYNC_STATUS_IN_PROGRESS:
|
||||
|
@ -104,7 +107,7 @@ void SNTPComponent::loop() {
|
|||
}
|
||||
}
|
||||
callback_args_.clear();
|
||||
|
||||
#else
|
||||
if (this->has_time_)
|
||||
return;
|
||||
|
||||
|
@ -116,6 +119,7 @@ void SNTPComponent::loop() {
|
|||
time.minute, time.second);
|
||||
this->time_sync_callback_.call();
|
||||
this->has_time_ = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace sntp
|
||||
|
|
Loading…
Reference in a new issue