WE310F5  39.00.000
M2MB PROFILE

This section describes the M2MB APIs related to profile. More...

#define DEFAULT_TCP_SERVER   1
 
#define DEFAULT_TCP_CLIENT   2
 
#define DEFAULT_UDP_SOCKET   3
 
#define M2M_HTTPD_PROFILE_ENABLE
 
enum  M2MB_PROFILE_EVENT {
  M2MB_PROFILE_DRV_UART_INIT_DONE,
  M2MB_PROFILE_UART0_READ_CB,
  M2MB_PROFILE_UART0_WRITE_CB,
  M2MB_PROFILE_UART1_READ_CB,
  M2MB_PROFILE_UART1_WRITE_CB,
  M2MB_PROFILE_DBG_INIT_DONE,
  M2MB_PROFILE_XFP_INIT_DONE,
  M2MB_PROFILE_EVENT_AP_MODE_SET,
  M2MB_PROFILE_EVENT_STA_MODE_SET,
  M2MB_PROFILE_EVENT_DNS_SET,
  M2MB_PROFILE_EVENT_mDNS_HOSTNAME_SET,
  M2MB_PROFILE_EVENT_mDNS_SRV_REG_SET,
  M2MB_PROFILE_EVENT_UDP_CFG_SET,
  M2MB_PROFILE_EVENT_TCP_CFG_SET,
  M2MB_PROFILE_EVENT_SNTP_INIT_DONE,
  M2MB_PROFILE_EVENT_SNTP_SYNC_DONE,
  M2MB_PROFILE_EVENT_INIT_DONE
}
 Profile event enumeration. More...
 
typedef enum M2MB_PROFILE_EVENT M2MB_PROFILE_EVENT_T
 Profile event enumeration. More...
 
typedef M2MB_STATUS_T(* M2MB_PROFILE_APPLY_CB_T) (UINT8 device_id, M2MB_PROFILE_EVENT_T event, M2MB_STATUS_T status, VOID *pData)
 Profile apply callback prototype. More...
 
typedef struct M2MB_WLAN_STA_CFG_S M2MB_WLAN_STA_CFG_T
 WLAN sta structure. More...
 
typedef struct M2MB_WLAN_STA_CFG_ARRAY_S M2MB_WLAN_STA_CFG_ARRAY_T
 Array of WLAN STATION configuration structure. More...
 
typedef struct M2M_IP_CFG_S M2MB_IP_CFG_T
 IP cfg structure. More...
 
typedef struct M2MB_STA_SCAN_CFG_S M2MB_STA_SCAN_CFG_T
 STA scan cfg structure. More...
 
typedef struct M2MB_ROAMING_CFG_S M2MB_ROAMING_CFG_T
 Roaming cfg structure. More...
 
typedef struct M2MB_POWER_SAVE_CFG_S M2MB_POWER_SAVE_CFG_T
 
typedef struct M2MB_EAP_CONF_S M2MB_EAP_CONF_T
 
typedef struct M2MB_STA_CFG_S M2MB_STA_CFG_T
 STA cfg structure. More...
 
typedef struct M2M_PROFILE_STA_SET_RESULT_S M2M_PROFILE_STA_SET_RESULT_T
 STA structure used in user callback to update the status of STA initialization. More...
 
typedef struct M2MB_AP_WLAN_CFG_S M2MB_AP_WLAN_CFG_T
 AP WLAN cfg structure. More...
 
typedef struct M2MB_DHCP_SRV_CFG_S M2MB_DHCP_SRV_CFG_T
 DHCP server cfg structure. More...
 
typedef struct M2MB_AP_CFG_S M2MB_AP_CFG_T
 AP cfg structure. More...
 
typedef struct M2M_PROFILE_AP_SET_RESULT_S M2M_PROFILE_AP_SET_RESULT_T
 AP structure used in user callback to update the status of AP initialization. More...
 
typedef struct M2MB_DNS_HOST_CFG_S M2MB_DNS_HOST_CFG_T
 DNS host cfg structure. More...
 
typedef struct M2MB_DNS_HOST_CFG_ARRAY_S M2MB_DNS_HOST_CFG_ARRAY_T
 Array of DNS host cfg structure. More...
 
typedef struct M2MB_MDNS_HOST_CFG_S M2MB_MDNS_HOST_CFG_T
 MDNS host cfg structure. More...
 
typedef struct M2MB_MDNS_SERVICE_CFG_S M2MB_MDNS_SERVICE_CFG_T
 MDNS service cfg structure. More...
 
typedef struct M2MB_MDNS_SERVICE_CFG_ARRAY_S M2MB_MDNS_SERVICE_CFG_ARRAY_T
 
typedef struct M2MB_MDNS_CFG_S M2MB_MDNS_CFG_T
 MDNS cfg structure. More...
 
typedef struct M2MB_UDP_CFG_S M2MB_UDP_CFG_T
 UDP cfg structure. More...
 
typedef struct M2MB_UDP_CFG_ARRAY_S M2MB_UDP_CFG_ARRAY_T
 UDP cfg structure for the system. More...
 
typedef struct M2MB_PROFILE_SOC_RESULT M2MB_PROFILE_SOC_RESULT_T
 Socket for UDP & TCP initialization result. More...
 
typedef struct M2MB_T_CFG_S M2MB_T_CFG_T
 TCP cfg structure. More...
 
typedef struct M2MB_T_CFG_ARRAY_S M2MB_TCP_CFG_ARRAY_T
 TCP cfg structure for the system. More...
 
typedef struct M2MB_PROFILE_UART_CFG M2MB_PROFILE_UART_CFG_T
 UART configuration structure. More...
 
typedef struct M2MB_PROFILE_UART_OPEN_CB M2MB_PROFILE_UART_OPEN_CB_T
 UART initialization result. More...
 
typedef struct M2MB_PROFILE_UART_CB M2MB_PROFILE_UART_CB_T
 UART read and write callback data structure. More...
 
typedef struct M2MB_PROFILE_DBG_CFG_S M2MB_PROFILE_DBG_CFG_T
 Debug configuration structure. More...
 
typedef struct M2MB_PROFILE_XFP_CFG_S M2MB_PROFILE_XFP_CFG_T
 XFP configuration structure. More...
 
typedef struct M2MB_HTTPC_CGF_S M2MB_HTTPC_CFG_ARRAY_T
 HTTP client cfg structure. More...
 
typedef struct M2MB_HTTPD_PROFILE_CFG_S M2MB_HTTPD_PROFILE_CFG_T
 HTTP Server cfg structure. More...
 
typedef struct M2MB_HTTPD_PROFILE_URI_INFO_S M2MB_HTTPD_PROFILE_URI_INFO_T
 HTTP Server URI info structure. More...
 
typedef struct M2MB_HTTPD_PROFILE_URI_CFG_ARRAY_S M2MB_HTTPD_PROFILE_URI_CFG_ARRAY_T
 HTTP Server URI config structure. More...
 
typedef struct M2MB_HTTPD_PROFILE_S M2MB_HTTPD_PROFILE_T
 HTTP Server Profile cfg structure. More...
 
typedef struct M2MB_SNTP_CFG_S M2MB_SNTP_CFG_T
 SNTP client cfg structure. More...
 
typedef struct M2MB_RETRY_CFG_S M2MB_RETRY_CFG_T
 
typedef struct M2MB_PROFILE_GPIO_CFG_S M2MB_PROFILE_GPIO_CFG_T
 
typedef struct M2MB_PROFILE_GPIO_CFG_ARRAY_S M2MB_PROFILE_GPIO_CFG_ARRAY_T
 GPIO cfg structure for the system. More...
 
typedef struct M2MB_SYSTEM_CFG_S M2MB_SYSTEM_CFG_T
 System cfg structure. More...
 
UINT8m2mb_profile_event_str []
 
const M2MB_JSON_COMPLEX_OBJ_T system_schema
 
char * m2mb_get_profile_event_string (M2MB_PROFILE_EVENT_T event)
 
INT32 m2mb_profile_apply (const M2MB_SYSTEM_CFG_T *pCfg, M2MB_PROFILE_APPLY_CB_T cb)
 m2mb_profile_apply is called to apply the profile. More...
 
INT32 m2mb_profile_udp_soc_init (M2MB_UDP_CFG_T *udp_cfg)
 m2mb_profile_udp_soc_init is called to apply the profile related to UDP. More...
 
INT32 m2mb_profile_tcp_soc_init (M2MB_T_CFG_T *t_cfg)
 m2mb_profile_tcp_soc_init is called to apply the profile related to TCP. More...
 

Detailed Description

This section describes the M2MB APIs related to profile.

WE310F5_Profile.png
Profile

Profile module provides data types and APIs for the system configuration. The data types defined are compatible with the JSON schema for the JSON parser module. These structure can be used to store the configuration in the JSON format in the file system. The system_schema variable defines the schema for JSON which user can use for this purpose. User can define variable of data type M2MB_SYSTEM_CFG_T and set the system configuration and using the system_schema, can store the configuration to file system in JSON format as shown below:-

UINT8 buffer[BUFFER_LEN]; -> BUFFER_LEN should be large enough to store the JSON encoded values UINT32 length; M2MB_SYSTEM_CFG_T sys_profile; .............. set the configuration in the sys_profile; .............. return_status = m2mb_json_encode((M2MB_JSON_COMPLEX_OBJ_T *)&system_schema, ( UINT8* )&sys_profile, ( UINT8* )buffer, BUFFER_LEN, ( UINT32* )&length );

The buffer will contain the JSON formated configuration. User can use file system APIs to store the buffer content to a configuration file in the flash.

On boot up, user can extract the configuration to the sys_profile by decoding back the buffer content as shown below:

return_status = m2mb_json_decode( buffer, buffer + length, ( M2MB_JSON_COMPLEX_OBJ_T* )&system_schema, ( UINT8* )&sys_profile );

Here, the buffer contains the content read from the configuration file and length is the length of the configuration file.

It also provides the API to initialize the module based on the profile setting. User callback with the appropriate events and data gets called while initializing the modules.

Macro Definition Documentation

◆ DEFAULT_TCP_CLIENT

#define DEFAULT_TCP_CLIENT   2

Definition at line 92 of file m2mb_profile.h.

◆ DEFAULT_TCP_SERVER

#define DEFAULT_TCP_SERVER   1

Definition at line 91 of file m2mb_profile.h.

◆ DEFAULT_UDP_SOCKET

#define DEFAULT_UDP_SOCKET   3

Definition at line 93 of file m2mb_profile.h.

◆ M2M_HTTPD_PROFILE_ENABLE

#define M2M_HTTPD_PROFILE_ENABLE

Definition at line 95 of file m2mb_profile.h.

Typedef Documentation

◆ M2M_PROFILE_AP_SET_RESULT_T

AP structure used in user callback to update the status of AP initialization.

AP structure used in user callback to update the status of AP initialization.

◆ M2M_PROFILE_STA_SET_RESULT_T

STA structure used in user callback to update the status of STA initialization.

STA structure used in user callback to update the status of STA initialization.

◆ M2MB_AP_CFG_T

typedef struct M2MB_AP_CFG_S M2MB_AP_CFG_T

AP cfg structure.

AP cfg structure.

◆ M2MB_AP_WLAN_CFG_T

AP WLAN cfg structure.

AP WLAN cfg structure.

◆ M2MB_DHCP_SRV_CFG_T

DHCP server cfg structure.

DHCP server cfg structure.

◆ M2MB_DNS_HOST_CFG_ARRAY_T

Array of DNS host cfg structure.

Array of DNS host cfg structure.

◆ M2MB_DNS_HOST_CFG_T

DNS host cfg structure.

DNS host cfg structure. To add DNS host name and IP address pair to the list of DNS server database.

◆ M2MB_EAP_CONF_T

◆ M2MB_HTTPC_CFG_ARRAY_T

HTTP client cfg structure.

HTTP client cfg structure.

◆ M2MB_HTTPD_PROFILE_CFG_T

HTTP Server cfg structure.

HTTP Server cfg structure.

◆ M2MB_HTTPD_PROFILE_T

HTTP Server Profile cfg structure.

HTTP Server Profile cfg structure.

◆ M2MB_HTTPD_PROFILE_URI_CFG_ARRAY_T

HTTP Server URI config structure.

HTTP Server URI config structure.

◆ M2MB_HTTPD_PROFILE_URI_INFO_T

HTTP Server URI info structure.

HTTP Server URI info structure.

◆ M2MB_IP_CFG_T

typedef struct M2M_IP_CFG_S M2MB_IP_CFG_T

IP cfg structure.

IP cfg structure.

◆ M2MB_MDNS_CFG_T

MDNS cfg structure.

MDNS cfg structure.

◆ M2MB_MDNS_HOST_CFG_T

MDNS host cfg structure.

MDNS host cfg structure.

◆ M2MB_MDNS_SERVICE_CFG_ARRAY_T

◆ M2MB_MDNS_SERVICE_CFG_T

MDNS service cfg structure.

MDNS service structure.

◆ M2MB_POWER_SAVE_CFG_T

◆ M2MB_PROFILE_APPLY_CB_T

typedef M2MB_STATUS_T(* M2MB_PROFILE_APPLY_CB_T) (UINT8 device_id, M2MB_PROFILE_EVENT_T event, M2MB_STATUS_T status, VOID *pData)

Profile apply callback prototype.

Profile apply callback prototype. The pData pointer has to be interpreted based on the event.

Parameters
[in]device_idDevice ID in operation
[in]eventEvent of the profile apply
[in]statusStatus of the event
[in]pDataData related to event. User has to typecast to the appropriate structure based on the event passed in the event parameter. The structure to typecast to interpret the data is explained in the event enum:M2MB_PROFILE_EVENT_T.

m2mb_profile_apply(&pcfg, profile_apply_cb)/

M2MB_STATUS_T profile_apply_cb( UINT8 device_id,
M2MB_PROFILE_EVENT_T event, M2MB_STATUS_T status, VOID *pData )
{
INT32 ret = 0;
// Check for Error scenaiors for all events
if(status != M2MB_OK)
{
(af.app_cfg.init)( &af, event, status, NULL );
return ret;
}
switch( event )
{
{}
break;
}
}

Definition at line 215 of file m2mb_profile.h.

◆ M2MB_PROFILE_DBG_CFG_T

Debug configuration structure.

This structure is used configure the Debug module.

◆ M2MB_PROFILE_EVENT_T

Profile event enumeration.

Profile event enumeration, passed in user callback while applying profile.

◆ M2MB_PROFILE_GPIO_CFG_ARRAY_T

GPIO cfg structure for the system.

GPIO cfg structure for the system.

◆ M2MB_PROFILE_GPIO_CFG_T

◆ M2MB_PROFILE_SOC_RESULT_T

Socket for UDP & TCP initialization result.

This structure is used to notify user about the status of UDP & TCP socket initialization result.

◆ M2MB_PROFILE_UART_CB_T

UART read and write callback data structure.

This structure is used to notify user about the details of UART read and write callback.

◆ M2MB_PROFILE_UART_CFG_T

UART configuration structure.

UART configuration structure.

◆ M2MB_PROFILE_UART_OPEN_CB_T

UART initialization result.

This structure is used to notify user about the status of UART initialization result.

◆ M2MB_PROFILE_XFP_CFG_T

XFP configuration structure.

XFP configuration structure. If it is enabled XFP based FWUP can be done over the configured port.

◆ M2MB_RETRY_CFG_T

◆ M2MB_ROAMING_CFG_T

Roaming cfg structure.

Roaming cfg structure.

◆ M2MB_SNTP_CFG_T

SNTP client cfg structure.

SNTP client cfg structure.

◆ M2MB_STA_CFG_T

STA cfg structure.

STA cfg structure.

◆ M2MB_STA_SCAN_CFG_T

STA scan cfg structure.

STA scan cfg structure.

◆ M2MB_SYSTEM_CFG_T

System cfg structure.

System cfg structure.

◆ M2MB_T_CFG_T

typedef struct M2MB_T_CFG_S M2MB_T_CFG_T

TCP cfg structure.

TCP cfg structure.

◆ M2MB_TCP_CFG_ARRAY_T

TCP cfg structure for the system.

TCP cfg structure for the system.

◆ M2MB_UDP_CFG_ARRAY_T

UDP cfg structure for the system.

UDP cfg structure for the system.

◆ M2MB_UDP_CFG_T

UDP cfg structure.

UDP cfg structure.

◆ M2MB_WLAN_STA_CFG_ARRAY_T

Array of WLAN STATION configuration structure.

Array of WLAN STATION configuration structure.

◆ M2MB_WLAN_STA_CFG_T

WLAN sta structure.

WLAN sta structure.

Enumeration Type Documentation

◆ M2MB_PROFILE_EVENT

Profile event enumeration.

Profile event enumeration, passed in user callback while applying profile.

Enumerator
M2MB_PROFILE_DRV_UART_INIT_DONE 

Once UART is initialized. The callback data should be interpreted using M2MB_PROFILE_UART_OPEN_CB_T structure. Event is raised when data is received from the Debug UART port. The callback data is interpreted using M2MB_PROFILE_UART_CB_T structure

M2MB_PROFILE_UART0_READ_CB 

Event is raised when data is written to the Debug UART port. The callback data is interpreted using M2MB_PROFILE_UART_CB_T structure

M2MB_PROFILE_UART0_WRITE_CB 

Event is raised when data is received from the High Speed(HS) UART port. The callback data is interpreted using M2MB_PROFILE_UART_CB_T structure

M2MB_PROFILE_UART1_READ_CB 

Event is raised when data is written to the High Speed(HS) UART port. The callback data is interpreted using M2MB_PROFILE_UART_CB_T structure

M2MB_PROFILE_UART1_WRITE_CB 

Event is raised when DBG module is initialized. The callback data is set to NULL

M2MB_PROFILE_DBG_INIT_DONE 

Event is raised when XFP module is initialized. The callback data is set to NULL

M2MB_PROFILE_XFP_INIT_DONE 

Event is raised when WLAN AP mode is initialized. The callback data is points to status

M2MB_PROFILE_EVENT_AP_MODE_SET 

Event is raised when WLAN STA mode is initialized. The callback data is points to status

M2MB_PROFILE_EVENT_STA_MODE_SET 

Event is raised when DNS client module is initialized. The callback data is set to NULL

M2MB_PROFILE_EVENT_DNS_SET 

Event is raised when mDNS host name is set. The callback data points to the host name string

M2MB_PROFILE_EVENT_mDNS_HOSTNAME_SET 

Event is raised when mDNS service registration is done. The callback data points to the memory content of data type M2MB_MDNS_SVC_INFO_T

M2MB_PROFILE_EVENT_mDNS_SRV_REG_SET 

Event is raised when UDP configuration is done. The callback data points to the memory content of data type M2MB_PROFILE_SOC_RESULT_T

M2MB_PROFILE_EVENT_UDP_CFG_SET 

Event is raised when TCP configuration is done. The callback data points to the memory content of data type M2MB_PROFILE_SOC_RESULT_T

M2MB_PROFILE_EVENT_TCP_CFG_SET 

Event is raised when SNTP initialization is done. The callback data points to status

M2MB_PROFILE_EVENT_SNTP_INIT_DONE 

Event is raised when SNTP synchronization with the server is done. The callback data points to M2MB_SNTP_TM_T with the current time if the synchronization is success else point to NULL

M2MB_PROFILE_EVENT_SNTP_SYNC_DONE 

Indicates all initialization procedure completed

M2MB_PROFILE_EVENT_INIT_DONE 

Definition at line 106 of file m2mb_profile.h.

Function Documentation

◆ m2mb_get_profile_event_string()

char* m2mb_get_profile_event_string ( M2MB_PROFILE_EVENT_T  event)
inline

Definition at line 164 of file m2mb_profile.h.

◆ m2mb_profile_apply()

INT32 m2mb_profile_apply ( const M2MB_SYSTEM_CFG_T pCfg,
M2MB_PROFILE_APPLY_CB_T  cb 
)

m2mb_profile_apply is called to apply the profile.

m2mb_profile_apply initializes the system with the profile configuration given. Based on the profile, it starts configuring WLAN and sets up the network layer.

Parameters
[in]pCfgPointer to system configuration.
[in]cbUser callback for the the event handling.
Returns
returns status, 0 is success else negative value -1.
Note
This API has to be called with proper configuration. m2mb_profile_apply(&pcfg, profile_apply_cb);
M2MB_WLAN_STA_CFG_ARRAY_T sta_wireless_cfg =
{
.num_of_cfg = 1,
.wlan[0] =
{
.enable = 1,
.ssid = "Telit_test",
.pwd = "12345678",
.channel = 6
}
};
M2MB_SYSTEM_CFG_T pcfg = {0};
pcfg.sta.pWlan = &sta_wireless_cfg;
VOID profile_apply_cb(UINT8 device_id,
M2MB_PROFILE_EVENT_T event, M2MB_STATUS_T status, VOID *pData )
{
switch(event)
{
{
}
break;
}
}
int main()
{
INT32 ret;
pcfg.wlan_running_mode = 0; //STATION
ret = m2mb_profile_apply(&pcfg, profile_apply_cb);
return M2MB_OK;
}

◆ m2mb_profile_tcp_soc_init()

INT32 m2mb_profile_tcp_soc_init ( M2MB_T_CFG_T t_cfg)

m2mb_profile_tcp_soc_init is called to apply the profile related to TCP.

m2mb_profile_tcp_soc_init initializes the TCP socket with the given TCP configuration. Based on the profile, it starts configuring TCP socket and sets up the transport layer.

Parameters
[in]t_cfgPointer to TCP configuration.
Returns
Returns sd if success else negative value -1.
Note
This API has to be called with proper configuration. Example
M2MB_T_CFG_T t_cfg = {0};
t_cfg.enable = 0;
t_cfg.lport = 8366;
t_cfg.rport = 8377;
t_cfg.ip = MAKEIP(192,168,16,42);
int main()
{
INT32 ret;
ret = m2mb_profile_tcp_soc_init(&t_cfg );
return ret;
}

◆ m2mb_profile_udp_soc_init()

INT32 m2mb_profile_udp_soc_init ( M2MB_UDP_CFG_T udp_cfg)

m2mb_profile_udp_soc_init is called to apply the profile related to UDP.

m2mb_profile_udp_soc_init initializes the UDP socket with the given UDP configuration. Based on the profile, it starts configuring UDP socket and sets up the transport layer.

Parameters
[in]udp_cfgPointer to UDP configuration.
Returns
Returns sd if success else negative value -1.
Note
This API has to be called with proper configuration. m2mb_profile_udp_soc_init(&udp_cfg );
M2MB_UDP_CFG_T udp_cfg = {0};
udp_cfg.enable = 0;
udp_cfg.lport = 8366;
int main()
{
INT32 ret;
ret = m2mb_profile_udp_soc_init(&udp_cfg );
return ret;
}

Variable Documentation

◆ m2mb_profile_event_str

UINT8* m2mb_profile_event_str[]

◆ system_schema

const M2MB_JSON_COMPLEX_OBJ_T system_schema