Functions#

This section provides a reference to the SNTP API functions.

Note

  • Event/Callback handlers must not contain function calls or code which can block or delay the execution of the event/callback handler as it will cause all the other events to queue up and delay the execution of other events since all the events are invoked and handled from a single thread.

  • Do not call any synchronous SDK APIs from within the Event/Callback handlers.

Functions#

sl_status_t
sl_sntp_client_start(sl_sntp_client_config_t *config, uint32_t timeout)

Start the 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)

Retrieve NTP server information.

sl_status_t
sl_sntp_client_stop(uint32_t timeout)

Stop the 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 the SNTP client.

Parameters
[in]config


A valid pointer to the client configuration structure of type sl_sntp_client_config_t. This parameter must not be null.

[in]timeout

The timeout for starting the SNTP client. If the timeout is greater than 0, this function operates in blocking mode. Otherwise, results are returned via the sl_sntp_client_event_handler_t callback.

This function initializes and starts the SNTP client with the provided configuration. It verifies the input parameters, sets up the client request, and sends the command to start the SNTP client. The function can operate in both blocking and non-blocking modes based on the timeout value.

Returns

Note

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


Definition at line 244 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

A valid pointer to a data buffer which should be greater than or equal to 50 bytes. In synchronous mode, the time is returned in this buffer in string format. In asynchronous mode, this parameter is given to the user in the user_data parameter of the event handler.

[in]data_length

The length of the data buffer. In asynchronous mode, this parameter is given to the user in the user_data_length parameter of the event handler.

[in]timeout

The timeout for getting the time. If the timeout is greater than 0, this function operates in blocking mode. Otherwise, results are returned via the sl_sntp_client_event_handler_t callback.

The function retrieves the current NTP epoch time. It operates in synchronous and asynchronous mode based on the timeout value.

  • Synchronous Mode: If the timeout value is non-zero then, function waits for the response until the timeout occurs. It returns the value in the provided data buffer.

  • Asynchronous Mode: If the timeout value is zero then, function returns immediately, It returns the value via the sl_sntp_client_event_handler_t callback.

Returns

Note


Definition at line 273 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


A valid pointer to a data buffer must have value greater than or equal to 50 bytes. In synchronous mode, the time and date parameters are return in string format in the buffer. In asynchronous mode, the parameter is specified by the user via a user_data parameter of the event handler.

[in]data_length

The parameter captures the length of the data buffer in synchronous mode. In asynchronous mode, the parameter is stated to the user via the user_data_length parameter of the event handler.

[in]timeout

The timeout captures time and date.If the timeout value is greater than 0, the function operates in blocking mode else, it returns the result via the sl_sntp_client_event_handler_t callback.

The function retrieves the current NTP epoch time and date. It operates in synchronous and asynchronous mode based on the timeout value.

  • Synchronous Mode: If the timeout value is non-zero then, function waits for the response until the timeout occurs. It returns the value in the provided data buffer.

  • Asynchronous Mode: If the timeout value is zero then, function returns immediately, It returns the value via the sl_sntp_client_event_handler_t callback.

Returns

Note


Definition at line 302 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)

Retrieve NTP server information.

Parameters
[out]data

A pointer is a sl_sntp_server_info_t type buffer where the server information is stored. In asynchronous mode, the parameter is passed to the user in the user_data parameter of the event handler. In synchronous mode the server information is returned in this data buffer.

[in]timeout

The timeout receives server information. If the timeout is greater than 0, the function operates in blocking mode else, it would return the result via the sl_sntp_client_event_handler_t callback.

The function retrieves information about the NTP server. It operates in both synchronous and asynchronous modes based on the timeout value. In synchronous mode, the server returns the information in the specific data buffer. In asynchronous mode, the result is return via the sl_sntp_client_event_handler_t callback.

Returns

Note


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

sl_sntp_client_stop#

sl_status_t sl_sntp_client_stop (uint32_t timeout)

Stop the SNTP client.

Parameters
[in]timeout

The timeout to stop the SNTP client. The function operates in blocking mode if the timeout value is greater than 0 else, results are returned via the sl_sntp_client_event_handler_t callback.

The function stops the SNTP client. It operates in both synchronous and asynchronous modes based on the timeout value. In synchronous mode, the function blocks until the client stops or the timeout occurs. In asynchronous mode, the results are returned via the sl_sntp_client_event_handler_t callback.

Returns

Note


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