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