From 2c5419bc283e4f911d8fe4af02a94ff5b8b3f58a Mon Sep 17 00:00:00 2001 From: Anton Sergunov Date: Thu, 9 May 2024 02:52:27 +0000 Subject: [PATCH] Move in cpp --- esphome/components/sntp/sntp_component.cpp | 4 +++- esphome/components/sntp/sntp_component.h | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/components/sntp/sntp_component.cpp b/esphome/components/sntp/sntp_component.cpp index 9b607d90c7..a6f052d3c2 100644 --- a/esphome/components/sntp/sntp_component.cpp +++ b/esphome/components/sntp/sntp_component.cpp @@ -24,6 +24,8 @@ namespace sntp { static const char *const TAG = "sntp"; +std::vector, sntp_sync_status_t>> callback_args_; + static std::function g_sync_callback = nullptr; void sntp_sync_time_cb(struct timeval *tv) { g_sync_callback(tv); } @@ -79,7 +81,7 @@ void SNTPComponent::update() { #endif } void SNTPComponent::loop() { - for (const auto &item : this->callback_args_) { + for (const auto &item : callback_args_) { switch (item.second) { case SNTP_SYNC_STATUS_RESET: ESP_LOGD(TAG, "Time sync reset"); diff --git a/esphome/components/sntp/sntp_component.h b/esphome/components/sntp/sntp_component.h index a8edaf9898..987dd23a19 100644 --- a/esphome/components/sntp/sntp_component.h +++ b/esphome/components/sntp/sntp_component.h @@ -32,7 +32,6 @@ class SNTPComponent : public time::RealTimeClock { std::string server_2_; std::string server_3_; bool has_time_{false}; - std::vector, sntp_sync_status_t>> callback_args_; }; } // namespace sntp