4 #if defined(USE_ESP32) || defined(USE_LIBRETINY) 5 #include "lwip/apps/sntp.h" 14 #include "lwip/apps/sntp.h" 19 #define strdup(x) (const_cast<char *>(x)) 25 static const char *
const TAG =
"sntp";
29 ESP_LOGCONFIG(TAG,
"Setting up SNTP...");
30 #if defined(USE_ESP32) || defined(USE_LIBRETINY) 34 sntp_setoperatingmode(SNTP_OPMODE_POLL);
40 sntp_setservername(0, strdup(this->
server_1_.c_str()));
42 sntp_setservername(1, strdup(this->
server_2_.c_str()));
45 sntp_setservername(2, strdup(this->
server_3_.c_str()));
55 ESP_LOGCONFIG(TAG,
"SNTP Time:");
56 ESP_LOGCONFIG(TAG,
" Server 1: '%s'", this->
server_1_.c_str());
57 ESP_LOGCONFIG(TAG,
" Server 2: '%s'", this->
server_2_.c_str());
58 ESP_LOGCONFIG(TAG,
" Server 3: '%s'", this->
server_3_.c_str());
59 ESP_LOGCONFIG(TAG,
" Timezone: '%s'", this->
timezone_.c_str());
62 #if !defined(USE_ESP_IDF) && !defined(USE_HOST) 75 auto time = this->
now();
79 ESP_LOGD(TAG,
"Synchronized time: %04d-%02d-%02d %02d:%02d:%02d", time.year, time.month, time.day_of_month, time.hour,
80 time.minute, time.second);
ESPTime now()
Get the time in the currently defined timezone.
CallbackManager< void()> time_sync_callback_
virtual uint32_t get_update_interval() const
Get the update interval in ms of this sensor.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
void dump_config() override