9 #include "lwip/apps/sntp.h" 15 static const char *
const TAG =
"sntp";
18 ESP_LOGCONFIG(TAG,
"Setting up SNTP...");
19 #if defined(USE_ESP_IDF) 20 if (esp_sntp_enabled()) {
23 esp_sntp_setoperatingmode(ESP_SNTP_OPMODE_POLL);
25 for (
auto &server : this->
servers_) {
26 esp_sntp_setservername(i++, server.c_str());
32 sntp_setoperatingmode(SNTP_OPMODE_POLL);
35 for (
auto &server : this->servers_) {
36 sntp_setservername(i++, server.c_str());
42 ESP_LOGCONFIG(TAG,
"SNTP Time:");
44 for (
auto &server : this->
servers_) {
45 ESP_LOGCONFIG(TAG,
" Server %zu: '%s'", i++, server.c_str());
49 #if !defined(USE_ESP_IDF) 62 auto time = this->
now();
66 ESP_LOGD(TAG,
"Synchronized time: %04d-%02d-%02d %02d:%02d:%02d", time.year, time.month, time.day_of_month, time.hour,
67 time.minute, time.second);
ESPTime now()
Get the time in the currently defined timezone.
std::vector< std::string > servers_
CallbackManager< void()> time_sync_callback_
virtual uint32_t get_update_interval() const
Get the update interval in ms of this sensor.
Implementation of SPI Controller mode.
void dump_config() override