9#if TIME_SHIELD_ENABLE_NTP_CLIENT
19 std::cerr <<
"Failed to start NTP time service." << std::endl;
28 std::cout <<
"UTC time (ms): " << utc_ms << std::endl;
29 std::cout <<
"Offset (us): " << offset_us << std::endl;
30 std::cout <<
"Last measurement ok: " << (is_ok ?
"true" :
"false") << std::endl;
40 std::cout <<
"NTP time service is disabled in this build." << std::endl;
Configuration macros for the library.
void init()
Initializes the Time Shield library.
bool last_measure_ok() noexcept
Return whether last measurement updated the offset.
int64_t offset_us() noexcept
Return last estimated offset in microseconds.
void shutdown()
Stop NTP time service.
int64_t utc_time_ms() noexcept
Return current UTC time in milliseconds based on offset.
bool init(std::chrono::milliseconds interval=std::chrono::seconds(30), bool measure_immediately=true)
Initialize NTP time service and start background measurements.
Initialization helpers for the Time Shield library.