oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Classes | Functions
ove::sntp Namespace Reference

C++ wrappers around the oveRTOS SNTP client API. More...

Classes

struct  Config
 SNTP client configuration with C++ defaults. More...
 

Functions

Result< void > sync (const Config &cfg={}) noexcept
 Synchronize with an NTP time server.
 
Result< int64_t > get_offset_us () noexcept
 Get the UTC offset from the last successful sync.
 
Result< uint32_t > get_utc () noexcept
 Get current UTC time in seconds since Unix epoch.
 

Detailed Description

C++ wrappers around the oveRTOS SNTP client API.

Function Documentation

◆ sync()

Result< void > ove::sntp::sync ( const Config cfg = {})
inlinenoexcept

Synchronize with an NTP time server.

Parameters
[in]cfgConfiguration (defaults: pool.ntp.org, 5s timeout).
Returns
Empty Result<void> on success; unexpected Error on failure (Error::NetDnsFail, Error::Timeout, …).

◆ get_offset_us()

Result< int64_t > ove::sntp::get_offset_us ( )
inlinenoexcept

Get the UTC offset from the last successful sync.

Returns
On success, the UTC offset in microseconds. On failure, unexpected(Error::NotSupported) if no sync has been performed yet.

◆ get_utc()

Result< uint32_t > ove::sntp::get_utc ( )
inlinenoexcept

Get current UTC time in seconds since Unix epoch.

Returns
On success, UTC seconds since the Unix epoch. On failure, an unexpected Error.