|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
Multi-source time fallback matrix - implementation. More...
Go to the source code of this file.
Functions | |
| bool | pc_time_source_add (const char *, uint8_t, TimeSourceFn) |
| Register a time source. | |
| uint32_t | pc_time_now (void) |
| Current best time. | |
| const char * | pc_time_source_active (void) |
| Name of the source that satisfied the last pc_time_now(), or nullptr. | |
| void | pc_time_source_reset (void) |
| Clear all registered sources. | |
| size_t | pc_time_http_date (char *out, size_t out_cap) |
The current best time (pc_time_now, any registered NTP / GPS / RTC / ... source) formatted as an RFC 7231 IMF-fixdate into out. | |
Multi-source time fallback matrix - implementation.
A fixed BSS table of sources queried in ascending priority. See time_source.h.
Definition in file time_source.cpp.
| bool pc_time_source_add | ( | const char * | name, |
| uint8_t | priority, | ||
| TimeSourceFn | fn | ||
| ) |
Register a time source.
| name | stable label (referenced by pointer; must outlive the source - point it at a string literal / static, like the rest of the lib). |
| priority | lower value = higher priority (queried first). |
| fn | the source callback. |
fn is null or the table is full. Definition at line 111 of file time_source.cpp.
| uint32_t pc_time_now | ( | void | ) |
Current best time.
Queries registered sources in ascending priority and returns the first nonzero epoch (stopping at the first valid source). Returns 0 if none have valid time.
Definition at line 115 of file time_source.cpp.
Referenced by pc_time_http_date().
| const char * pc_time_source_active | ( | void | ) |
Name of the source that satisfied the last pc_time_now(), or nullptr.
Definition at line 119 of file time_source.cpp.
| void pc_time_source_reset | ( | void | ) |
Clear all registered sources.
Definition at line 123 of file time_source.cpp.
| size_t pc_time_http_date | ( | char * | out, |
| size_t | out_cap | ||
| ) |
The current best time (pc_time_now, any registered NTP / GPS / RTC / ... source) formatted as an RFC 7231 IMF-fixdate into out.
out when no source currently has a valid time.This is what lets the HTTP Date: header be fed by whatever time source is enabled, not just NTP: register RTC / GPS / NTP via pc_time_source_add() and the header follows the priority.
Definition at line 132 of file time_source.cpp.
References pc_http_date(), and pc_time_now().