Special handlr for esp_idf

This commit is contained in:
Anton Sergunov 2024-05-09 16:59:05 +00:00
parent e7632ea16c
commit ced4eea497

View file

@ -81,10 +81,12 @@ void SNTPComponent::update() {
} }
#endif #endif
#if defined(USE_ESP_IDF) #if defined(USE_ESP_IDF)
this->has_time_ = false;
sntp_restart(); sntp_restart();
#endif #endif
} }
void SNTPComponent::loop() { void SNTPComponent::loop() {
#if defined(USE_ESP_IDF)
for (const auto &item : callback_args_) { for (const auto &item : callback_args_) {
switch (item.second) { switch (item.second) {
case SNTP_SYNC_STATUS_RESET: case SNTP_SYNC_STATUS_RESET:
@ -92,6 +94,7 @@ void SNTPComponent::loop() {
break; break;
case SNTP_SYNC_STATUS_COMPLETED: case SNTP_SYNC_STATUS_COMPLETED:
ESP_LOGD(TAG, "Time sync completed"); ESP_LOGD(TAG, "Time sync completed");
this->has_time_ = true;
this->time_sync_callback_.call(); this->time_sync_callback_.call();
break; break;
case SNTP_SYNC_STATUS_IN_PROGRESS: case SNTP_SYNC_STATUS_IN_PROGRESS:
@ -104,7 +107,7 @@ void SNTPComponent::loop() {
} }
} }
callback_args_.clear(); callback_args_.clear();
#else
if (this->has_time_) if (this->has_time_)
return; return;
@ -116,6 +119,7 @@ void SNTPComponent::loop() {
time.minute, time.second); time.minute, time.second);
this->time_sync_callback_.call(); this->time_sync_callback_.call();
this->has_time_ = true; this->has_time_ = true;
#endif
} }
} // namespace sntp } // namespace sntp