28#ifndef RCBENCH_WALL_CLOCK_H
29#define RCBENCH_WALL_CLOCK_H
45#define WALL_VALID_FLOOR_S 1767225600LL
54#define WALL_STAMP_FLOOR_S 347198400LL
57#define WALL_NTP_TIMEOUT_MS 30000u
60#define WALL_NTP_SERVER "pool.ntp.org"
63#define WALL_ZONE_DEFAULT 2
66#define WALL_ZONE_COUNT 10
131char *
wall_ntp_line(
char *out,
size_t n,
const char *server, int64_t new_us,
197 bool answered, uint32_t now_ms);
236 bool crystal, uint32_t cal);
One join's request: at most one per join.
Definition wall_clock.h:152
uint32_t start_ms
Definition wall_clock.h:154
wall_ntp_state_t state
Definition wall_clock.h:153
char * wall_ntp_line(char *out, size_t n, const char *server, int64_t new_us, int64_t old_us)
The console line of an NTP answer: the server, the time set and how far it moved the clock,...
Definition wall_clock.c:107
bool wall_valid(int64_t unix_s)
Whether a clock reading holds a real date.
Definition wall_clock.c:40
wall_ntp_state_t
Where a join's NTP request stands.
Definition wall_clock.h:135
@ WALL_NTP_IDLE
Definition wall_clock.h:136
@ WALL_NTP_ASKING
Definition wall_clock.h:137
@ WALL_NTP_DONE
Definition wall_clock.h:138
char * wall_slow_clock_line(char *out, size_t n, wall_slow_src_t src, bool crystal, uint32_t cal)
The console line of the slow clock at start, after the tag "clock": the source, its calibrated freque...
Definition wall_clock.c:194
wall_ntp_do_t wall_ntp_step(wall_ntp_t *n, bool joined, bool answered, uint32_t now_ms)
Move the request on. Joined: one START, then SET on an answer or GAVE_UP after WALL_NTP_TIMEOUT_MS....
Definition wall_clock.c:127
bool wall_slow_fell_back(wall_slow_src_t src, bool crystal)
Whether the slow clock fell back from the crystal: the build asks for it and another source runs.
Definition wall_clock.c:189
wall_ntp_do_t wall_ntp_hold_step(wall_ntp_t *n, bool joined, bool lingers, bool answered, uint32_t now_ms)
wall_ntp_step() across a session's end that lingers: a request that asks counts the lingering station...
Definition wall_clock.c:171
bool wall_ntp_holds(const wall_ntp_t *n, bool lingers, uint32_t now_ms)
Whether the radio stays up past its session's end for this request: the session lingers (wa_lingers()...
Definition wall_clock.c:165
const char * wall_zone_posix(int index)
Time zone index as a POSIX TZ string, for setenv("TZ") and tzset(). The order is the SETUP row's (UI_...
Definition wall_clock.c:50
char * wall_utc_text(char *out, size_t n, int64_t unix_s)
A UTC time as "YYYY-MM-DD HH:MM:SS UTC".
Definition wall_clock.c:81
bool wall_stamp_known(int64_t mtime)
Whether a file's stamp says when it was written: false for a stamp FatFs made from an unset clock (an...
Definition wall_clock.c:45
wall_slow_src_t
The RTC (real-time clock) slow clock the ESP32-P4's RTC timer counts, as ESP-IDF's rtc_clk_slow_src_g...
Definition wall_clock.h:201
@ WALL_SLOW_RC
Definition wall_clock.h:202
@ WALL_SLOW_CRYSTAL
Definition wall_clock.h:203
@ WALL_SLOW_OTHER
Definition wall_clock.h:204
uint64_t wall_slow_mhz(uint32_t cal)
A slow clock's frequency from ESP-IDF's calibration value: the period in microseconds with 19 fractio...
Definition wall_clock.c:178
wall_ntp_do_t
What wall_ntp_step() asks of the caller.
Definition wall_clock.h:143
@ WALL_NTP_START
Definition wall_clock.h:145
@ WALL_NTP_GAVE_UP
Definition wall_clock.h:148
@ WALL_NTP_SET
Definition wall_clock.h:147
@ WALL_NTP_STOP
Definition wall_clock.h:146
@ WALL_NTP_NONE
Definition wall_clock.h:144
int64_t wall_local_s(int64_t unix_s)
A time moved by the zone in force (TZ, tzset()) at that time, so a UTC civil reading of the result sh...
Definition wall_clock.c:58