WE310F5  39.00.000

This section describes the M2MB APIs to perform various Network Connection Manager(NCM) operations. More...

#define M2MB_NCM_FLAG_KEEP_ALIVE   ( 1 << 0 )
 
#define M2MB_NCM_FLAG_DYNAMIC_KEEP_ALIVE   ( 1 << 1 )
 
#define M2MB_NCM_FLAG_ROAMING   ( 1 << 2 )
 
#define M2MB_NCM_FLAG_WITH_STAT   ( 1 << 3 )
 
#define M2MB_WPS_PIN_LENGTH   8
 
#define M2MB_SECURITY_KEY_LENGTH_MAX   64
 
enum  M2MB_NCM_CTX_STATES {
  M2MB_NCM_STATE_NOT_INITIALISED,
  M2MB_NCM_STATE_INITIALISED,
  M2MB_NCM_STATE_L2_DISCONNECTING,
  M2MB_NCM_STATE_L2_DISCONNECTED,
  M2MB_NCM_STATE_L2_CONCT_TO_KNOWN_AP,
  M2MB_NCM_STATE_L2_SCAN_KNOWN_CHNL,
  M2MB_NCM_STATE_L2_SCAN_SPECIFIC_CHNL,
  M2MB_NCM_STATE_L2_SCAN_ALL_CHNL,
  M2MB_NCM_STATE_L2_CONNECTED,
  M2MB_NCM_STATE_L3_CONNECTED,
  M2MB_NCM_STATE_IDLE,
  M2MB_NCM_STATE_L3_IP_FAIL
}
 Different states in NCM module. More...
 
enum  M2MB_NCM_IPFLAG_SETTING_E {
  M2MB_NCM_IPFLAG_V4_STATIC = (1 << 0),
  M2MB_NCM_IPFLAG_V4_DHCP = (1 << 1),
  M2MB_NCM_IPFLAG_V6_AUTO = (1 << 2),
  M2MB_NCM_IPFLAG_V6_DHCP = (1 << 3)
}
 IP configuration. More...
 
enum  M2MB_L2_L3_NCM_EVENTS_ID_E {
  M2MB_NCM_L2_DISASSOC_DONE,
  M2MB_NCM_L2_RESTART,
  M2MB_NCM_L2_SCAN_DONE,
  M2MB_NCM_L2_SCAN_FAIL,
  M2MB_NCM_L2_CONNECT_FAIL,
  M2MB_NCM_L2_CONNECT_DONE,
  M2MB_NCM_L3_CONNECT_DONE,
  M2MB_NCM_L3_DISCONNECT,
  M2MB_NCM_L3_CONNECT_FAIL,
  M2MB_NCM_L2_AP_START_DONE,
  M2MB_NCM_L3_AP_START_DONE,
  M2MB_NCM_L3_AP_START_FAIL,
  M2MB_NCM_L2_PNO_PROFILE_DONE,
  M2MB_NCM_AP_STOP_DONE,
  M2MB_NCM_L3_AUTO_IP_DONE,
  M2MB_NCM_L3_NEW_IP_DONE,
  M2MB_NCM_L3_CLIENT_CONNECTED,
  M2MB_NCM_L3_CLIENT_DISCONNECTED
}
 Events from NCM module. More...
 
enum  M2MB_NCM_CFG_OPCODE_E {
  M2MB_NCM_CFG_OPCODE_AP_PROFILE,
  M2MB_NCM_CFG_OPCODE_AP_CFG,
  M2MB_NCM_CFG_OPCODE_STA_PROFILE,
  M2MB_NCM_CFG_OPCODE_STA_RETRY,
  M2MB_NCM_CFG_OPCODE_IP_CFG,
  M2MB_NCM_CFG_OPCODE_DNS_CFG,
  M2MB_NCM_CFG_OPCODE_DHCP_SERVER_CFG,
  M2MB_NCM_CFG_OPCODE_STA_ROAMING,
  M2MB_NCM_CFG_OPCODE_STAT_GET,
  M2MB_NCM_CFG_OPCODE_CLIENT_GET,
  M2MB_NCM_CFG_OPCODE_INTERFACE_GET,
  M2MB_NCM_CFG_OPCODE_STA_WPS_CFG,
  M2MB_NCM_CFG_OPCODE_STA_POWER_SAVE_CFG,
  M2MB_NCM_AP_MODE_CONNECTED_STA_INFO,
  M2MB_NCM_AP_MODE_DISCONNECTED_STA_INFO,
  M2MB_NCM_MODE_L2_ONLY
}
 Opcode to be used in configuration API. More...
 
enum  M2MB_NCM_INIT_MODE_E {
  M2MB_NCM_MODE_STATION,
  M2MB_NCM_MODE_AP,
  M2MB_NCM_MODE_BOTH
}
 Different modes. More...
 
enum  M2MB_DISASSOC_REASON_T {
  M2MB_WLAN_NO_NETWORK_AVAIL = 0x01,
  M2MB_WLAN_LOST_LINK = 0x02,
  M2MB_WLAN_DISCONNECT_CMD = 0x03,
  M2MB_WLAN_BSS_DISCONNECTED = 0x04,
  M2MB_WLAN_AUTH_FAILED = 0x05,
  M2MB_WLAN_ASSOC_FAILED = 0x06,
  M2MB_WLAN_NO_RESOURCES_AVAIL = 0x07,
  M2MB_WLAN_CSERV_DISCONNECT = 0x08,
  M2MB_WLAN_INVALID_PROFILE = 0x0a,
  M2MB_WLAN_DOT11H_CHANNEL_SWITCH = 0x0b,
  M2MB_WLAN_PROFILE_MISMATCH = 0x0c,
  M2MB_WLAN_CONNECTION_EVICTED = 0x0d,
  M2MB_WLAN_IBSS_MERGE = 0x0e,
  M2MB_WLAN_EXCESS_TX_RETRY = 0x0f,
  M2MB_WLAN_SEC_HS_TO_RECV_M1 = 0x10,
  M2MB_WLAN_SEC_HS_TO_RECV_M3 = 0x11,
  M2MB_WLAN_TKIP_COUNTERMEASURES = 0x12,
  M2MB_WLAN_SCAN_FAIL = 0x13,
  M2MB_L3_FAIL = 0x14
}
 Disconnection reason. More...
 
typedef enum M2MB_NCM_CTX_STATES M2MB_NCM_CTX_STATES_E
 Different states in NCM module. More...
 
typedef struct M2MB_NCM_AP_PROFILE M2MB_NCM_AP_PROFILE_T
 AP profile information. More...
 
typedef struct M2MB_NCM_STA_CFG M2MB_NCM_STA_CFG_T
 STA mode configuration information. More...
 
typedef struct M2MB_NCM_WPS_CFG M2MB_NCM_WPS_CFG_T
 Station mode WPS configuration information. More...
 
typedef struct M2MB_NCM_POWER_SAVE_CFG M2MB_NCM_POWER_SAVE_CFG_T
 
typedef struct M2MB_NCM_AP_CFG M2MB_NCM_AP_CFG_T
 AP mode configuration information. More...
 
typedef struct M2MB_NCM_DHCP_SERVER_CFG M2MB_NCM_DHCP_SERVER_CFG_T
 DHCP server configuration for the device in AP mode. More...
 
typedef struct M2MB_NCM_IP_CFG M2MB_NCM_IP_CFG_T
 Generic IP configuration. More...
 
typedef struct M2MB_NCM_IFCFG M2MB_NCM_IFCFG_T
 Network Connect Manager Interface configuration. More...
 
typedef struct M2MB_NCM_RETRY_CFG M2MB_NCM_RETRY_CFG_T
 Retry configuration. More...
 
typedef struct M2MB_NCM_ROAMING_CFG M2MB_NCM_ROAMING_CFG_T
 Roaming configuration. More...
 
typedef struct M2MB_NCM_DEVICE_STATS M2MB_NCM_DEVICE_STATS_T
 Packet count statistics. More...
 
typedef struct M2MB_NCM_CONNECTED_STA_INFO M2MB_NCM_CONNECTED_STA_INFO_T
 Connected station information. More...
 
typedef union M2MB_NCM_CFG_PTR M2MB_NCM_CFG_PTR_T
 Configuration pointer union. More...
 
typedef VOID(* M2MB_NCM_CB_T) (UINT8 device_id, UINT8 event, INT32 status_code, VOID *cb_Ctx)
 NCM module user callback prototype. More...
 
typedef VOID(* M2MB_NCM_SCAN_CB_T) (UINT8 device_id, UINT8 event_id, INT32 status, VOID *data)
 
UINT8 m2mb_ncm_init (UINT8 mode, UINT8 bandwidth, M2MB_NCM_CB_T cb, VOID *cb_ctx)
 NCM module initialization. More...
 
INT32 m2mb_ncm_get_cfg (UINT8 handle, M2MB_NCM_CFG_OPCODE_E opCode, M2MB_NCM_CFG_PTR_T *p)
 This API is used to get different configurations of NCM module. More...
 
INT32 m2mb_ncm_set_cfg (UINT8 handle, M2MB_NCM_CFG_OPCODE_E opCode, M2MB_NCM_CFG_PTR_T *p)
 This API is used to set the different configurations in NCM module. More...
 
INT32 m2mb_ncm_register_cb (UINT8 handle, M2MB_NCM_CB_T m2mb_ncm_cb, VOID *Ctx)
 This API is used to register application callback in NCM module. More...
 
INT32 m2mb_ncm_start (UINT8 handle)
 This API is used to start the NCM module after initialization. More...
 
INT32 m2mb_ncm_stop (UINT8 handle)
 Disconnect or Down the NCM module. More...
 
INT32 m2mb_ncm_deregister_cb (UINT8 handle)
 This API is used to deregister the user callback in NCM module. More...
 
M2MB_STATUS_T m2mb_ncm_deinit (UINT8 handle)
 This API is used to deintializes the NCM module. More...
 
UINT32 m2mb_ncm_check_handle_init (UINT32 handle)
 This API is used to check the handle is initialized or not. More...
 
INT32 m2mb_ncm_get_state (UINT8 device_id)
 Current state of NCM module. More...
 
INT32 m2mb_ncm_scan (UINT8 device_id, UINT8 *ssid, UINT8 no_of_channels, UINT8 *channel_list, UINT8 scan_type, UINT32 num_of_scan_entries, M2MB_WLAN_BSS_SCAN_INFO_T *scanentries, M2MB_NCM_SCAN_CB_T m2m_ncm_scan_cb, VOID *usr_ctx)
 This API is used to get the WLAN scan results. This API expects m2mb_ncm_init prior to it in STA mode. More...
 

Detailed Description

This section describes the M2MB APIs to perform various Network Connection Manager(NCM) operations.

Network Connection Manager handles both L2 and L3 level network connection for both Station (STA) and Access Point (AP) mode.

WE310F5_NCM_STA.png
NCM Station Mode

To connect to an AP (in STA mode), use the following API sequence:

WE310F5_NCM_AP.png
NCM AP Mode

To start an AP, use the following API sequence:

Macro Definition Documentation

◆ M2MB_NCM_FLAG_DYNAMIC_KEEP_ALIVE

#define M2MB_NCM_FLAG_DYNAMIC_KEEP_ALIVE   ( 1 << 1 )

Flag to learn the keep alive time dynamically and using it to maintain connection

Definition at line 105 of file m2mb_ncm.h.

◆ M2MB_NCM_FLAG_KEEP_ALIVE

#define M2MB_NCM_FLAG_KEEP_ALIVE   ( 1 << 0 )

Flag for keep alive feature

Definition at line 104 of file m2mb_ncm.h.

◆ M2MB_NCM_FLAG_ROAMING

#define M2MB_NCM_FLAG_ROAMING   ( 1 << 2 )

Flag for roaming feature

Definition at line 107 of file m2mb_ncm.h.

◆ M2MB_NCM_FLAG_WITH_STAT

#define M2MB_NCM_FLAG_WITH_STAT   ( 1 << 3 )

Flag for storing NCM stat

Definition at line 108 of file m2mb_ncm.h.

◆ M2MB_SECURITY_KEY_LENGTH_MAX

#define M2MB_SECURITY_KEY_LENGTH_MAX   64

Definition at line 111 of file m2mb_ncm.h.

◆ M2MB_WPS_PIN_LENGTH

#define M2MB_WPS_PIN_LENGTH   8

Definition at line 110 of file m2mb_ncm.h.

Typedef Documentation

◆ M2MB_NCM_AP_CFG_T

AP mode configuration information.

This data structure allows the application to set AP configuration information used in AP mode.
This data structure should be used to get/set the AP configuration by calling m2mb_ncm_get/set_cfg using opcode M2MB_NCM_CFG_OPCODE_AP_CFG.

◆ M2MB_NCM_AP_PROFILE_T

AP profile information.

This data structure allows the application to set AP profile information to search to connect to the network.
This data structure should be used to get/set the AP profile configuration by calling m2mb_ncm_get/set_cfg using opcode M2MB_NCM_CFG_OPCODE_AP_PROFILE.

◆ M2MB_NCM_CB_T

typedef VOID(* M2MB_NCM_CB_T) (UINT8 device_id, UINT8 event, INT32 status_code, VOID *cb_Ctx)

NCM module user callback prototype.

Type definition of user callback to handle events received from NCM module.
Events are defined in M2MB_L2_L3_NCM_EVENTS_ID_E.

Definition at line 645 of file m2mb_ncm.h.

◆ M2MB_NCM_CFG_PTR_T

Configuration pointer union.

This union allows the application to pass pointer to the get/set API.
This union should be used to get/set various NCM configuration by calling m2mb_ncm_get/set_cfg.

Note
Some of the members are only used to get the configurations.

◆ M2MB_NCM_CONNECTED_STA_INFO_T

Connected station information.

This structure is used to get the connected station information .
This structure should be used to get connected station information by calling m2mb_ncm_get with M2MB_NCM_CFG_OPCODE_CLIENT_GET flag.

◆ M2MB_NCM_CTX_STATES_E

Different states in NCM module.

This enumeration will be helpful in tracking the NCM module state

◆ M2MB_NCM_DEVICE_STATS_T

Packet count statistics.

Data structure that represents WLAN statistics information.

This data structure contains counts of various types of packets transmitted/received on the particular device ID and also the active and power save time.

This data structure should be used only to get the statistics by calling m2mb_ncm_get using opcode M2MB_NCM_CFG_OPCODE_STAT_GET.

◆ M2MB_NCM_DHCP_SERVER_CFG_T

DHCP server configuration for the device in AP mode.

This data structure allows the application to set DHCP server configuration information used in AP mode.
This data structure should be used to get/set the AP configuration by calling m2mb_ncm_get/set_cfg using opcode M2MB_NCM_CFG_OPCODE_DHCP_SERVER_CFG.

◆ M2MB_NCM_IFCFG_T

Network Connect Manager Interface configuration.

This data structure allows the application to get the interface information.
This data structure should be used to get the interface configuration by calling m2mb_ncm_get using opcode M2MB_NCM_CFG_OPCODE_INTERFACE_GET.

◆ M2MB_NCM_IP_CFG_T

Generic IP configuration.

This data structure allows the application to set or get IP configuration information. Both AP and STA modes supported
This data structure should be used to get/set the generic IP configuration by calling m2mb_ncm_get/set_cfg using opcode M2MB_NCM_CFG_OPCODE_IP_CFG.

◆ M2MB_NCM_POWER_SAVE_CFG_T

◆ M2MB_NCM_RETRY_CFG_T

Retry configuration.

This data structure allows the application to set retry configuration for both WLAN and IP layer connection.
This data structure should be used to get/set the retry configuration by calling m2mb_ncm_get/set_cfg using opcode M2MB_NCM_CFG_OPCODE_STA_RETRY.

◆ M2MB_NCM_ROAMING_CFG_T

Roaming configuration.

This data structure allows the application to set roaming configuration WLAN layer connection.
This data structure should be used to get/set the retry configuration by calling m2mb_ncm_get/set_cfg using opcode M2MB_NCM_CFG_OPCODE_STA_ROAMING.

◆ M2MB_NCM_SCAN_CB_T

typedef VOID(* M2MB_NCM_SCAN_CB_T) (UINT8 device_id, UINT8 event_id, INT32 status, VOID *data)

Definition at line 646 of file m2mb_ncm.h.

◆ M2MB_NCM_STA_CFG_T

STA mode configuration information.

This data structure allows the application to set STA configuration information used in STA mode.
This data structure should be used to get/set the Station mode configuration by calling m2mb_ncm_get/set_cfg using opcode M2MB_NCM_CFG_OPCODE_STA_PROFILE.

◆ M2MB_NCM_WPS_CFG_T

Station mode WPS configuration information.

This data structure allows the application to set STA WPS configuration information used in STA mode.
This data structure should be used to get/set the Station mode WPS configuration by calling m2mb_ncm_get/set_cfg using opcode M2MB_NCM_CFG_OPCODE_STA_WPS_CFG.

Enumeration Type Documentation

◆ M2MB_DISASSOC_REASON_T

Disconnection reason.

Identifies the disconnection reason.

Enumerator
M2MB_WLAN_NO_NETWORK_AVAIL 

No network available.

M2MB_WLAN_LOST_LINK 

Missed beacons.

M2MB_WLAN_DISCONNECT_CMD 

User disconnect command.

M2MB_WLAN_BSS_DISCONNECTED 

BSS disconnected.

M2MB_WLAN_AUTH_FAILED 

Authentication failed.

M2MB_WLAN_ASSOC_FAILED 

Association failed.

M2MB_WLAN_NO_RESOURCES_AVAIL 

No resources available.

M2MB_WLAN_CSERV_DISCONNECT 

Disconnection due to connection services.

M2MB_WLAN_INVALID_PROFILE 

RSNA failure.

M2MB_WLAN_DOT11H_CHANNEL_SWITCH 

802.11h channel switch.

M2MB_WLAN_PROFILE_MISMATCH 

Profile mismatched.

M2MB_WLAN_CONNECTION_EVICTED 

Connection evicted.

M2MB_WLAN_IBSS_MERGE 

Disconnection due to merging of IBSS.

M2MB_WLAN_EXCESS_TX_RETRY 

TX frames failed after excessive retries.

M2MB_WLAN_SEC_HS_TO_RECV_M1 

Security 4-way handshake timed out waiting for M1.

M2MB_WLAN_SEC_HS_TO_RECV_M3 

Security 4-way handshake timed out waiting for M3.

M2MB_WLAN_TKIP_COUNTERMEASURES 

TKIP counter-measures.

M2MB_WLAN_SCAN_FAIL 

scan fail

M2MB_L3_FAIL 

L3 FAIL

Definition at line 490 of file m2mb_ncm.h.

◆ M2MB_L2_L3_NCM_EVENTS_ID_E

Events from NCM module.

This enum defines macros for different types of events from NCM in connection process and is helpful to user applications.

Note
This enum will be used internally by the NCM module.
Enumerator
M2MB_NCM_L2_DISASSOC_DONE 

NCM event for L2 disassociation, STA

M2MB_NCM_L2_RESTART 

NCM event for L2 restart, STA

M2MB_NCM_L2_SCAN_DONE 

NCM event for scan complete for L2 connection, STA

M2MB_NCM_L2_SCAN_FAIL 

NCM event for scan fail before L2 connection, STA

M2MB_NCM_L2_CONNECT_FAIL 

NCM event for L2 connection fail, STA

M2MB_NCM_L2_CONNECT_DONE 

NCM event for L2 connection done, STA

M2MB_NCM_L3_CONNECT_DONE 

Event for L3 connection done after L2 connection, STA

M2MB_NCM_L3_DISCONNECT 

L3 disconnect event in NCM module, STA

M2MB_NCM_L3_CONNECT_FAIL 

NCM event for L3 connection fail during connection process, STA

M2MB_NCM_L2_AP_START_DONE 

NCM event for device in AP mode for L2 connection successfully

M2MB_NCM_L3_AP_START_DONE 

NCM event for device in AP mode for L3 connection successfully

M2MB_NCM_L3_AP_START_FAIL 

NCM event for device in AP mode, L3 fail

M2MB_NCM_L2_PNO_PROFILE_DONE 

NCM event for PNO profile operation, Not implemented

M2MB_NCM_AP_STOP_DONE 

Event for AP mode, stop successfully

M2MB_NCM_L3_AUTO_IP_DONE 

L3 auto IP configuration in STA mode

M2MB_NCM_L3_NEW_IP_DONE 

IP renewal with new IP address

M2MB_NCM_L3_CLIENT_CONNECTED 

Ncm even when a client is connected in AP mode

M2MB_NCM_L3_CLIENT_DISCONNECTED 

Ncm even when a client is disconnected in AP mode

Definition at line 170 of file m2mb_ncm.h.

◆ M2MB_NCM_CFG_OPCODE_E

Opcode to be used in configuration API.

This enum is used in m2m_ncm_cfg.
This data type should be used to set/get the configuration for both in AP and STA mode.

Enumerator
M2MB_NCM_CFG_OPCODE_AP_PROFILE 

Used to GET/SET the AP profile info. Both STA and AP modes M2MB_NCM_AP_PROFILE_T

M2MB_NCM_CFG_OPCODE_AP_CFG 

AP configuration setting M2MB_NCM_AP_CFG_T

M2MB_NCM_CFG_OPCODE_STA_PROFILE 

STA profile setting M2MB_NCM_STA_CFG_T

M2MB_NCM_CFG_OPCODE_STA_RETRY 

Retry configuration. M2MB_NCM_RETRY_CFG_T

M2MB_NCM_CFG_OPCODE_IP_CFG 

IP configuration. M2MB_NCM_IP_CFG_T

M2MB_NCM_CFG_OPCODE_DNS_CFG 

DNS configuration

M2MB_NCM_CFG_OPCODE_DHCP_SERVER_CFG 

DHCP server configuration. M2MB_NCM_DHCP_SERVER_CFG_T

M2MB_NCM_CFG_OPCODE_STA_ROAMING 

Roaming configuration

M2MB_NCM_CFG_OPCODE_STAT_GET 

WLAN statistics. only GET. M2MB_NCM_DEVICE_STATS_T

M2MB_NCM_CFG_OPCODE_CLIENT_GET 

Used to get the connected client info when the device is in AP mode

M2MB_NCM_CFG_OPCODE_INTERFACE_GET 

Interface configuration. Only GET. M2MB_NCM_IFCFG_T

M2MB_NCM_CFG_OPCODE_STA_WPS_CFG 

STA WPS configuration setting M2MB_NCM_WPS_CFG_T

M2MB_NCM_CFG_OPCODE_STA_POWER_SAVE_CFG 
M2MB_NCM_AP_MODE_CONNECTED_STA_INFO 

For Connected station information in AP mode

M2MB_NCM_AP_MODE_DISCONNECTED_STA_INFO 

For disconnect station information in AP mode

M2MB_NCM_MODE_L2_ONLY 

Set this if only L2 level connection is required.

Definition at line 208 of file m2mb_ncm.h.

◆ M2MB_NCM_CTX_STATES

Different states in NCM module.

This enumeration will be helpful in tracking the NCM module state

Enumerator
M2MB_NCM_STATE_NOT_INITIALISED 

The NCM is not initialized

M2MB_NCM_STATE_INITIALISED 

The NCM is initialized and ready

M2MB_NCM_STATE_L2_DISCONNECTING 

The NCM has initiated the L2 disconnect with the WLAN and waiting for the disconnect indication from the WLAN. The disconnect is initiated by the NCM when Sync Loss is detected

M2MB_NCM_STATE_L2_DISCONNECTED 

The NCM has L2 disconnected. This happens:

  • At Start
  • The Disassociation triggered by NCM and confirmed by WLAN
  • The Disassociation indication from the WLAN
M2MB_NCM_STATE_L2_CONCT_TO_KNOWN_AP 

Scanning known AP with previously scanned MAC frame

M2MB_NCM_STATE_L2_SCAN_KNOWN_CHNL 

Scanning known channel

M2MB_NCM_STATE_L2_SCAN_SPECIFIC_CHNL 

scanning specific channels

M2MB_NCM_STATE_L2_SCAN_ALL_CHNL 

Scanning All channels

M2MB_NCM_STATE_L2_CONNECTED 

L2 Connected. L3 is not connected yet

M2MB_NCM_STATE_L3_CONNECTED 

L2 and L3 both are Connected

M2MB_NCM_STATE_IDLE 

Wait/idle state

M2MB_NCM_STATE_L3_IP_FAIL 

IP fail in NCm connection

Definition at line 119 of file m2mb_ncm.h.

◆ M2MB_NCM_INIT_MODE_E

Different modes.

This enum is used to start the NCM module initialization. It depends on the user to start the NCM module in STATION or AP mode.

Enumerator
M2MB_NCM_MODE_STATION 

Station mode for NCM module initialization.

M2MB_NCM_MODE_AP 

AP mode for NCM module initialization.

M2MB_NCM_MODE_BOTH 

Both AP and STA mode

Definition at line 239 of file m2mb_ncm.h.

◆ M2MB_NCM_IPFLAG_SETTING_E

IP configuration.

This enum defines macros for IP flag setting in NCM connection and will be referred by M2MB_NCM_IP_CFG_T structure.

Note
This enum will be used by M2MB_NCM_IP_CFG_T structure.
Enumerator
M2MB_NCM_IPFLAG_V4_STATIC 

setting a static flag (no dhcp)

M2MB_NCM_IPFLAG_V4_DHCP 

setting DHCP flag

M2MB_NCM_IPFLAG_V6_AUTO 

V6 auto flag

M2MB_NCM_IPFLAG_V6_DHCP 

V6 dhcp flag

Definition at line 151 of file m2mb_ncm.h.

Function Documentation

◆ m2mb_ncm_check_handle_init()

UINT32 m2mb_ncm_check_handle_init ( UINT32  handle)

This API is used to check the handle is initialized or not.

This API is used to check the operating mode in NCM module is properly initialized or not. This is the checking initialization API. m2mb_ncm_init should be called first before calling this API.

Parameters
[in]handleHandle, received from the m2mb_ncm_init API.
Returns
returns M2MB_OK on success or M2MB_ERROR on failure.
Note
This API should be called after m2mb_ncm_init.

m2mb_ncm_check_handle_init(handle);

int main()
{
UINT8 handle;
INT32 ret;
if(handle == 2)
{
return M2MB_ERROR;
}
if(ret == M2MB_OK)
{
return 0;
}
return -1;
}

◆ m2mb_ncm_deinit()

M2MB_STATUS_T m2mb_ncm_deinit ( UINT8  handle)

This API is used to deintializes the NCM module.

m2mb_ncm_deinit is used to deinitializes the NCM module. If the device is already connected to the existing AP or else device is already created an AP then in either cases the device should first disconnect or down the network by using m2mb_ncm_disconnect function. If the device is in idle state after NCM initialization then user may directly deinitialize the NCM module.

Parameters
[in]handleHandle, received from the m2mb_ncm_init API.
Returns
returns M2MB_OK on success or M2MB_ERROR on failure.
Note
This API should be called after m2mb_ncm_init. m2mb_ncm_disconnect should be called if the NCM module is in connected state or created state.

m2mb_ncm_deinit(handle);

VOID app_ncm_connect_cb(UINT8 device_id, UINT8 event, VOID *cb_Ctx)
{
switch(event)
{
{
//set event after connection
}
break;
{
//set event after disconnection
}
break;
}
}
int main()
{
UINT8 handle;
UINT8 *user_ssid = "Telit_test";
handle = m2mb_ncm_init(M2MB_NCM_MODE_STATION, app_ncm_connect_cb, NULL);
if(handle == 2)
{
return M2MB_ERROR;
}
ap.ssid_Len = strlen(user_ssid);
memcpy( ap.ssid, user_ssid, strlen(user_ssid));
ap.channel = 6;
if(ret != M2MB_OK)
{
}
//wait for event if connection has happened to AP or not
ret = m2mb_ncm_start(handle);
if(ret != M2MB_OK)
{
}
ret = m2mb_ncm_disconnect(handle);
if(ret != M2MB_OK)
{
}
//wait for event if disconnection has happened with AP or not
ret = m2mb_ncm_deinit(handle);
if(ret != M2MB_OK)
{
}
return M2MB_OK;
}

◆ m2mb_ncm_deregister_cb()

INT32 m2mb_ncm_deregister_cb ( UINT8  handle)

This API is used to deregister the user callback in NCM module.

m2mb_ncm_deregister_cb is used by application to deregister the user callback. m2mb_ncm_deregister_cb will be applied for both callbacks registered by m2mb_ncm_init and m2mb_ncm_register_cb. This API will deregister user callback for either methods.

Parameters
[in]handleHandle, received from the m2mb_ncm_init API.
Returns
returns 0 on success or 1 on failure.
Note
This API should be called after m2mb_ncm_init and m2mb_ncm_register_cb.

m2mb_ncm_deregister_cb(ncm_handle);

VOID ncm_user_cb(UINT8 device_id, UINT8 event, VOID *cb_Ctx)
{
switch(event)
{
{
}
break;
}
}
int main()
{
UINT8 handle;
INT32 ret;
if(handle == 2)
{
return M2MB_ERROR;
}
...
ret = m2mb_ncm_register_cb(handle, ncm_user_cb, NULL);
if(ret != M2MB_OK)
{
}
ret = m2mb_ncm_deregister_cb(handle);
if(ret != M2MB_OK)
{
}
}

◆ m2mb_ncm_get_cfg()

INT32 m2mb_ncm_get_cfg ( UINT8  handle,
M2MB_NCM_CFG_OPCODE_E  opCode,
M2MB_NCM_CFG_PTR_T p 
)

This API is used to get different configurations of NCM module.

User can get the details of different configurations of NCM module by using this API. Refer M2MB_NCM_CFG_PTR_T for different types of configurations user can get. Some of the members of M2MB_NCM_CFG_PTR_T are used only to GET configurations. Refer M2MB_NCM_CFG_OPCODE_E for different opcodes and user should pass respective structure to get the configuration.

Parameters
[in]handleHandle, received from the m2mb_ncm_init API.
[in]opCodeIndicates which configuration opcode is used. Refer M2MB_NCM_CFG_OPCODE_E for different opcodes.
[out]ppointer to the configuration structure. Should be typecasted with M2MB_NCM_CFG_PTR_T
Returns
On success returns Handle either 0 or 1, and 2 on failure.
Note
This API should to be called after m2mb_ncm_init API.

m2mb_ncm_get_cfg(handle, M2MB_NCM_CFG_OPCODE_INTERFACE_GET, (M2MB_NCM_CFG_PTR_T *)&pCfg);

int main()
{
UINT8 handle;
INT32 ret;
M2MB_NCM_IFCFG_T pCfg = {0};
if(handle == 2)
{
return M2MB_ERROR;
}
(M2MB_NCM_CFG_PTR_T *)&pCfg);
if(ret != M2MB_SUCCESS)
{
return M2MB_ERROR;
}
return M2MB_OK;
}

◆ m2mb_ncm_get_state()

INT32 m2mb_ncm_get_state ( UINT8  device_id)

Current state of NCM module.

This API is used to check the current state of NCM module. Refer M2MB_NCM_CTX_STATES_E to understand the state of NCM module.

Parameters
[in]device_idHandle, received from the m2mb_ncm_init API.
Returns
returns M2MB_OK on success or M2MB_ERROR on failure.
Note
This API should be called after m2mb_ncm_init.

m2mb_ncm_get_state(device_id);

int main()
{
UINT8 handle;
INT32 state;
if(handle == 2)
{
return M2MB_ERROR;
}
state = m2mb_ncm_get_state(handle);
return M2MB_OK;
}

◆ m2mb_ncm_init()

UINT8 m2mb_ncm_init ( UINT8  mode,
UINT8  bandwidth,
M2MB_NCM_CB_T  cb,
VOID cb_ctx 
)

NCM module initialization.

This API configures and initializes the NCM module. Refer M2MB_NCM_INIT_MODE_E to configure the mode for NMC module initialization. User can register the callback as second parameter for this API or else user can use m2mb_ncm_register_cb function after initialization of NCM module i.e after calling this API to register the callback. The counterpart function for this API is m2mb_ncm_deinit.

Parameters
[in]modeOperating mode. Refer M2MB_NCM_INIT_MODE_E for different operating mode.
[in]cbCallback of application to get indicated for any events from NCM module.
[in]cb_ctxUser callback context, passed along with the events to the callback.
Returns
On success returns HANDLE to be used for other NCM related APIs or M2MB_ERROR on failure.
Note
This API should to be called before any other NCM related APIs are called.

m2mb_ncm_init(M2MB_NCM_MODE_STATION, app_ncm_connect_cb, user_ctx);

VOID app_ncm_connect_cb(UINT8 device_id, UINT8 event, VOID *user_ctx)
{
switch(event)
{
{
}
break;
{
}
}
int main()
{
UINT8 handle;
handle = m2mb_ncm_init(M2MB_NCM_MODE_STATION, app_ncm_connect_cb, NULL);
if(handle == 2)
{
return M2MB_ERROR;
}
}

◆ m2mb_ncm_register_cb()

INT32 m2mb_ncm_register_cb ( UINT8  handle,
M2MB_NCM_CB_T  m2mb_ncm_cb,
VOID Ctx 
)

This API is used to register application callback in NCM module.

This API is the optional to register the application callback with NCM module. User can register application callback through m2mb_ncm_init or else user can use this API to register application callback. The counterpart for this API is m2mb_ncm_deregister_cb. Its user's choice to use either this API or m2mb_ncm_init function to register application callback.

Parameters
[in]handleHandle, received from the m2mb_ncm_init API.
[in]m2mb_ncm_cbCallback of application to get indicated for any events from NCM module.
[in]CtxUser callback context, passed along with the events to the user callback.
Returns
returns M2MB_OK on success or M2MB_ERROR on failure.
Note
This API should be called after m2mb_ncm_init.

m2mb_ncm_register_cb(handle, ncm_user_cb, NULL);

VOID ncm_user_cb(UINT8 device_id, UINT8 event, VOID *cb_Ctx)
{
switch(event)
{
{
}
break;
}
}
int main()
{
UINT8 handle;
UINT8 *user_ssid = "Telit_test";
if(handle == 2)
{
return M2MB_ERROR;
}
ap.ssid_Len = strlen(user_ssid);
memcpy( ap.ssid, user_ssid, strlen(user_ssid));
ap.channel = 6;
ret = m2mb_ncm_register_cb(handle, ncm_user_cb, NULL);
if(ret != M2MB_OK)
{
}
if(ret != M2MB_OK)
{
}
//wait for event if connection has happened to AP or not
ret = m2mb_ncm_start(handle);
if(ret != M2MB_OK)
{
}
return M2MB_OK;
}

◆ m2mb_ncm_scan()

INT32 m2mb_ncm_scan ( UINT8  device_id,
UINT8 ssid,
UINT8  no_of_channels,
UINT8 channel_list,
UINT8  scan_type,
UINT32  num_of_scan_entries,
M2MB_WLAN_BSS_SCAN_INFO_T scanentries,
M2MB_NCM_SCAN_CB_T  m2m_ncm_scan_cb,
VOID usr_ctx 
)

This API is used to get the WLAN scan results. This API expects m2mb_ncm_init prior to it in STA mode.

This API is used to get the WLAN scan results, it can be used for replacement of m2mb_wlan_scan API at NCM level. If the user is passing the m2mb_ncm_scan_cb then the results will come to user callback asynchronously. If the user is passing NULL in user callback parameter then this API will acta s blocking call and user buffer will get filled.

Parameters
[in]device_idHandle, received from the m2mb_ncm_init API.
[in]ssidSSID of the particular Access Point to scan [optional]
[in]no_of_channelsNumber of channels to scan [optional]. 0 for all channel scan
[in]channel_listList of channels that user wants to scan.
[in]scan_typeScanning type ; [active - 0] or [passive - 1]
[in]num_of_scan_entriesUser can pass number of entries of scan results and he should provide buffer of that number of scan results. Array of M2MB_WLAN_BSS_SCAN_INFO_T structures
[in,out]result_buffBuffer which is provided by the user to store scan results.

m2mb_ncm_scan(device_id, SSID, 0, chnl, 0, 12, scan_entries, m2m_scan_cb,NULL);

VOID m2mb_scan_cb(UINT8 device_id, UINT8 event_id, INT32 status, VOID *data)
{
switch(event_id)
{
{
...
}
}
}
int main()
{
UINT8 handle;
if(handle == 2)
{
return M2MB_ERROR;
}
ret = m2mb_ncm_scan(device_id, SSID, 0, chnl, 0, 12, scan_entries, m2m_scan_cb,NULL);
return M2MB_OK;
}

◆ m2mb_ncm_set_cfg()

INT32 m2mb_ncm_set_cfg ( UINT8  handle,
M2MB_NCM_CFG_OPCODE_E  opCode,
M2MB_NCM_CFG_PTR_T p 
)

This API is used to set the different configurations in NCM module.

User can set different configurations of NCM module by using this API. Refer M2MB_NCM_CFG_PTR_T for different types of configurations user can set. Some of the members of M2MB_NCM_CFG_PTR_T are used only to SET configurations. Refer M2MB_NCM_CFG_OPCODE_E for different opcodes and user should pass respective structure filled with required parameters to set the configuration.

Parameters
[in]handleHandle, received from the m2mb_ncm_init API.
[in]opCodeIndicates which configuration opcode is used. Refer M2MB_NCM_CFG_OPCODE_E for different opcodes.
[in]pPointer to the structure with filled parameters to set. Should be typecasted with M2MB_NCM_CFG_PTR_T
Returns
returns M2MB_OK on success, M2MB_ERROR value on error.
Note
This API has to be called after m2mb_ncm_init API is called. Before calling m2mb_ncm_start, if user wants to set the user defined values then this API should have been called to set the configuration details else default values will be used.

m2mb_ncm_set_cfg(handle, M2MB_NCM_CFG_OPCODE_IP_CFG, (M2MB_NCM_CFG_PTR_T *)&pCfg);

int main()
{
UINT8 handle;
INT32 ret;
M2MB_NWIF_IPV4_CONFIG_T ipv4Cfg = {0};
ipv4Cfg.ipv4Addr = //user should fill ipaddress;
ipv4Cfg.gateway = //user should fill gateway;
ipv4Cfg.subnetMask = //user should fill subnet mask;
cfg.pIPv4Cfg = &ipv4Cfg;
if(handle == 2)
{
return M2MB_ERROR;
}
if(ret != M2MB_SUCCESS)
{
return M2MB_ERROR;
}
return M2MB_OK;
}

◆ m2mb_ncm_start()

INT32 m2mb_ncm_start ( UINT8  handle)

This API is used to start the NCM module after initialization.

This API starts the NCM module to connect to the existing network when the NCM is initiated in STA mode or else it create its own network when the NCM is initiated in AP mode. Either of these functionalities require AP profile. The AP profile should be set by user using m2mb_ncm_set_cfg with M2MB_NCM_CFG_OPCODE_AP_PROFILE opcode and respective structure in M2MB_NCM_CFG_PTR_T. User can set IP related parameters by using m2mb_ncm_set_cfg with M2MB_NCM_CFG_OPCODE_IP_CFG opcode and respective structure in M2MB_NCM_CFG_PTR_T. This API uses the configuration set by the user else it uses the default configuration. The counter part fro this API is m2mb_ncm_disconnect.

Parameters
[in]handleHandle, received from the m2mb_ncm_init API.
Returns
Returns M2MB_OK on success, M2MB_ERROR on failure.
Note
This API has to be called after m2mb_ncm_init API is called. User should set required configurations by using m2mb_ncm_set_cfg before calling this API. Else the default value will be used.

m2mb_ncm_start( handle );

VOID app_ncm_connect_cb(UINT8 device_id, UINT8 event, VOID *cb_Ctx)
{
switch(event)
{
{
}
break;
{
}
break;
}
}
int main()
{
UINT8 handle;
INT32 ret;
UINT8 *user_ssid = "Telit_test";
M2MB_NCM_AP_CFG_T cfg = {0};
M2MB_NCM_DHCP_SERVER_CFG_T dhcp_server_info = {0};
M2MB_NCM_IP_CFG_T ip_cfg = {0};
M2MB_NWIF_IPV4_CONFIG_T ipv4Cfg = {0};
handle = m2mb_ncm_init(M2MB_NCM_MODE_AP, app_ncm_connect_cb, NULL);
if(handle == 2)
{
return M2MB_ERROR;
}
ap.ssid_Len = strlen(user_ssid);
memcpy( ap.ssid, user_ssid, strlen(user_ssid));
ap.channel = 6;
if(ret != M2MB_OK)
{
}
cfg.beaconInterval = 100;
cfg.dtimPeriod = 3;
cfg.hiddenSsid = 0;
(M2MB_NCM_CFG_PTR_T *)&cfg );
if(ret != M2MB_OK)
{
return M2MB_ERROR;
}
&ipv4Cfg.ipv4Addr);
&ipv4Cfg.subnetMask);
&ipv4Cfg.gateway);
ip_cfg.pIPv4Cfg = &ipv4Cfg;
(M2MB_NCM_CFG_PTR_T *)&ip_cfg);
if(ret != M2MB_OK)
{
return M2MB_ERROR;
}
&dhcp_server_info.startIP);
&dhcp_server_info.endIP);
dhcp_server_info.leaseTime = 86400000;
(M2MB_NCM_CFG_PTR_T *)&dhcp_server_info);
if(ret != M2MB_OK)
{
return M2MB_ERROR;
}
ret = m2mb_ncm_start(handle);
if(ret != M2MB_OK)
{
return M2MB_ERROR;
}
}

◆ m2mb_ncm_stop()

INT32 m2mb_ncm_stop ( UINT8  handle)

Disconnect or Down the NCM module.

This API is used to disconnect from the connected network in STA mode and down the created network in AP mode. This API is the counterpart of m2mb_ncm_start API. For deinitialization of NCM module, the user should give this API.

Parameters
[in]handleHandle, received from the m2mb_ncm_init API.
Returns
returns M2MB_OK on success or M2MB_ERROR on failure.
Note
This API should be called after m2mb_ncm_init and m2mb_ncm_start APIs.

m2mb_ncm_deregister_cb(handle);

VOID app_ncm_connect_cb(UINT8 device_id, UINT8 event, VOID *cb_Ctx)
{
switch(event)
{
{
//set event after connection
}
break;
{
//set event after disconnection
}
break;
}
}
int main()
{
UINT8 handle;
UINT8 *user_ssid = "Telit_test";
handle = m2mb_ncm_init(M2MB_NCM_MODE_STATION, app_ncm_connect_cb, NULL);
if(handle == 2)
{
return M2MB_ERROR;
}
ap.ssid_Len = strlen(user_ssid);
memcpy( ap.ssid, user_ssid, strlen(user_ssid));
ap.channel = 6;
if(ret != M2MB_OK)
{
}
//wait for event if connection has happened to AP or not
ret = m2mb_ncm_start(handle);
if(ret != M2MB_OK)
{
}
ret = m2mb_ncm_disconnect(handle);
if(ret != M2MB_OK)
{
}
return M2MB_OK;
}