![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform Simple Network Time Protocol(SNTP) operations. 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 enum M2MB_SNTP_CONF_ID M2MB_SNTP_CONF_ID_E |
SNTP GET/SET Configuration enumeration.
This enum defines macros for various GET/SET Configuration for SNTP module.
typedef struct M2MB_SNTP_INIT_PARAMS M2MB_SNTP_INIT_PARAMS_T |
SNTP initialization parameters.
Contains information needed to initialize the SNTP module, such as user callback, user context and poll interval.
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_SRV_ADD_INFO M2MB_SNTP_SRV_ADD_INFO_T |
Structure is used by the Configuration ID M2MB_SNTP_CONF_SET_SRV_ADD to configure the given sntp server information.
Structure is used by the Configuration ID M2MB_SNTP_CONF_SET_SRV_ADD to configure the given sntp server ip address at the server id.
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.
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 244 of file m2mb_sntp.h.
enum M2MB_SNTP_CONF_ID |
SNTP GET/SET Configuration enumeration.
This enum defines macros for various GET/SET Configuration for SNTP module.
Definition at line 139 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 121 of file m2mb_sntp.h.
M2MB_STATUS_T m2mb_sntp_deinit | ( | HANDLE | handle | ) |
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.
[in] | handle | Specifies the context handle initialized by m2mb_sntp_init API. |
M2MB_STATUS_T m2mb_sntp_get_cfg | ( | HANDLE | handle, |
M2MB_SNTP_CONF_ID_E | conf_id, | ||
M2MB_SNTP_CONF_PARAMS_T * | conf_params | ||
) |
GET the SNTP configuration parameters.
This API is called to get the configuration of the SNTP module based on the conf IDs.
[in] | handle | Specifies the pointer to the context handle initialized by m2mb_sntp_init API. |
[in] | conf_id | GET configuration ID form enum M2MB_SNTP_CONF_ID_E. |
[in] | conf_params | configuration params to be passed according to the configuration required. |
M2MB_STATUS_T m2mb_sntp_init | ( | HANDLE * | handle, |
M2MB_SNTP_INIT_PARAMS_T * | init_params | ||
) |
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] | handle | Specifies the pointer to the context handle that can be used by other SNTP APIs. |
[in] | init_params | Initialization parameters required for SNTP module initialization. |
Example
M2MB_STATUS_T m2mb_sntp_set_cfg | ( | HANDLE | handle, |
M2MB_SNTP_CONF_ID_E | conf_id, | ||
M2MB_SNTP_CONF_PARAMS_T * | conf_params | ||
) |
SET the SNTP configuration parameters.
This API is called to configure the SNTP module based on the conf IDs.
[in] | handle | Specifies the pointer to the context handle initialized by m2mb_sntp_init API. |
[in] | conf_id | SET configuration ID form enum M2MB_SNTP_CONF_ID_E. |
[in] | conf_params | configuration params to be passed according to the configuration to be done. To add the server, use conf ID M2MB_SNTP_CONF_SET_SRV_ADD need to pass the server name and server ID with M2MB_SNTP_SRV_ADD_INFO_T *srv_info of the M2MB_SNTP_CONF_PARAMS_T. To deleve the server, use conf ID M2MB_SNTP_CONF_SET_SRV_DEL and need to pass the infomation serverID of the M2MB_SNTP_CONF_PARAMS_T |
M2MB_STATUS_T m2mb_sntp_start | ( | HANDLE | handle | ) |
m2mb_sntp_start is called to start to send the sntp client request to the sntp server.
m2mb_sntp_start starts to send the sntp client request to the sntp server.
Example
M2MB_STATUS_T m2mb_sntp_update | ( | HANDLE | handle | ) |
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.