Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers
Helper functions for updating the RTC using SNTP

SNTP helper functions. More...

Collaboration diagram for Helper functions for updating the RTC using SNTP:

Enumerations

enum  sntp_query_state {
  NO_TIME = 0 , WAITING_FOR_DNS , WAITING_FOR_SNTP , HAVE_TIME ,
  RETRYING
}
 

Functions

void SNTP_Init ()
 Initialise the SNTP library. More...
 
ca_error SNTP_Update ()
 Start the process for updating the RTC using an SNTP request. More...
 
enum sntp_query_state SNTP_GetState ()
 Get the status of the library, which indicates whether the RTC has been updated using SNTP. More...
 

Detailed Description

SNTP helper functions.

Enumeration Type Documentation

◆ sntp_query_state

Enumerator
NO_TIME 
WAITING_FOR_DNS 
WAITING_FOR_SNTP 
HAVE_TIME 
RETRYING 

Function Documentation

◆ SNTP_GetState()

enum sntp_query_state SNTP_GetState ( )

Get the status of the library, which indicates whether the RTC has been updated using SNTP.

Returns
enum sntp_query_state NO_TIME if the time has never been updated, WAITING_FOR_DNS or WAITING_FOR_SNTP if an update is in progress, RETRYING if an unsuccessful update was attempted, and HAVE_TIME if the RTC has been successfully updated.

◆ SNTP_Init()

void SNTP_Init ( )

Initialise the SNTP library.

◆ SNTP_Update()

ca_error SNTP_Update ( )

Start the process for updating the RTC using an SNTP request.

This is an asynchronous (non-blocking) function, which makes progress as long as otTaskletsProcess() and cascoda_io_handler() are being called regularly. The RTC will be updated once both the SNTP and DNS requests succeed.

Once SNTP_Update is called, the library will keep retrying until all requests succeed, and then it will refresh the RTC every 48 hours.

Calling this function while the library is in the HAVE_TIME or RETRYING states will make it start an update immediately, without waiting for the timeouts inherent in those states.

Returns
ca_error CA_ERROR_SUCCESS if the request to update the RTC is successful. CA_ERROR_ALREADY if the library is already in the process of refreshing the RTC.