12#if DETWS_ENABLE_NTP && defined(ARDUINO)
18static const time_t DETWS_NTP_PLAUSIBLE_EPOCH = 1609459200;
20bool detws_ntp_begin(
const char *tz,
const char *server1,
const char *server2)
23 configTzTime(tz ? tz :
"UTC0", server1, server2);
29 return time(
nullptr) > DETWS_NTP_PLAUSIBLE_EPOCH;
34 time_t now = time(
nullptr);
35 return (now > DETWS_NTP_PLAUSIBLE_EPOCH) ? now : 0;
54 time_t host_test_epoch = 0;
60 s_ntp_svc.host_test_epoch = epoch;
72 return s_ntp_svc.host_test_epoch != 0;
76 return s_ntp_svc.host_test_epoch;
Format a Unix epoch as an RFC 7231 IMF-fixdate (one shared copy).
size_t detws_http_date(time_t epoch, char *out, size_t out_cap)
Write epoch as an RFC 7231 IMF-fixdate into out (always GMT).
time_t detws_ntp_epoch()
Current Unix epoch seconds, or 0 if not yet synced (or disabled).
uint32_t ntp_time_source(void)
NTP as a time source for the multi-source registry (services/time_source).
void detws_ntp_set_test_epoch(time_t epoch)
bool detws_ntp_synced()
True once a plausible wall-clock time has been obtained from SNTP.
bool detws_ntp_begin(const char *tz, const char *server1, const char *server2)
Start the SNTP client.
size_t detws_ntp_http_date(char *out, size_t out_cap)
Format the current time as an RFC 7231 IMF-fixdate (HTTP Date).
Optional SNTP wall-clock time sync (DETWS_ENABLE_NTP).