![]() |
WL865E4-P
36.07.001
|
This section describes the M2MB APIs to perform Simple Network Time Protocol(SNTP) operations. More...
#define | M2MB_SNTP_DEFAULT_SERVER "pool.ntp.org" |
#define | M2MB_SNTP_SERVER_NAME_SIZE 68 |
#define | M2MB_SNTP_SERVER_MAX 2 |
#define | M2MB_IP_ADDR_STR_LEN 48 |
#define | M2MB_SNTP_SYNC_DONE 0x0010 |
enum | M2MB_SNTP_SERVER_STATUS { M2MB_SNTP_SERVER_STATUS_KOD = 1, M2MB_SNTP_SERVER_STATUS_NORESP = 2 } |
Server status enumeration. More... | |
enum | M2MB_SNTP_SERVER_ID { M2MB_SNTP_SERVER_ID_PRIMARY, M2MB_SNTP_SERVER_ID_SECONDARY } |
Server ID enumeration. More... | |
enum | M2MB_SNTPC_RTC_STATUS_E { M2MB_SNTPC_EVENT_SYSTEM_RTC_SET, M2MB_SNTPC_EVENT_SYSTEM_RTC_NOT_SET } |
The enum indicates RTC SYCN status. More... | |
enum | M2MB_SNTPC_EVENTS_ID_E { M2MB_SNTPC_EVENT_INIT, M2MB_SNTPC_EVENT_INCORRECT_SVR_TYPE, M2MB_SNTPC_EVENT_SYSTEM_SYNC_DONE, M2MB_SNTPC_EVENT_SERVER_DELETED, M2MB_SNTPC_EVENT_SERVER_ADDED } |
Events from SNTP module. More... | |
typedef enum M2MB_SNTP_SERVER_STATUS | M2MB_SNTP_SERVER_STATUS_E |
Server status enumeration. More... | |
typedef enum M2MB_SNTP_SERVER_ID | M2MB_SNTP_SERVER_ID_E |
Server ID enumeration. More... | |
typedef struct M2MB_SNTP_SERVER_ENTRY | M2MB_SNTP_SERVER_ENTRY_T |
SNTP server entry structure. More... | |
typedef struct M2MB_SNTP_SERVER_LIST | M2MB_SNTP_SERVER_LIST_T |
SNTP server list structure. More... | |
typedef struct M2MB_SNTP_TM | M2MB_SNTP_TM_T |
Time broken down. More... | |
typedef void(* | M2MB_SNTPC_APP_CB_t) (void *sntpc_ctx, uint32_t event, void *uData) |
User callback to indicate SNTP event. More... | |
INT32 | m2mb_sntp_init (M2MB_SNTPC_APP_CB_t user_cb, void *user_ctx, uint32_t poll_interval) |
m2mb_sntp_init is called to initialize the SNTP user callback and continuous interval. More... | |
INT32 | m2mb_sntp_start (VOID) |
m2mb_sntp_start is called to start SNTP. More... | |
INT32 | m2mb_sntp_is_started (VOID) |
m2mb_sntp_is_started is called to check SNTP status. More... | |
INT32 | m2mb_sntp_deinit (VOID) |
m2mb_sntp_deinit is called to de-initialize SNTP module. More... | |
INT32 | m2mb_sntp_svr_add (M2MB_SNTP_SERVER_ID_E serverID, UINT8 *name) |
m2mb_sntp_svr_add is called to add a SNTP server to get the time. More... | |
INT32 | m2mb_sntp_svr_delete (M2MB_SNTP_SERVER_ID_E serverID) |
m2mb_sntp_svr_delete is called to delete the SNTP server details. More... | |
INT32 | m2mb_sntp_update (VOID) |
m2mb_sntp_update is called to update the system time from SNTP server. More... | |
INT32 | m2mb_sntp_get_time (M2MB_SNTP_TM_T *tm) |
m2mb_sntp_get_time is called to get the current system time. More... | |
INT32 | m2mb_sntp_get_server_list (M2MB_SNTP_SERVER_LIST_T *svr_List) |
m2mb_sntp_get_server_list is called to get the SNTP server list. More... | |
This section describes the M2MB APIs to perform Simple Network Time Protocol(SNTP) operations.
#define M2MB_IP_ADDR_STR_LEN 48 |
sntp sync done event mask
Definition at line 82 of file m2mb_sntp.h.
#define M2MB_SNTP_DEFAULT_SERVER "pool.ntp.org" |
< The default SNTP server if the server hostname/address is not specified. Byte length of the SNTP server name (DNS name or IPv4/IPv6 address).
Definition at line 73 of file m2mb_sntp.h.
#define M2MB_SNTP_SERVER_MAX 2 |
IP address string length.
Definition at line 79 of file m2mb_sntp.h.
#define M2MB_SNTP_SERVER_NAME_SIZE 68 |
Maximum number of servers supported
Definition at line 76 of file m2mb_sntp.h.
#define M2MB_SNTP_SYNC_DONE 0x0010 |
Definition at line 85 of file m2mb_sntp.h.
typedef struct M2MB_SNTP_SERVER_ENTRY M2MB_SNTP_SERVER_ENTRY_T |
SNTP server entry structure.
This data structure is used with m2mb_sntp_get_server_list() to get server information.
typedef enum M2MB_SNTP_SERVER_ID M2MB_SNTP_SERVER_ID_E |
Server ID enumeration.
This enum defines macros for SNTP server ID. This status signifies whether the server to be added is a Primary server or Secondary server.
typedef struct M2MB_SNTP_SERVER_LIST M2MB_SNTP_SERVER_LIST_T |
SNTP server list structure.
This data structure is used with m2mb_sntp_get_server_list() to maintain server list information.
typedef enum M2MB_SNTP_SERVER_STATUS M2MB_SNTP_SERVER_STATUS_E |
Server status enumeration.
This enum defines macros for SNTP server status. This status signifies the reply from from the server.
typedef struct M2MB_SNTP_TM M2MB_SNTP_TM_T |
Time broken down.
This data structure is used to get the system time in a broken down format.
typedef void(* M2MB_SNTPC_APP_CB_t) (void *sntpc_ctx, uint32_t event, void *uData) |
User callback to indicate SNTP event.
This callback function pointer allows the application to get SNTP event.
This data type should be used to set the event callback to get event from the SNTP by calling sntpc_start.
[in] | sntpc_ctx | sntpc_ctx passed by the user when registering the callback with API m2mb_sntp_init |
[in] | event | event is event ID of type M2MB_SNTPC_EVENTS_ID_E. |
[in] | uData | uData is data for user. User can interpret this based on M2MB_SNTPC_EVENTS_ID_E. If event ID is,
|
Example
Definition at line 245 of file m2mb_sntp.h.
enum M2MB_SNTP_SERVER_ID |
Server ID enumeration.
This enum defines macros for SNTP server ID. This status signifies whether the server to be added is a Primary server or Secondary server.
Enumerator | |
---|---|
M2MB_SNTP_SERVER_ID_PRIMARY | Primary server ID. |
M2MB_SNTP_SERVER_ID_SECONDARY | Secondary server ID. |
Definition at line 106 of file m2mb_sntp.h.
Server status enumeration.
This enum defines macros for SNTP server status. This status signifies the reply from from the server.
Enumerator | |
---|---|
M2MB_SNTP_SERVER_STATUS_KOD | Status of the SNTP server: Sent a KOD |
M2MB_SNTP_SERVER_STATUS_NORESP | Status of SNTP server: No reply |
Definition at line 94 of file m2mb_sntp.h.
Events from SNTP module.
This enum defines macros for different types of events involved in the process of SNTP protocol and helpful to user applications.
Definition at line 137 of file m2mb_sntp.h.
The enum indicates RTC SYCN status.
This enum is used by M2MB_SNTPC_EVENT_SYSTEM_SYNC_DONE event indicating the RTC status either updated or not.
Definition at line 121 of file m2mb_sntp.h.
m2mb_sntp_deinit is called to de-initialize SNTP module.
m2mb_sntp_deinit de-initializes the SNTP module. It frees up all memory allocated during initialization process.
INT32 m2mb_sntp_get_server_list | ( | M2MB_SNTP_SERVER_LIST_T * | svr_List | ) |
m2mb_sntp_get_server_list is called to get the SNTP server list.
m2mb_sntp_get_server_list gets the list of configured SNTP servers.
[in] | svr_List | Pointer to a buffer to contain the server list. |
Example
INT32 m2mb_sntp_get_time | ( | M2MB_SNTP_TM_T * | tm | ) |
m2mb_sntp_get_time is called to get the current system time.
m2mb_sntp_get_time gives the current system time.
[in] | tm | Pointer to the SNTP time structure to store the current system time. |
Example
INT32 m2mb_sntp_init | ( | M2MB_SNTPC_APP_CB_t | user_cb, |
void * | user_ctx, | ||
uint32_t | poll_interval | ||
) |
m2mb_sntp_init is called to initialize the SNTP user callback and continuous interval.
m2mb_sntp_init is called to initialize the SNTP user callback and continuous interval.
[in] | user_cb | Callback set by user. |
[in] | user_ctx | Pointer to a context set by user. |
[in] | poll_interval | Continuous poll interval in seconds, Defaults are 15 seconds for initial and 30 seconds for continuous. If poll_interval is set to 0 than server will be polled only once and SNTP module will be stopped once you receive M2MB_SNTPC_EVENT_SYSTEM_SYNC_DONE event. |
Example
m2mb_sntp_is_started is called to check SNTP status.
m2mb_sntp_is_started checks whether the SNTP client is started.
m2mb_sntp_start is called to start SNTP.
m2mb_sntp_start initializes the SNTP module.
Example
INT32 m2mb_sntp_svr_add | ( | M2MB_SNTP_SERVER_ID_E | serverID, |
UINT8 * | name | ||
) |
m2mb_sntp_svr_add is called to add a SNTP server to get the time.
m2mb_sntp_svr_add stores the SNTP server address to get the time. The server name can be either an IP address or the hostname of SNTP server. The host name cannot be more than 68 bytes.
If user is passing the hostname then DNS client should have been initialized to fetch the IP address from the hostname.
[in] | serverID | User is supposed to pass M2MB_SNTP_SERVER_PRIMARY or M2MB_SNTP_SERVER_SECONDARY to indicate whether the primary or secondary server has to be added. |
[in] | name | Pointer to the name of the server. The name can be either hostname or IP address. If hostname is given then the host name can be maximum of 68 bytes length. |
Example
INT32 m2mb_sntp_svr_delete | ( | M2MB_SNTP_SERVER_ID_E | serverID | ) |
m2mb_sntp_svr_delete is called to delete the SNTP server details.
m2mb_sntp_svr_delete deletes the SNTP server details.
[in] | serverID | User is supposed to pass M2MB_SNTP_SERVER_PRIMARY or M2MB_SNTP_SERVER_SECONDARY to indicate whether the primary or secondary server has to be deleted. |
Example
m2mb_sntp_update is called to update the system time from SNTP server.
m2mb_sntp_update initiates the SNTP procedure and updates the system time.