mirror of
https://github.com/esphome/esphome.git
synced 2024-11-23 23:48:11 +01:00
Move in cpp
This commit is contained in:
parent
87659ef22b
commit
2c5419bc28
2 changed files with 3 additions and 2 deletions
|
@ -24,6 +24,8 @@ namespace sntp {
|
||||||
|
|
||||||
static const char *const TAG = "sntp";
|
static const char *const TAG = "sntp";
|
||||||
|
|
||||||
|
std::vector<std::pair<optional<struct timeval>, sntp_sync_status_t>> callback_args_;
|
||||||
|
|
||||||
static std::function<void(struct timeval *tv)> g_sync_callback = nullptr;
|
static std::function<void(struct timeval *tv)> g_sync_callback = nullptr;
|
||||||
|
|
||||||
void sntp_sync_time_cb(struct timeval *tv) { g_sync_callback(tv); }
|
void sntp_sync_time_cb(struct timeval *tv) { g_sync_callback(tv); }
|
||||||
|
@ -79,7 +81,7 @@ void SNTPComponent::update() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
void SNTPComponent::loop() {
|
void SNTPComponent::loop() {
|
||||||
for (const auto &item : this->callback_args_) {
|
for (const auto &item : callback_args_) {
|
||||||
switch (item.second) {
|
switch (item.second) {
|
||||||
case SNTP_SYNC_STATUS_RESET:
|
case SNTP_SYNC_STATUS_RESET:
|
||||||
ESP_LOGD(TAG, "Time sync reset");
|
ESP_LOGD(TAG, "Time sync reset");
|
||||||
|
|
|
@ -32,7 +32,6 @@ class SNTPComponent : public time::RealTimeClock {
|
||||||
std::string server_2_;
|
std::string server_2_;
|
||||||
std::string server_3_;
|
std::string server_3_;
|
||||||
bool has_time_{false};
|
bool has_time_{false};
|
||||||
std::vector<std::pair<optional<struct timeval>, sntp_sync_status_t>> callback_args_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace sntp
|
} // namespace sntp
|
||||||
|
|
Loading…
Reference in a new issue