Loading...
Searching...
No Matches
Simple Network Time Protocol

Simple Network Time Protocol (SNTP) implementation. More...

Detailed Description

Simple Network Time Protocol (SNTP) implementation.

Note
The current implementation of SNTP uses ztimer 64bit version with microsecond accuracy, which can have a strong impact on the power consumption of your device.

Files

file  sntp.h
 SNTP definitions.
 

Functions

int sntp_sync (sock_udp_ep_t *server, uint32_t timeout)
 Synchronize with time server.
 
int64_t sntp_get_offset (void)
 Get real time offset from system time as returned by ztimer64_now()
 
static uint64_t sntp_get_unix_usec (void)
 Get time in microseconds from 1970-01-01 00:00:00 UTC.
 

Function Documentation

◆ sntp_get_offset()

int64_t sntp_get_offset ( void )

Get real time offset from system time as returned by ztimer64_now()

Returns
Real time offset in microseconds relative to 1900-01-01 00:00 UTC

◆ sntp_get_unix_usec()

static uint64_t sntp_get_unix_usec ( void )
inlinestatic

Get time in microseconds from 1970-01-01 00:00:00 UTC.

Returns
Time in microseconds from 1970-01-01 00:00:00 UTC

Definition at line 63 of file sntp.h.

◆ sntp_sync()

int sntp_sync ( sock_udp_ep_t * server,
uint32_t timeout )

Synchronize with time server.

Parameters
[in]serverThe time server
[in]timeoutTimeout for the server response in microseconds
Returns
0 on success
Negative number on error