13#if PC_ENABLE_NTP && defined(ARDUINO)
19static const time_t PC_NTP_PLAUSIBLE_EPOCH = 1609459200;
21bool pc_ntp_begin(
const char *tz,
const char *server1,
const char *server2)
24 configTzTime(tz ? tz :
"UTC0", server1, server2);
30 return time(
nullptr) > PC_NTP_PLAUSIBLE_EPOCH;
35 time_t now = time(
nullptr);
36 return (now > PC_NTP_PLAUSIBLE_EPOCH) ? now : 0;
54 time_t host_test_epoch = 0;
60 s_ntp_svc.host_test_epoch = epoch;
63bool pc_ntp_begin(
const char *tz,
const char *server1,
const char *server2)
72 return s_ntp_svc.host_test_epoch != 0;
76 return s_ntp_svc.host_test_epoch;
Render a Unix epoch as an RFC 7231 IMF-fixdate.
uint8_t pc_http_date(time_t epoch, char *out, uint32_t out_cap)
Write epoch into out as an IMF-fixdate in GMT.
size_t pc_ntp_http_date(char *out, size_t out_cap)
Format the current time as an RFC 7231 IMF-fixdate (HTTP Date).
uint32_t pc_ntp_time_source(void)
NTP as a time source for the multi-source registry (services/timing_position/time_source).
bool pc_ntp_begin(const char *tz, const char *server1, const char *server2)
Start the SNTP client.
time_t pc_ntp_epoch()
Current Unix epoch seconds, or 0 if not yet synced (or disabled).
bool pc_ntp_synced()
True once a plausible wall-clock time has been obtained from SNTP.
void pc_ntp_set_test_epoch(time_t epoch)