WE310F5  39.00.000
m2mb_sntp.h File Reference

This file contains the public APIs and structures of Simple Network Time Protocol(SNTP) module. More...

Go to the source code of this file.

Data Structures

struct  M2MB_SNTP_SERVER_ENTRY
 SNTP server entry structure. More...
 
struct  M2MB_SNTP_SERVER_LIST
 SNTP server list structure. More...
 
struct  M2MB_SNTP_TM
 Time broken down. More...
 
struct  M2MB_SNTP_SRV_ADD_INFO
 Structure is used by the Configuration ID M2MB_SNTP_CONF_SET_SRV_ADD to configure the given sntp server information. More...
 
struct  M2MB_SNTP_INIT_PARAMS
 SNTP initialization parameters. More...
 
union  M2MB_SNTP_CONF_PARAMS_T
 Structure is used by SET/GET configuration paramters of CONF IDs mentioned in enum M2MB_SNTP_CONF_ID_E. 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_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,
  M2MB_SNTPC_EVENT_SYNC_FAIL
}
 Events from SNTP module. More...
 
enum  M2MB_SNTP_CONF_ID {
  M2MB_SNTP_CONF_INVALID = 0,
  M2MB_SNTP_CONF_SET_SRV_ADD = 1,
  M2MB_SNTP_CONF_SET_SRV_DEL = 2,
  M2MB_SNTP_CONF_GET_IS_STARTED = 4,
  M2MB_SNTP_CONF_GET_TIME = 5,
  M2MB_SNTP_CONF_GET_SERVER_LIST = 6
}
 SNTP GET/SET Configuration enumeration. 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 enum M2MB_SNTP_CONF_ID M2MB_SNTP_CONF_ID_E
 SNTP GET/SET Configuration 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 event, VOID *uData)
 User callback to indicate SNTP event. More...
 
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. More...
 
typedef struct M2MB_SNTP_INIT_PARAMS M2MB_SNTP_INIT_PARAMS_T
 SNTP initialization parameters. More...
 
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. More...
 
M2MB_STATUS_T m2mb_sntp_deinit (HANDLE handle)
 m2mb_sntp_deinit is called to de-initialize SNTP module. More...
 
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. More...
 
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. More...
 
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. More...
 
M2MB_STATUS_T m2mb_sntp_update (HANDLE handle)
 m2mb_sntp_update is called to update the system time from SNTP server. More...
 

Detailed Description

This file contains the public APIs and structures of Simple Network Time Protocol(SNTP) module.

we310/epl/inc/nwk/m2mb_sntp.h

SNTP provides APIs to get the current time from the global server and updates the system.

To get the current time, the user must provide the server details. This module stores the primary and secondary server details. User can provide server details either by giving its host name or IP address. If host name is given then user has to make sure the DNS client module is initialized before setting the server details.

Steps to use SNTP module:
  1. User has to call m2mb_sntpc_init() API first to register the user callback with application 
  context and poll interval. 
  1. m2mb_sntp_start() API should be called which starts the SNTP module.
  2. Once SNTP module is started, user can add server by calling m2mb_sntp_avr_add() API with valid server name and serverId (Primary - M2MB_SNTP_SERVER_PRIMARY, secondary - M2MB_SNTP_SECONDARY_SERVER_ID).
    4. Server has to be updated by calling API m2mb_sntp_update.
    
  3. m2mb_sntp_svr_delete() is called to delete the server with particular server ID.
Note
Dependencies: "#include m2mb_types.h" "#include m2mb_status.h"
Author
SP
Date
31/03/2020

Definition in file m2mb_sntp.h.