oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Data Structures | Functions
SNTP Client

Simple NTP client for time synchronization. More...

Data Structures

struct  ove_sntp_config_t
 SNTP client configuration. More...
 

Functions

int ove_sntp_sync (const ove_sntp_config_t *cfg)
 Synchronize with an NTP server.
 
int ove_sntp_get_offset_us (int64_t *offset_us)
 Get the UTC offset computed by the last successful sync.
 
int ove_sntp_get_utc (uint32_t *utc_s)
 Get the current UTC time in seconds since Unix epoch.
 

Detailed Description

Simple NTP client for time synchronization.

Sends a single NTP query to a time server and stores the UTC offset relative to the monotonic clock. Useful for wall-clock timestamps, TLS certificate validation, and log correlation.

Note
Requires CONFIG_OVE_NET_SNTP (implies CONFIG_OVE_NET and CONFIG_OVE_TIME).

Function Documentation

◆ ove_sntp_sync()

int ove_sntp_sync ( const ove_sntp_config_t cfg)

Synchronize with an NTP server.

Sends a single NTP request and stores the computed UTC offset. Subsequent calls update the stored offset.

Parameters
[in]cfgConfiguration (NULL for defaults: pool.ntp.org, 5s timeout).
Returns
OVE_OK on success, negative error code on failure.

◆ ove_sntp_get_offset_us()

int ove_sntp_get_offset_us ( int64_t *  offset_us)

Get the UTC offset computed by the last successful sync.

The offset can be added to ove_time_get_us() to approximate wall-clock time (microseconds since Unix epoch).

Parameters
[out]offset_usUTC offset in microseconds.
Returns
OVE_OK if a sync has been performed, OVE_ERR_NOT_SUPPORTED otherwise.

◆ ove_sntp_get_utc()

int ove_sntp_get_utc ( uint32_t *  utc_s)

Get the current UTC time in seconds since Unix epoch.

Convenience function: returns monotonic time + NTP offset.

Parameters
[out]utc_sUTC seconds since 1970-01-01 00:00:00.
Returns
OVE_OK on success, OVE_ERR_NOT_SUPPORTED if no sync done.