Functions#

This section provides a reference to the SNTP API functions.

Functions#

sl_status_t
sl_sntp_client_start(sl_sntp_client_config_t *config, uint32_t timeout)

Start SNTP client.

sl_status_t
sl_sntp_client_get_time(uint8_t *data, uint16_t data_length, uint32_t timeout)

Get the current NTP epoch time in seconds.

sl_status_t
sl_sntp_client_get_time_date(uint8_t *data, uint16_t data_length, uint32_t timeout)

Get time and date information from NTP.

sl_status_t
sl_sntp_client_get_server_info(sl_sntp_server_info_t *data, uint32_t timeout)

Get NTP server information.

sl_status_t
sl_sntp_client_stop(uint32_t timeout)

Stop SNTP client.

Function Documentation#

sl_sntp_client_start#

sl_status_t sl_sntp_client_start (sl_sntp_client_config_t * config, uint32_t timeout)

Start SNTP client.

Parameters
[in]config

Valid pointer to client configuration structure of type sl_sntp_client_config_t . This shall not be null.

[in]timeout

Timeout for starting SNTP client. This is blocking API for timeout > 0, else results are returned in sl_sntp_client_event_handler_t callback

Returns

Note

  • This API needs to be called before calling any other SNTP API


Definition at line 156 of file components/service/sntp/inc/sl_sntp.h

sl_sntp_client_get_time#

sl_status_t sl_sntp_client_get_time (uint8_t * data, uint16_t data_length, uint32_t timeout)

Get the current NTP epoch time in seconds.

Parameters
[in]data

Valid pointer to data buffer which should be greater than or equal to 50 bytes. In synchronous case, time is returned in this buffer in string format. In async call, this parameter is given to user in user_data parameter of event handler.

[in]data_length

Data buffer length. In async call, this parameter is given to user in user_data_length parameter of event handler.

[in]timeout

Timeout for getting time. This is blocking API for timeout > 0, else results are returned in sl_sntp_client_event_handler_t callback

Returns


Definition at line 167 of file components/service/sntp/inc/sl_sntp.h

sl_sntp_client_get_time_date#

sl_status_t sl_sntp_client_get_time_date (uint8_t * data, uint16_t data_length, uint32_t timeout)

Get time and date information from NTP.

Parameters
[in]data

Valid pointer to data buffer which should be greater than or equal to 50 bytes. In synchronous case, the date and time is returned in this buffer in string format. In async call, this parameter is given to user in user_data parameter of event handler.

[in]data_length

Data buffer length. In async call, this parameter is given to user in user_data_length parameter of event handler.

[in]timeout

Timeout for getting time and date. This is blocking API for timeout > 0, else results are returned in sl_sntp_client_event_handler_t callback

Returns


Definition at line 178 of file components/service/sntp/inc/sl_sntp.h

sl_sntp_client_get_server_info#

sl_status_t sl_sntp_client_get_server_info (sl_sntp_server_info_t * data, uint32_t timeout)

Get NTP server information.

Parameters
[in]data

Valid pointer to data buffer of type __attribute__. In async call, this parameter is given to user in user_data with its the structure size (i.e sizeof( sl_sntp_client_event_handler_t )) in user_data_length parameter of event handler.

[in]timeout

Timeout for getting server information. This is blocking API for timeout > 0, else results are returned in sl_sntp_client_event_handler_t callback

Returns


Definition at line 188 of file components/service/sntp/inc/sl_sntp.h

sl_sntp_client_stop#

sl_status_t sl_sntp_client_stop (uint32_t timeout)

Stop SNTP client.

Parameters
[in]timeout

Timeout for stop SNTP client. This is blocking API for timeout > 0, else results are returned in sl_sntp_client_event_handler_t callback

Returns


Definition at line 197 of file components/service/sntp/inc/sl_sntp.h