WE310F5  39.00.000
M2MB Application Framework

This section describes the M2MB APIs for the application framework. More...

#define M2MB_AF_MAX_USER_THREAD_SUPPORTED   10
 
#define TEST_START   "\r\nEXAMPLE APPLICATION TEST START\r\n"
 
#define TEST_COMPLETE   "\r\nEXAMPLE APPLICATION TEST COMPLETE\r\n"
 
#define TEST_COMPLETE_COUNT   5
 
enum  M2MB_AF_NWK_EVENT {
  M2MB_AF_NWK_DATA_RECEVEID = 1,
  M2MB_AF_NWK_CONNECTION_CLOSE,
  M2MB_AF_NWK_NEW_CONNECTION
}
 Application framework network event. More...
 
enum  M2MB_AF_DRV_TYPE {
  M2MB_AF_DRV_TYPE_UART0,
  M2MB_AF_DRV_TYPE_UART1
}
 Application framework driver type. More...
 
typedef enum M2MB_AF_NWK_EVENT M2MB_AF_NWK_EVENT_E
 Application framework network event. More...
 
typedef enum M2MB_AF_DRV_TYPE M2MB_AF_DRV_TYPE_E
 Application framework driver type. More...
 
typedef VOID(* M2MB_AF_INIT_CB_T) (VOID *user_ctx, M2MB_PROFILE_EVENT_T event, M2MB_STATUS_T status, VOID *pData)
 Application framework user init callback function prototype. More...
 
typedef VOID(* M2MB_AF_DRV_RD_CB_T) (VOID *user_ctx, M2MB_AF_DRV_TYPE_E module_type, VOID *pData, UINT32 len)
 Application framework Driver read callback function prototype. More...
 
typedef struct M2MB_AF_NWK_DATA_RECV M2MB_AF_NWK_DATA_RECV_T
 Application framework Network data receive structure. More...
 
typedef VOID(* M2MB_AF_NWK_EV_CB_T) (VOID *user_ctx, UINT32 sd, M2MB_AF_NWK_EVENT_E ev, VOID *pData)
 Application framework Network event callback function prototype. More...
 
typedef struct M2MB_AF_APP_THREAD_S M2MB_AF_APP_THREAD_T
 APP thread information. More...
 
typedef VOID(* M2MB_AF_THREAD_PROCESS_T) (VOID *user_ctx, M2MB_AF_APP_THREAD_T *pTCtx, VOID *pMsg)
 Application framework thread message processing function prototype. More...
 
typedef struct M2M_AF_USER_THREAD_DETAILS_S M2M_AF_USER_THREAD_DETAILS_T
 Application framework thread details structure. More...
 
typedef struct M2M_AF_USER_THREAD_CFG_S M2M_AF_USER_THREAD_CFG_T
 Application framework user thread system configuration. More...
 
typedef struct M2MB_AF_USER_CFG_S M2MB_AF_USER_CFG_T
 Application framework User configuration detail structure. More...
 
VOID m2mb_af_dbg_print (M2MB_SYSTEM_CFG_T *pSystemCfg)
 m2mb_af_dbg_print is called to print the Access point SSID and channel information based on WLAN running mode. More...
 
INT32 m2mb_af_udp_soc_init (M2MB_UDP_CFG_T *udp_cfg)
 m2mb_af_udp_soc_init is called to initialize UDP socket creation. More...
 
INT32 m2mb_af_tcp_soc_init (M2MB_T_CFG_T *tcp_cfg)
 m2mb_af_tcp_soc_init is called to initialize TCP socket creation. More...
 
INT32 m2mb_af_start (M2MB_AF_USER_CFG_T *pApp_cfg, const M2MB_SYSTEM_CFG_T *pSystem_cfg)
 m2mb_af_start is called to start the application framework. More...
 

Detailed Description

This section describes the M2MB APIs for the application framework.

The Application framework provides a basic framework for the user to develop its application. Application framework provides the following features:-

Macro Definition Documentation

◆ M2MB_AF_MAX_USER_THREAD_SUPPORTED

#define M2MB_AF_MAX_USER_THREAD_SUPPORTED   10

Definition at line 53 of file m2mb_app_framework.h.

◆ TEST_COMPLETE

#define TEST_COMPLETE   "\r\nEXAMPLE APPLICATION TEST COMPLETE\r\n"

Definition at line 55 of file m2mb_app_framework.h.

◆ TEST_COMPLETE_COUNT

#define TEST_COMPLETE_COUNT   5

Definition at line 56 of file m2mb_app_framework.h.

◆ TEST_START

#define TEST_START   "\r\nEXAMPLE APPLICATION TEST START\r\n"

Definition at line 54 of file m2mb_app_framework.h.

Typedef Documentation

◆ M2M_AF_USER_THREAD_CFG_T

Application framework user thread system configuration.

User thread configuration details structure.

◆ M2M_AF_USER_THREAD_DETAILS_T

Application framework thread details structure.

Structure to give thread details.

◆ M2MB_AF_APP_THREAD_T

APP thread information.

This data structure stores the thread handlers details. To post a message to the thread user can use the pQHandle and OS APIs. To get details on thread thrHandle can be used .

◆ M2MB_AF_DRV_RD_CB_T

typedef VOID(* M2MB_AF_DRV_RD_CB_T) (VOID *user_ctx, M2MB_AF_DRV_TYPE_E module_type, VOID *pData, UINT32 len)

Application framework Driver read callback function prototype.

Driver read callback function prototype.user_ctx is the context given in M2MB_AF_USER_CFG_T (pUsr_ctx). module_type is the type of driver, pData is the pointer to data and len is the length of data received. The user has to process the data fast as the pData buffer is reused to read the data from the driver.

Definition at line 112 of file m2mb_app_framework.h.

◆ M2MB_AF_DRV_TYPE_E

Application framework driver type.

Driver type supported by the application framework.

◆ M2MB_AF_INIT_CB_T

typedef VOID(* M2MB_AF_INIT_CB_T) (VOID *user_ctx, M2MB_PROFILE_EVENT_T event, M2MB_STATUS_T status, VOID *pData)

Application framework user init callback function prototype.

User init callback function prototype. user_ctx is the context given in M2MB_AF_USER_CFG_T (pUsr_ctx). Events are defined in the m2mb_profile.h file. the pData depends on the event as described in the memb_profile.h file.

Definition at line 96 of file m2mb_app_framework.h.

◆ M2MB_AF_NWK_DATA_RECV_T

Application framework Network data receive structure.

This structure is used to indicate the data received for a socket.

◆ M2MB_AF_NWK_EV_CB_T

typedef VOID(* M2MB_AF_NWK_EV_CB_T) (VOID *user_ctx, UINT32 sd, M2MB_AF_NWK_EVENT_E ev, VOID *pData)

Application framework Network event callback function prototype.

Network event callback function prototype. The pData is of type M2MB_AF_NWK_DATA_RECEVEID when event is M2MB_AF_NWK_DATA_RECEVEID and M2MB_SOCKET_BSD_SOCKADDR_IN_T when event is M2MB_AF_NWK_NEW_CONNECTION.

Definition at line 140 of file m2mb_app_framework.h.

◆ M2MB_AF_NWK_EVENT_E

Application framework network event.

Event for the network activity. This event is passed M2MB_AF_NWK_EV_CB_T callback

◆ M2MB_AF_THREAD_PROCESS_T

typedef VOID(* M2MB_AF_THREAD_PROCESS_T) (VOID *user_ctx, M2MB_AF_APP_THREAD_T *pTCtx, VOID *pMsg)

Application framework thread message processing function prototype.

Thread message processing function prototype.

Definition at line 169 of file m2mb_app_framework.h.

◆ M2MB_AF_USER_CFG_T

Application framework User configuration detail structure.

User configuration detail structure.

Enumeration Type Documentation

◆ M2MB_AF_DRV_TYPE

Application framework driver type.

Driver type supported by the application framework.

Enumerator
M2MB_AF_DRV_TYPE_UART0 
M2MB_AF_DRV_TYPE_UART1 

Definition at line 79 of file m2mb_app_framework.h.

◆ M2MB_AF_NWK_EVENT

Application framework network event.

Event for the network activity. This event is passed M2MB_AF_NWK_EV_CB_T callback

Enumerator
M2MB_AF_NWK_DATA_RECEVEID 
M2MB_AF_NWK_CONNECTION_CLOSE 
M2MB_AF_NWK_NEW_CONNECTION 

Definition at line 65 of file m2mb_app_framework.h.

Function Documentation

◆ m2mb_af_dbg_print()

VOID m2mb_af_dbg_print ( M2MB_SYSTEM_CFG_T pSystemCfg)

m2mb_af_dbg_print is called to print the Access point SSID and channel information based on WLAN running mode.

m2mb_af_dbg_print is called to print the Access point SSID and channel information based on WLAN running mode.

Parameters
[in]pSystemCfgPointer to System configuration structure.
Returns
Returns status.
Note
This API can be called if debug module is initalized in the application. Example
//Get the System configurations
extern M2MB_SYSTEM_CFG_T * pSystemCfg;
static void tea_af_init_cb( void *user_ctx, UINT32 event, M2MB_STATUS_T status, void* pData)
{
...
...
m2mb_af_dbg_print(pSystemCfg);
...
...
}
int main()
{
// User configuration structure
M2MB_AF_USER_CFG_T App_cfg = {0};
...
...
// Application Framework init callback
App_cfg.init = (M2MB_AF_INIT_CB_T)tea_af_init_cb;
...
...
// Initialize the platform, with Debug Enabled and get the inputs
system_cfg.dbg_cfg.d_cfg.enableCI = FALSE;
...
...
// Start the Application Frame Work
m2mb_af_start( &App_cfg, &system_cfg );
...
...
}

◆ m2mb_af_start()

INT32 m2mb_af_start ( M2MB_AF_USER_CFG_T pApp_cfg,
const M2MB_SYSTEM_CFG_T pSystem_cfg 
)

m2mb_af_start is called to start the application framework.

m2mb_af_start starts the application framework. It initializes the different modules based on the profile configuration and creates threads as per the configuration given by the user.

Returns
Returns status.
Note

Example

//Get the System configurations
extern M2MB_SYSTEM_CFG_T * pSystemCfg;
static void tea_af_init_cb( void *user_ctx, UINT32 event, M2MB_STATUS_T status, void* pData)
{
...
...
m2mb_af_dbg_print(pSystemCfg);
...
...
}
int main()
{
// User configuration structure
M2MB_AF_USER_CFG_T App_cfg = {0};
...
...
// Application Framework init callback
App_cfg.init = (M2MB_AF_INIT_CB_T)tea_af_init_cb;
...
...
// Initialize the platform, with Debug Enabled and get the inputs
system_cfg.dbg_cfg.d_cfg.enableCI = FALSE;
...
...
// Start the Application Frame Work
m2mb_af_start( &App_cfg, &system_cfg );
...
...
}

◆ m2mb_af_tcp_soc_init()

INT32 m2mb_af_tcp_soc_init ( M2MB_T_CFG_T tcp_cfg)

m2mb_af_tcp_soc_init is called to initialize TCP socket creation.

It takes TCP configuration, finds free entry in pTcp_soc array and calls m2mb_profile_tcp_soc_init() to create socket.

Returns
Returns status.
Note

Example

M2MB_T_CFG_T tcp_cfg;
tcp_cfg.enable = TRUE;
tcp_cfg.lport = m2mb_socket_bsd_htons(1234);
m2mb_socket_bsd_inet_pton( M2MB_SOCKET_BSD_AF_INET4, "192.168.1.1", &tcp_cfg.ip );
tcp_cfg.rport = m2mb_socket_bsd_htons(5678);
if( M2MB_OK == m2mb_af_tcp_soc_init( &tcp_cfg ))
m2mb_dbg_consol_print("TCP SOCKET CREATED AND CONNECTED TO SERVER\r\n"");
else
m2mb_dbg_consol_print("TCP SOCKET FAIL\r\n"");

◆ m2mb_af_udp_soc_init()

INT32 m2mb_af_udp_soc_init ( M2MB_UDP_CFG_T udp_cfg)

m2mb_af_udp_soc_init is called to initialize UDP socket creation.

It takes UDP configuration, finds free entry in pUdp_soc array and calls m2mb_profile_udp_soc_init() to create socket.

Returns
Returns status.
Note

Example

M2MB_UDP_CFG_T udp_cfg;
udp_cfg.enable = TRUE;
udp_cfg.port = m2mb_socket_bsd_htons(1234);
if( M2MB_OK == m2mb_af_udp_soc_init( &udp_cfg ))
m2mb_dbg_consol_print("UDP SOCKET CREATED\r\n"");
else
m2mb_dbg_consol_print("UDP SOCKET CREATION FAILED\r\n"");