Embedded TCP/IP stack  3.9.3
SNTP client API

SNTP Client API. More...

Detailed Description

SNTP Client API.

The SNTP (Simple Network Time Protocol) client service allows a user application to obtain a timestamp from a remote NTP server.
The client implements SNTP Version 4 defined by RFC4330.
After the SNTP client is initialized by calling the fnet_sntp_init() function, the user application should call the main service-polling function fnet_poll_service() periodically in background.
The obtained timestamp will be passed to the fnet_sntp_callback_resolved_t callback function, which is set during the SNTP-client service initialization.
The SNTP client service is released automatically as soon as the requested timestamp obtained or an error occurs. Your application code may continue to call fnet_poll_service() to handle other services, but this will not have any impact on the SNTP client communication until you initialize the next timestamp obtaining by calling fnet_sntp_init() again.

For the SNTP-client service example, refer to the FNET Shell demo source code.

Note
Current version of the SNTP client:
  • can process only one request at a time.
  • support unicast addressing mode. It does not support broadcast or multicast addressing mode.

Configuration parameters:

Data Structures

struct  fnet_sntp_timestamp_t
 SNTP timestamp (RFC4330) is represented as a 64-bit unsigned fixed-point number, in seconds relative to 0h on 1 January 1900. The integer part is in the first 32 bits, and the fraction part in the last 32 bits. The maximum number that can be represented is 4,294,967,295 seconds with a precision of about 232 picoseconds. More...
 
struct  fnet_sntp_utc_t
 Coordinated Universal Time (UTC) type. More...
 
struct  fnet_sntp_params
 Initialization parameters for the fnet_sntp_init() function. More...
 

Typedefs

typedef void(* fnet_sntp_callback_resolved_t) (const fnet_sntp_timestamp_t *timestamp, void *cookie)
 Prototype of the SNTP-client callback function that is called when the SNTP client has completed the timestamp resolving. More...
 

Functions

fnet_return_t fnet_sntp_init (struct fnet_sntp_params *params)
 Initializes the SNTP client service and starts the time resolving. More...
 
void fnet_sntp_release (void)
 Aborts the time resolving and releases the SNTP-client service. More...
 
void fnet_sntp_timestamp2utc (const fnet_sntp_timestamp_t *timestamp, fnet_sntp_utc_t *utc)
 Converts the SNTP timestamp to the Coordinated Universal Time (UTC). More...
 

© 2005-2017 by Andrey Butok. http://fnet.sourceforge.net