objc

Typedefs | Functions
Network Time Protocol

Network Time Protocol (NTP) client to synchronize system time. More...

Collaboration diagram for Network Time Protocol:

Typedefs

typedef struct net_ntp_t net_ntp_t
 Opaque NTP manager handle. More...
 
typedef void(* net_ntp_callback_t) (net_ntp_t *ntp, const sys_date_t *date, void *user_data)
 Callback invoked when system time should be updated. More...
 

Functions

net_ntp_tnet_ntp_init (net_ntp_callback_t callback, void *user_data)
 Initialize (or re-initialize) the NTP manager. More...
 
bool net_ntp_valid (net_ntp_t *ntp)
 Determine if the NTP handle is checking for time updates. More...
 
void net_ntp_finalize (net_ntp_t *ntp)
 Release NTP resources. More...
 

Detailed Description

Network Time Protocol (NTP) client to synchronize system time.

This module retrieves the current UTC time from a time server, and invokes a callback which can then update the system time.

Typedef Documentation

◆ net_ntp_callback_t

typedef void(* net_ntp_callback_t) (net_ntp_t *ntp, const sys_date_t *date, void *user_data)

Callback invoked when system time should be updated.

Parameters
datePointer to the updated UTC time. Valid only for the duration of the callback.

Definition at line 37 of file ntp.h.

◆ net_ntp_t

typedef struct net_ntp_t net_ntp_t

Opaque NTP manager handle.

The handle identifies the singleton NTP manager. It is valid after net_ntp_init() succeeds and remains valid until net_ntp_finalize() is called.

Definition at line 29 of file ntp.h.

Function Documentation

◆ net_ntp_finalize()

void net_ntp_finalize ( net_ntp_t ntp)

Release NTP resources.

Parameters
ntpThe NTP manager handle.
Examples:
examples/runtime/ntp/main.c.

◆ net_ntp_init()

net_ntp_t* net_ntp_init ( net_ntp_callback_t  callback,
void *  user_data 
)

Initialize (or re-initialize) the NTP manager.

Parameters
callbackOptional callback invoked on successful time updates.
Returns
A pointer to the NTP manager handle (singleton), or NULL on error.
Examples:
examples/runtime/ntp/main.c.

◆ net_ntp_valid()

bool net_ntp_valid ( net_ntp_t ntp)

Determine if the NTP handle is checking for time updates.

Parameters
ntpThe NTP manager handle.
Returns
true if initialized; false otherwise.

Returns true if the NTP manager is valid and connected. If the connection is lost, it will return false.

Examples:
examples/runtime/ntp/main.c.