21 static const char *
const TAG =
"time";
26 struct timeval timev {
27 .tv_sec =
static_cast<time_t
>(epoch), .tv_usec = 0,
29 ESP_LOGVV(TAG,
"Got epoch %" PRIu32, epoch);
30 struct timezone tz = {0, 0};
31 int ret = settimeofday(&timev, &tz);
35 ret = settimeofday(&timev,
nullptr);
42 ESP_LOGW(TAG,
"setimeofday() failed with code %d", ret);
45 auto time = this->
now();
46 ESP_LOGD(TAG,
"Synchronized time: %04d-%02d-%02d %02d:%02d:%02d", time.year, time.month, time.day_of_month, time.hour,
47 time.minute, time.second);
ESPTime now()
Get the time in the currently defined timezone.
CallbackManager< void()> time_sync_callback_
Implementation of SPI Controller mode.
void synchronize_epoch_(uint32_t epoch)
Report a unix epoch as current time.