Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
WINC1500 (Wi-Fi)

Macros

#define WIFI_1X_TLS_HS_FLAGS_DEFAULT
 
#define WIFI_1X_TLS_HS_FLAGS_PEER_AUTH   NBIT1
 
#define WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK   NBIT2
 
#define WIFI_1X_TLS_HS_FLAGS_REQUIRE_TIME   NBIT3
 
#define WIFI_1X_TLS_HS_FLAGS_RSV5   NBIT5
 
#define WIFI_1X_TLS_HS_FLAGS_RSV7   NBIT7
 
#define WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING   NBIT4
 
#define WIFI_1X_TLS_HS_FLAGS_SPECIFY_ROOTCERT   NBIT6
 

Functions

static sint8 m2m_validate_ap_parameters (CONST tstrM2MAPModeConfig *pstrM2MAPModeConfig)
 
static sint8 m2m_validate_scan_options (tstrM2MScanOption *ptstrM2MScanOption)
 
static void m2m_wifi_cb (uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
 
static sint8 m2m_wifi_connect_prepare_msg (tenuCredStoreOption enuCredStoreOption, tenuM2mSecType enuAuthType, uint16 u16AuthSize, tstrNetworkId *pstrNetworkId, tstrM2mWifiConnHdr *pstrWifiConn)
 
sint8 m2m_wifi_deinit (void *arg)
 De-initialize the WINC driver and host interface. More...
 
sint8 m2m_wifi_disable_ap (void)
 Synchronous API to disable access point mode on the WINC IC. More...
 
sint8 m2m_wifi_disconnect (void)
 Synchronous API to request disconnection from a network. More...
 
sint8 m2m_wifi_enable_ap (CONST tstrM2MAPConfig *pstrM2MAPConfig)
 Asynchronous API to enable access point (AKA "hot-spot") mode on the WINC IC. More...
 
NMI_API sint8 m2m_wifi_enable_mac_mcast (uint8 *pu8MulticastMacAddress, uint8 u8AddRemove)
 Add MAC filter to receive Multicast packets. More...
 
sint8 m2m_wifi_get_connection_info (void)
 Request the status information of the currently connected Wi-Fi AP. The result is passed to the Wi-Fi notification callback with the event M2M_WIFI_RESP_CONN_INFO. More...
 
uint8 m2m_wifi_get_num_ap_found (void)
 Reads the number of AP's found in the last Scan Request, The function read the number of AP's from global variable which updated in the wifi_cb in M2M_WIFI_RESP_SCAN_DONE. More...
 
sint8 m2m_wifi_get_otp_mac_address (uint8 *pu8MacAddr, uint8 *pu8IsValid)
 Request the MAC address stored on the OTP (one time programmable) memory of the device. (the function is Blocking until response received) More...
 
uint8 m2m_wifi_get_sleep_mode (void)
 Get the current Power save mode. More...
 
sint8 m2m_wifi_handle_events (void *arg)
 Synchronous M2M event handler function. More...
 
sint8 m2m_wifi_init (tstrWifiInitParam *pWifiInitParam)
 Synchronous API to initialize the WINC driver. More...
 
sint8 m2m_wifi_p2p (uint8 u8Channel)
 
sint8 m2m_wifi_p2p_disconnect (void)
 
sint8 m2m_wifi_req_client_ctrl (uint8 u8Cmd)
 Send a command to the PS Client (An WINC board running the ps_firmware), if the PS client send any commands it will be received in wifi_cb M2M_WIFI_RESP_CLIENT_INFO. More...
 
sint8 m2m_wifi_req_curr_rssi (void)
 Request the current RSSI for the current connected AP, the response received in wifi_cb M2M_WIFI_RESP_CURRENT_RSSI. More...
 
sint8 m2m_wifi_req_scan_result (uint8 index)
 Reads the AP information from the Scan Result list with the given index, the response received in wifi_cb M2M_WIFI_RESP_SCAN_RESULT, the response pointer should be casted with tstrM2mWifiscanResult structure. More...
 
sint8 m2m_wifi_req_server_init (uint8 ch)
 Initialize the PS Server, The WINC support non secure communication with another WINC, (SERVER/CLIENT) through one byte command (probe request and probe response) without any connection setup. More...
 
sint8 m2m_wifi_request_scan (uint8 ch)
 Asynchronous API to request the WINC IC to scan for networks. More...
 
sint8 m2m_wifi_send_crl (tstrTlsCrlInfo *pCRL)
 Asynchronous API that notifies the WINC with the Certificate Revocation List. More...
 
sint8 m2m_wifi_set_cust_InfoElement (uint8 *pau8M2mCustInfoElement)
 API to add or remove a user-defined Information Element. More...
 
sint8 m2m_wifi_set_device_name (uint8 *pu8DeviceName, uint8 u8DeviceNameLength)
 Set the WILC1000 device name which is used as P2P device name. More...
 
sint8 m2m_wifi_set_lsn_int (tstrM2mLsnInt *pstrM2mLsnInt)
 Set the Wi-Fi listen interval for power save operation. It is represented in units of AP Beacon periods. More...
 
NMI_API sint8 m2m_wifi_set_receive_buffer (void *pvBuffer, uint16 u16BufferLen)
 set the ethernet receive buffer, should be called in the receive call back. More...
 
sint8 m2m_wifi_set_sleep_mode (uint8 PsTyp, uint8 BcastEn)
 Set the power saving mode for the WILC1000. More...
 
sint8 m2m_wifi_set_tx_power (uint8 u8TxPwrLevel)
 set the TX power More...
 
sint8 m2m_wifi_wps (uint8 u8TriggerType, const char *pcPinNumber)
 Asynchronous API to engage the WINC IC's Wi-Fi Protected Setup (enrollee) function. More...
 
sint8 m2m_wifi_wps_disable (void)
 Disable the WILC WPS operation. More...
 

Variables

static uint8 gau81xRootSha1 [20] = {0}
 
static uint8gau8ethRcvBuf =NULL
 
static tpfAppEthCb gpfAppEthCb = NULL
 
static tpfAppWifiCb gpfAppWifiCb = NULL
 
static uint16 gu16ethRcvBufSize
 
static uint32 gu321xTlsHsFlags = WIFI_1X_TLS_HS_FLAGS_DEFAULT
 
static volatile uint8 gu8ChNum
 
static volatile uint8 gu8scanInProgress = 0
 
static volatile uint8 gu8WifiState = WIFI_STATE_DEINIT
 

#define WIFI_1X_TLS_HS_FLAGS_DEFAULT
Value:
( \
)
#define WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING
Definition: winc1500/host_drv/driver/source/m2m_wifi.c:53
#define WIFI_1X_TLS_HS_FLAGS_PEER_AUTH
Definition: winc1500/host_drv/driver/source/m2m_wifi.c:47
#define WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK
Definition: winc1500/host_drv/driver/source/m2m_wifi.c:49
#define WIFI_1X_TLS_HS_FLAGS_PEER_AUTH   NBIT1
#define WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK   NBIT2
#define WIFI_1X_TLS_HS_FLAGS_REQUIRE_TIME   NBIT3
#define WIFI_1X_TLS_HS_FLAGS_RSV5   NBIT5
#define WIFI_1X_TLS_HS_FLAGS_RSV7   NBIT7
#define WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING   NBIT4
#define WIFI_1X_TLS_HS_FLAGS_SPECIFY_ROOTCERT   NBIT6

sint8 m2m_wifi_deinit ( void *  arg)

De-initialize the WINC driver and host interface.

Synchronous API to de-initialize the WINC driver and host interface.

Parameters
[in]argGeneric argument. Not used in current implementation.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Synchronous de-initialization function for the WINC driver.
De-initializes the host interface and frees any resources used by the M2M_WIFI layer. 
This function must be called in the application closing phase to ensure that all
resources have been correctly released.
No arguments are expected to be passed in. 
Parameters
[in]argOpaque argument, not used in current implementation. Application should use null.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Note
This function must be called at the de-initialization stage of the application. Generally this function should be the last function before switching off the chip and it should be followed only by nm_bsp_deinit function call. Every function call of m2m_wifi_init should be matched with a call to m2m_wifi_deinit.
See Also
nm_bsp_deinit m2m_wifi_init m2m_wifi_init_hold m2m_wifi_download_mode
De-initialization function for the WINC driver.
De-initializes the host interface and frees any resources used by the M2M_WIFI layer.
This function must be called in the application closing phase to ensure that all
resources have been correctly released.
Parameters
[in]argOpaque argument, not used in current implementation. Application should use null.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Note
This function must be called at the de-initialization stage of the application. Generally this function should be the last function before switching off the chip and it should be followed only by nm_bsp_deinit function call. Every function call of m2m_wifi_init should be matched with a call to m2m_wifi_deinit.
See Also
nm_bsp_deinit m2m_wifi_init m2m_wifi_init_hold m2m_wifi_init_start m2m_wifi_reinit m2m_wifi_reinit_hold m2m_wifi_reinit_start m2m_wifi_download_mode m2m_wifi_download_mode

References gu8WifiState, hif_deinit(), M2M_SUCCESS, nm_drv_deinit(), NULL, and WIFI_STATE_DEINIT.

sint8 m2m_wifi_disable_ap ( void  )

Synchronous API to disable access point mode on the WINC IC.

Synchronous API to disable access point mode on the WINC.

See Also
m2m_wifi_enable_ap
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Must be called only when the AP is enabled through the @ref m2m_wifi_enable_ap
function. Otherwise the call to this function will not be useful.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
m2m_wifi_enable_ap

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_DISABLE_AP, and NULL.

sint8 m2m_wifi_disconnect ( void  )

Synchronous API to request disconnection from a network.

Precondition
Disconnection must be made to a successfully connected AP. If the WILC is not in the connected state, a call to this function will hold insignificant.
Warning
This function must be called in station mode only.
See Also
m2m_wifi_connect m2m_wifi_default_connect
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Request a Wi-Fi disconnect from the currently connected AP.
After the disconnect is complete the driver should receive a response of @ref M2M_WIFI_RESP_CON_STATE_CHANGED based on the states defined
in @ref tenuM2mConnState, successful disconnection is defined by @ref M2M_WIFI_DISCONNECTED .
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Precondition
Disconnection request must be made to a successfully connected AP. If the WINC is not in the connected state, a call to this function will hold insignificant.
Warning
This function must be called in station mode only.
See Also
m2m_wifi_connect_open m2m_wifi_connect_wep m2m_wifi_connect_psk m2m_wifi_connect_1x_mschap2 m2m_wifi_connect_1x_tls m2m_wifi_default_connect
Request a Wi-Fi disconnect from the currently connected AP.
The connection status will be indicated to the application via a @ref M2M_WIFI_RESP_CON_STATE_CHANGED event.
The status will be one of those defined in @ref tenuM2mConnState, with @ref M2M_WIFI_DISCONNECTED indicating
a successful disconnection.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Precondition
Disconnection request must be made to a successfully connected AP. If the WINC is not in the connected state, a call to this function will hold insignificant.
Warning
This function must be called in station mode only.
See Also
m2m_wifi_connect m2m_wifi_connect_sc m2m_wifi_default_connect m2m_wifi_connect_open m2m_wifi_connect_wep m2m_wifi_connect_psk m2m_wifi_connect_1x_mschap2 m2m_wifi_connect_1x_tls

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DISCONNECT, and NULL.

sint8 m2m_wifi_enable_ap ( CONST tstrM2MAPConfig pstrM2MAPConfig)

Asynchronous API to enable access point (AKA "hot-spot") mode on the WINC IC.

Asynchronous API to enable access point (AKA "hot-spot") mode on the WINC.

Parameters
[in]pstrM2MAPConfigA structure holding the AP configurations.
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at intalization. Registering the callback is done through passing it to the m2m_wifi_init.
  • The m2m_wifi_handle_events MUST be called to receive the responses in the callback.
See Also
tpfAppWifiCb tenuM2mSecType m2m_wifi_init tstrM2mWifiStateChanged tstrM2MAPConfig
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Example

The code snippet demonstrates how the AP mode is enabled after the driver is initialized in the application's main function

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
printf("STA has Associated\n");
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
tstrM2MAPConfig apConfig;
strcpy(apConfig.au8SSID, "WILC_SSID");
strcpy((char *)cfg.uniAuth.au8PSK, "12345678");
apConfig.u8ListenChannel = 1;
// Trigger AP
m2m_wifi_enable_ap(&apConfig);
while(1)
{
}
}
}
The WINC IC supports the ability to operate as an access point with the following limitations:
  - Only 1 station may be associated at any given time.
  - Open system and WEP are the only security suites supported.
Parameters
[in]pstrM2MAPConfigA structure holding the AP configurations.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Precondition
Warning
This function is not allowed in STA mode.
See Also
tpfAppWifiCb tenuM2mSecType m2m_wifi_init M2M_WIFI_REQ_DHCP_CONF tstrM2mWifiStateChanged tstrM2MAPConfig

Example

The code snippet demonstrates how the AP mode is enabled after the driver is initialized in the application's main function and the handling of the event M2M_WIFI_REQ_DHCP_CONF, to indicate successful connection.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
uint8 *pu8IPAddress = (uint8*)pvMsg;
printf("Associated STA has IP Address \"%u.%u.%u.%u\"\n",pu8IPAddress[0],pu8IPAddress[1],pu8IPAddress[2],pu8IPAddress[3]);
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
tstrM2MAPConfig apConfig;
strcpy(apConfig.au8SSID, "WINC_SSID");
apConfig.u8ListenChannel = 1;
apConfig.u8SsidHide = 0;
// IP Address
apConfig.au8DHCPServerIP[0] = 192;
apConfig.au8DHCPServerIP[1] = 168;
apConfig.au8DHCPServerIP[2] = 1;
apConfig.au8DHCPServerIP[3] = 1;
// Trigger AP
m2m_wifi_enable_ap(&apConfig);
while(1)
{
}
}
}
The WINC supports the ability to operate as an access point with the following limitations:
- Only 1 station may be associated at any given time.
- Open system and WEP are the only security suites supported.
Parameters
[in]pstrM2MAPConfigA structure holding the AP configurations.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Warning
This function is not allowed in P2P or STA modes.
Precondition
See Also
tpfAppWifiCb tenuM2mSecType m2m_wifi_init M2M_WIFI_REQ_DHCP_CONF tstrM2mWifiStateChanged tstrM2MAPConfig

Example

The code snippet demonstrates how the AP mode is enabled after the driver is initialized in the application's main function and the handling of the event M2M_WIFI_REQ_DHCP_CONF, to indicate successful connection.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
uint8 *pu8IPAddress = (uint8*)pvMsg;
printf("Associated STA has IP Address \"%u.%u.%u.%u\"\n",pu8IPAddress[0],pu8IPAddress[1],pu8IPAddress[2],pu8IPAddress[3]);
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
tstrM2MAPConfig apConfig;
strcpy(apConfig.au8SSID, "WINC_SSID");
apConfig.u8ListenChannel = 1;
apConfig.u8SsidHide = 0;
// IP Address
apConfig.au8DHCPServerIP[0] = 192;
apConfig.au8DHCPServerIP[1] = 168;
apConfig.au8DHCPServerIP[2] = 1;
apConfig.au8DHCPServerIP[3] = 1;
// Trigger AP
m2m_wifi_enable_ap(&apConfig);
while(1)
{
}
}
}

References tstrM2MAPConfigExt::au8DefRouterIP, tstrM2MAPConfigExt::au8DNSServerIP, tstrM2MAPConfigExt::au8SubnetMask, m2m_memcpy(), m2m_wifi_enable_ap_ext(), tstrM2MAPModeConfig::strApConfig, and tstrM2MAPModeConfig::strApConfigExt.

NMI_API sint8 m2m_wifi_enable_mac_mcast ( uint8 pu8MulticastMacAddress,
uint8  u8AddRemove 
)

Add MAC filter to receive Multicast packets.

Asynchronous API to add or remove MAC addresses to the multicast filter.

Synchronous function for filtering received MAC addresses.

Parameters
[in]pu8MulticastMacAddressPointer to the MAC address.
[in]u8AddRemoveFlag to Add/Remove MAC address.
Returns
The function SHALL return 0 for success and a negative value otherwise.
Synchronous function for filtering received MAC addresses from certain MAC address groups.
This function allows the addition/removal of certain MAC addresses, used in the multicast filter.
Parameters
[in]pu8MulticastMacAddressPointer to MAC address
[in]u8AddRemoveA flag to add or remove the MAC ADDRESS, based on the following values:
  • 0 : remove MAC address
  • 1 : add MAC address
Note
Maximum number of MAC addresses that could be added is 8.
Warning
This function is available in ETHERNET/bypass mode ONLY. Make sure that the application defines ETH_MODE.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
m2m_wifi_set_receive_buffer m2m_wifi_send_ethernet_pkt
This function will configure the WINC to receive/ignore multicast packets from certain
MAC address groups when operating in bypass mode.
This function requests the given MAC addresses to be added/removed from the multicast filter.
Parameters
[in]pu8MulticastMacAddressPointer to MAC address
[in]u8AddRemoveA flag to add or remove the MAC ADDRESS, based on the following values:
  • 0 : remove MAC address
  • 1 : add MAC address
Note
Maximum number of MAC addresses that could be added is 8.
Warning
This function is available in ETHERNET/bypass mode ONLY. Make sure that the application defines ETH_MODE.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
m2m_wifi_set_receive_buffer m2m_wifi_send_ethernet_pkt

References tstrM2MMulticastMac::au8macaddress, hif_send(), M2M_DBG, M2M_ERR_FAIL, M2M_MAC_ADDRES_LEN, m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_MAC_MCAST, NULL, and tstrM2MMulticastMac::u8AddRemove.

sint8 m2m_wifi_get_connection_info ( void  )

Request the status information of the currently connected Wi-Fi AP. The result is passed to the Wi-Fi notification callback with the event M2M_WIFI_RESP_CONN_INFO.

Asynchronous API for retrieving the WINC connection status.

Asynchronous API for retrieving the WINC IC's connection status.

Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the intialization m2m_wifi_init function.
  • The event M2M_WIFI_RESP_CONN_INFO must be handled in the callback to receive the requested connection info.
Warning
Calling this function is valid ONLY in the STA CONNECTED state. Otherwise, the WILC SW shall ignore the request silently.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_RESP_CONN_INFO tstrM2MConnInfo
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Example

The code snippet shows an example of how wi-fi connection information is retrieved .

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
tstrM2MConnInfo *pstrConnInfo = (tstrM2MConnInfo*)pvMsg;
printf("CONNECTED AP INFO\n");
printf("SSID : %s\n",pstrConnInfo->acSSID);
printf("SEC TYPE : %d\n",pstrConnInfo->u8SecType);
printf("Signal Strength : %d\n", pstrConnInfo->s8RSSI);
printf("Local IP Address : %d.%d.%d.%d\n",
pstrConnInfo->au8IPAddr[0] , pstrConnInfo->au8IPAddr[1], pstrConnInfo->au8IPAddr[2], pstrConnInfo->au8IPAddr[3]);
}
break;
default:
break;
}
}
int main()
{
tuniM2MWifiAuth sta_auth_param;
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// connect to the AP
m2m_wifi_connect((char *)DEMO_WLAN_SSID, sizeof(DEMO_WLAN_SSID),
M2M_WIFI_SEC_OPEN, &sta_auth_param, M2M_WIFI_CH_ALL);
while(1)
{
}
}
}
Asynchronous connection status retrieval function, retrieves the status information of the 
currently connected AP. 
The result is passed to the Wi-Fi notification callback through the event 
@ref M2M_WIFI_RESP_CONN_INFO. Connection information is retrieved from 
the structure @ref tstrM2MConnInfo.

Connection Information retrieved:
-Connection Security
-Connection RSSI
-Remote MAC address
-Remote IP address

In case the WINC is operating in station mode, the SSID of the AP is also retrieved.
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the initialization m2m_wifi_init function.
  • The event M2M_WIFI_RESP_CONN_INFO must be handled in the callback to receive the requested connection info.
Warning
  • In case the WINC is operating in AP mode, the SSID field will be returned as a NULL string.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
M2M_WIFI_RESP_CONN_INFO, tstrM2MConnInfo

Example

The code snippet shows an example of how wi-fi connection information is retrieved .

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
tstrM2MConnInfo *pstrConnInfo = (tstrM2MConnInfo*)pvMsg;
printf("CONNECTED AP INFO\n");
printf("SSID : %s\n",pstrConnInfo->acSSID);
printf("SEC TYPE : %d\n",pstrConnInfo->u8SecType);
printf("Signal Strength : %d\n", pstrConnInfo->s8RSSI);
printf("Local IP Address : %d.%d.%d.%d\n",
pstrConnInfo->au8IPAddr[0] , pstrConnInfo->au8IPAddr[1], pstrConnInfo->au8IPAddr[2], pstrConnInfo->au8IPAddr[3]);
}
break;
{
// Get the current AP information.
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// connect to the default AP
while(1)
{
}
}
}
Requests the connection status from the WINC including information regarding any access
point to which it is currently connected, or any non-AP station that is connected to the WINC.
All information will be returned to the application via the Wi-Fi notification callback through
the event @ref M2M_WIFI_RESP_CONN_INFO.

The connection info can be retrieved using the structure @ref tstrM2MConnInfo which contains:
- Connection Security
- Connection RSSI
- Remote MAC address
- Remote IP address
- SSID of the network (in cases where the WINC is in non-AP mode)
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the initialization m2m_wifi_init function.
  • The event M2M_WIFI_RESP_CONN_INFO must be handled in the callback to receive the requested connection info.
Warning
  • In case the WINC is operating in AP mode or P2P mode, the SSID field will be returned as a NULL string.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
M2M_WIFI_RESP_CONN_INFO, tstrM2MConnInfo

Example

The code snippet shows an example of how wi-fi connection information is retrieved .

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
tstrM2MConnInfo *pstrConnInfo = (tstrM2MConnInfo*)pvMsg;
printf("CONNECTED AP INFO\n");
printf("SSID : %s\n",pstrConnInfo->acSSID);
printf("SEC TYPE : %d\n",pstrConnInfo->u8SecType);
printf("Signal Strength : %d\n", pstrConnInfo->s8RSSI);
printf("Local IP Address : %d.%d.%d.%d\n",
pstrConnInfo->au8IPAddr[0] , pstrConnInfo->au8IPAddr[1], pstrConnInfo->au8IPAddr[2], pstrConnInfo->au8IPAddr[3]);
}
break;
{
// Get the current AP information.
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// connect to the default AP
while(1)
{
}
}
}

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_GET_CONN_INFO, and NULL.

uint8 m2m_wifi_get_num_ap_found ( void  )

Reads the number of AP's found in the last Scan Request, The function read the number of AP's from global variable which updated in the wifi_cb in M2M_WIFI_RESP_SCAN_DONE.

Synchronous function to retrieve the number of AP's found during the last scan operation.

See Also
m2m_wifi_request_scan
Returns
Return the number of AP's found in the last Scan Request.
Precondition
m2m_wifi_request_scan need to be called first
Warning
That function need to be called in the wifi_cb in M2M_WIFI_RESP_SCAN_DONE, calling that function in any other place will return undefined/undated numbers. Function used only in STA mode only.
See Also
m2m_wifi_request_scan M2M_WIFI_RESP_SCAN_DONE M2M_WIFI_RESP_SCAN_RESULT
Precondition
m2m_wifi_request_scan need to be called first
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at intialization. Registering the callback is done through passing it to the m2m_wifi_init.
  • The event M2M_WIFI_RESP_SCAN_DONE must be handled in the callback to receive the requested connection information.
Warning
This function must be called only in the wi-fi callback function when the events M2M_WIFI_RESP_SCAN_DONE or M2M_WIFI_RESP_SCAN_RESULT are received. Calling this function in any other place will result in undefined/outdated numbers.
Returns
Return the number of AP's found in the last Scan Request.

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
The function reads the number of APs from global variable which was updated in the Wi-Fi 
callback function through the @ref M2M_WIFI_RESP_SCAN_DONE event.
Function used only in STA mode only. 
See Also
m2m_wifi_request_scan M2M_WIFI_RESP_SCAN_DONE M2M_WIFI_RESP_SCAN_RESULT
Precondition
m2m_wifi_request_scan must be called first to ensure up to date results are available.
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at initialization. Registering the callback is done through passing it to the m2m_wifi_init.
  • The event M2M_WIFI_RESP_SCAN_DONE must be handled in the callback to receive the requested scan information.
Warning
This function must be called only in the wi-fi callback function when the events M2M_WIFI_RESP_SCAN_DONE or M2M_WIFI_RESP_SCAN_RESULT are received. Calling this function in any other place will result in undefined/outdated numbers.
Returns
Return the number of AP's found in the last Scan Request.

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
This function allows the application to recover the number of access points discovered during
the most recent scan activity. This is achieved via a global variable in the WINC driver that
is populated when receiving the @ref M2M_WIFI_RESP_SCAN_DONE event.
Function to be used in STA mode only.
See Also
m2m_wifi_request_scan M2M_WIFI_RESP_SCAN_DONE M2M_WIFI_RESP_SCAN_RESULT
Precondition
m2m_wifi_request_scan must be called first to ensure up to date results are available.
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at initialization. Registering the callback is done through passing it to the m2m_wifi_init.
  • The event M2M_WIFI_RESP_SCAN_DONE must be handled in the callback to receive the requested scan information.
Warning
This function must be called only in the wi-fi callback function when the events M2M_WIFI_RESP_SCAN_DONE or M2M_WIFI_RESP_SCAN_RESULT are received. Calling this function in any other place will result in undefined/outdated numbers.
Returns
Returns the number of AP's found in the last Scan Request.

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}

References gu8ChNum.

sint8 m2m_wifi_get_otp_mac_address ( uint8 pu8MacAddr,
uint8 pu8IsValid 
)

Request the MAC address stored on the OTP (one time programmable) memory of the device. (the function is Blocking until response received)

Synchronous API to query the MAC address programmed into the WINC OTP memory.

Synchronous API to query the MAC address programmed into the WINC ICs OTP memory.

Parameters
[out]pu8MacAddrOutput MAC address buffer of 6 bytes size. Valid only if *pu8Valid=1.
[out]pu8IsValidA output boolean value to indicate the validity of pu8MacAddr in OTP. Output zero if the OTP memory is not programmed, non-zero otherwise.
Returns
The function shall return M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_get_mac_address
Precondition
m2m_wifi_init required to call any WIFI/socket function
Parameters
[out]pu8MacAddrOutput MAC address buffer of 6 bytes size. Valid only if *pu8Valid=1.
[out]pu8IsValidA output boolean value to indicate the validity of pu8MacAddr in OTP. Output zero if the OTP memory is not programmed, non-zero otherwise.
Precondition
m2m_wifi_init required to call any WIFI/socket function
See Also
m2m_wifi_get_mac_address
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
This function attempts to read the device's MAC address from the One Time Programmable (OTP)
memory on the IC. The presence (yes or no) of a MAC address in the OTP memory and, in the case
of it being present, its value is returned via RAM pointed to by the input arguments.

Request the MAC address stored on the One Time Programmable(OTP) memory of the device.
The function is blocking until the response is received.
Precondition
Prior call to m2m_wifi_init is required before any WIFI/socket function.
Parameters
[out]pu8MacAddrOutput MAC address buffer 6 bytes in size. Valid only if *pu8Valid=1.
[out]pu8IsValidA boolean value set by the callee to indicate the validity of pu8MacAddr in OTP. If no MAC has been programmed in the OTP the value of this parameter will be zero; otherwise it will be non-zero.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_get_mac_address
This function attempts to read the device's MAC address from the One Time Programmable (OTP)
memory on the WINC. The presence (yes or no) of a MAC address in the OTP memory and, in the case
of it being present, its value is returned via RAM pointed to by the input arguments.

Request the MAC address stored on the One Time Programmable(OTP) memory of the device.
The function is blocking until the response is received.
Precondition
Prior call to m2m_wifi_init is required before any WIFI/socket function.
Parameters
[out]pu8MacAddrOutput MAC address buffer 6 bytes in size. Valid only if *pu8Valid=1.
[out]pu8IsValidA boolean value set by the callee to indicate the validity of pu8MacAddr in OTP. If no MAC has been programmed in the OTP the value of this parameter will be zero; otherwise it will be non-zero.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_get_mac_address

References hif_chip_sleep(), hif_chip_wake(), M2M_SUCCESS, and nmi_get_otp_mac_address().

uint8 m2m_wifi_get_sleep_mode ( void  )

Get the current Power save mode.

Synchronous API to retrieve the current power save mode of the WINC.

Synchronous power save mode retrieval function.

Returns
The current operating power saving mode.
See Also
tenuPowerSaveModes , m2m_wifi_set_sleep_mode
tenuPowerSaveModes m2m_wifi_set_sleep_mode
Returns
The current operating power saving mode.
The current operating power saving mode based on the enumerated sleep modes tenuPowerSaveModes.
See Also
tenuPowerSaveModes m2m_wifi_set_sleep_mode
Returns
The current operating power saving mode. The value will be one of those from the enumerated type tenuPowerSaveModes.
See Also
tenuPowerSaveModes m2m_wifi_set_sleep_mode

References hif_get_sleep_mode().

sint8 m2m_wifi_handle_events ( void *  arg)

Synchronous M2M event handler function.

Precondition
Prior to receiving wi-fi interrupts, the WILC driver should have been successfully initialized by calling the m2m_wifi_init function.
Warning
Failure to successfully complete this function indicates bus errors and hence a fatal error that will prevent the application from proceeding.
Returns
The function returns M2M_SUCCESS for successful interrupt handling and a negative value otherwise.
This function is responsible for handling interrupts received from the WINC firmware.
Applications should call this function periodically in-order to receive the events that are to 
be handled by the callback functions implemented by the application.

Handle the various events received from the WINC board.
Whenever an event happens in the WINC board (e.g. Connection, Disconnection, DHCP, etc),
the WINC will interrupt the host to let it know that a new event has occurred. The host driver
will attempt to handle these events whenever the application decides to do so by calling
the m2m_wifi_handle_events function.
It is mandatory to call this function periodically and independently of any other condition.
It is ideal to include this function in the main and the most frequent loop of the
    host application.
Precondition
Prior to receiving events, the WINC driver should have been successfully initialized by calling the m2m_wifi_init function.
Warning
Failure to successfully complete this function indicates bus errors and hence a fatal error that will prevent the application from proceeding.
Returns
The function returns M2M_SUCCESS for successful interrupt handling and a negative value otherwise.
This function is responsible for handling interrupts received from the WINC firmware.
Applications should call this function periodically in-order to receive the events that are to
be handled by the callback functions implemented by the application.

Handle the various events received from the WINC.
Whenever an event happens in the WINC (e.g. Connection, Disconnection, DHCP, etc),
the WINC will interrupt the host to let it know that a new event has occurred. The host driver
will attempt to handle these events whenever the application decides to do so by calling
the m2m_wifi_handle_events function.
It is mandatory to call this function periodically and independently of any other condition.
It is ideal to include this function in the main and the most frequent loop of the
host application.
Precondition
Prior to receiving events, the WINC driver should have been successfully initialized by calling the m2m_wifi_init function.
Warning
Failure to successfully complete this function indicates bus errors and hence a fatal error that will prevent the application from proceeding.
Returns
The function returns M2M_SUCCESS for successful interrupt handling and a negative value otherwise.

References hif_handle_isr().

sint8 m2m_wifi_init ( tstrWifiInitParam pWifiInitParam)

Synchronous API to initialize the WINC driver.

Parameters
[in]pWifiInitParamThis is a pointer to the tstrWifiInitParam structure which holds the pointer to the application WIFI layer call back function, monitoring mode call back and tstrEthInitParam strucutre.
Precondition
Prior to this function call, application users must provide a call back function responsible for receiving all the wi-fi events that are received on the M2M_WIFI layer.
Warning
Failure to successfully complete function indicates that the driver couldn't be initialized and a fatal error will prevent the application from proceeding.
See Also
m2m_wifi_deinit tenuM2mStaCmd
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
This function initializes the WINC driver by registering the callback function for the M2M_WIFI layer
(also the callback function for bypass mode/monitoring mode if defined), initializing the host
interface layer and the bus interfaces. Wi-Fi callback registering is essential to allow the
handling of the events received, in response to the asynchronous Wi-Fi operations.

The possible Wi-Fi events that are expected to be received through the callback
function (provided by the application) to the M2M_WIFI layer are listed below:

 - @ref M2M_WIFI_RESP_CON_STATE_CHANGED
 - @ref M2M_WIFI_RESP_CONN_INFO
 - @ref M2M_WIFI_REQ_DHCP_CONF
 - @ref M2M_WIFI_REQ_WPS
 - @ref M2M_WIFI_RESP_IP_CONFLICT
 - @ref M2M_WIFI_RESP_SCAN_DONE
 - @ref M2M_WIFI_RESP_SCAN_RESULT
 - @ref M2M_WIFI_RESP_CURRENT_RSSI
 - @ref M2M_WIFI_RESP_CLIENT_INFO
 - @ref M2M_WIFI_RESP_PROVISION_INFO
 - @ref M2M_WIFI_RESP_DEFAULT_CONNECT
 - @ref M2M_WIFI_RESP_ETHERNET_RX_PACKET (if bypass mode is enabled)
 - @ref M2M_WIFI_RESP_WIFI_RX_PACKET (if monitoring mode is enabled)

Any application using the WINC driver must call this function at the start of its main function.
Parameters
[in]pWifiInitParamThis is a pointer to a structure of type tstrWifiInitParam which contains pointers to the application WIFI layer callback function, monitoring mode callback and tstrEthInitParam structure (which contains initialization settings for bypass mode).
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Precondition
Prior to this function call, The application should initialize the BSP using nm_bsp_init. Also, application users must provide a call back function responsible for receiving all the wi-fi events that are received on the M2M_WIFI layer.
Warning
Failure to successfully complete indicates that the driver could not be initialized and a fatal error will prevent the application from proceeding, proper error handling should be implemented by the application.
See Also
m2m_wifi_deinit m2m_wifi_init_hold m2m_wifi_init_start tstrWifiInitParam tenuM2mStaCmd tenuM2mStaCmd
This function initializes the WINC driver by registering the callback function for the M2M_WIFI layer
(also the callback function for bypass mode/monitoring mode if defined), initializing the host
interface layer and the bus interfaces. Wi-Fi callback registering is essential to allow the
handling of the events received, in response to the asynchronous Wi-Fi operations.

The possible Wi-Fi events that are expected to be received through the callback
function (provided by the application) to the M2M_WIFI layer are listed below:

 - @ref M2M_WIFI_RESP_CON_STATE_CHANGED
 - @ref M2M_WIFI_RESP_CONN_INFO
 - @ref M2M_WIFI_REQ_DHCP_CONF
 - @ref M2M_WIFI_REQ_WPS
 - @ref M2M_WIFI_RESP_IP_CONFLICT
 - @ref M2M_WIFI_RESP_SCAN_DONE
 - @ref M2M_WIFI_RESP_SCAN_RESULT
 - @ref M2M_WIFI_RESP_CURRENT_RSSI
 - @ref M2M_WIFI_RESP_CLIENT_INFO
 - @ref M2M_WIFI_RESP_PROVISION_INFO
 - @ref M2M_WIFI_RESP_DEFAULT_CONNECT
 - @ref M2M_WIFI_RESP_ETHERNET_RX_PACKET (if bypass mode is enabled)
 - @ref M2M_WIFI_RESP_WIFI_RX_PACKET (if monitoring mode is enabled)

Any application using the WINC driver must call this function at the start of its main function.
Parameters
[in]pWifiInitParamThis is a pointer to a variable of type tstrWifiInitParam which contains pointers to the application WIFI layer callback function, monitoring mode callback and tstrEthInitParam structure (which contains initialization settings for bypass mode).
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Precondition
Prior to this function call, the application should initialize the BSP using nm_bsp_init. Also, the application must provide a callback function responsible for receiving all the wi-fi events that are received on the M2M_WIFI layer.
Warning
Failure to successfully complete indicates that the driver could not be initialized and a fatal error will prevent the application from proceeding, proper error handling should be implemented by the application.
See Also
m2m_wifi_deinit m2m_wifi_init_hold m2m_wifi_init_start m2m_wifi_reinit m2m_wifi_reinit_hold m2m_wifi_reinit_start m2m_wifi_download_mode tstrWifiInitParam tenuM2mStaCmd

References M2M_SUCCESS, m2m_wifi_init_hold(), and m2m_wifi_init_start().

sint8 m2m_wifi_p2p_disconnect ( void  )
Precondition
The p2p mode must have be enabled and active before a disconnect can be called.
See Also
m2m_wifi_p2p
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_DISABLE_P2P, and NULL.

NMI_API sint8 m2m_wifi_req_client_ctrl ( uint8  cmd)

Send a command to the PS Client (An WINC board running the ps_firmware), if the PS client send any commands it will be received in wifi_cb M2M_WIFI_RESP_CLIENT_INFO.

Asynchronous command sending function to the PS Client.

Parameters
[in]cmdControl command sent from PS Server to PS Client (command values defined by the application).
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_req_server_init, M2M_WIFI_RESP_CLIENT_INFO
Precondition
m2m_wifi_req_server_init should be called first
Asynchronous command sending function to the PS Client (a WINC board running the ps_firmware)
if the PS client sends any command, it will be received through the @ref M2M_WIFI_RESP_CLIENT_INFO event.
Parameters
[in]cmdControl command sent from PS Server to PS Client (command values defined by the application)
Precondition
m2m_wifi_req_server_init should be called first.
Warning
This mode is not supported in the current release.
See Also
m2m_wifi_req_server_init M2M_WIFI_RESP_CLIENT_INFO
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

References hif_send(), M2M_ERR, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_CLIENT_CTRL, NULL, and tstrM2Mservercmd::u8cmd.

sint8 m2m_wifi_req_curr_rssi ( void  )

Request the current RSSI for the current connected AP, the response received in wifi_cb M2M_WIFI_RESP_CURRENT_RSSI.

Asynchronous API to request the current Receive Signal Strength (RSSI) of the current connection.

See Also
M2M_WIFI_RESP_CURRENT_RSSI
Returns
The function shall return M2M_SUCCESS for success and a negative value otherwise.
Precondition
- A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered before intialization. Registering the callback is done through passing it to the m2m_wifi_init through the tstrWifiInitParam intialization structure.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Example

The code snippet demonstrates how the rssi request is called in the application's main function and the handling of event received in the callback.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
sint8 *rssi = (sint8*)pvMsg;
M2M_INFO("ch rssi %d\n",*rssi);
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
This function will result in the application receiving the RSSI via a
@ref M2M_WIFI_RESP_CURRENT_RSSI event.
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered during initialization. Registration of the callback is done through passing it to m2m_wifi_init via the tstrWifiInitParam initialization structure.
  • The event M2M_WIFI_RESP_CURRENT_RSSI must be handled in the callback to receive the requested Rssi information.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.

Example

The code snippet demonstrates how the RSSI request is called in the application's main function and the handling of the event received in the callback.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
sint8 *rssi = (sint8*)pvMsg;
M2M_INFO("ch rssi %d\n",*rssi);
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_CURRENT_RSSI, and NULL.

sint8 m2m_wifi_req_scan_result ( uint8  index)

Reads the AP information from the Scan Result list with the given index, the response received in wifi_cb M2M_WIFI_RESP_SCAN_RESULT, the response pointer should be casted with tstrM2mWifiscanResult structure.

Asynchronous API to request the information of an access point discovered via scanning.

Synchronous call to read the AP information from the SCAN Result list.

Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found
See Also
tstrM2mWifiscanResult,m2m_wifi_get_num_ap_found,m2m_wifi_request_scan
Returns
The function shall return M2M_SUCCESE for success and a negative value otherwise
Precondition
m2m_wifi_request_scan need to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found
Warning
Function used only in STA mode only. the scan result updated only if scan request called, else it will be cashed in firmware for the host scan request result, which mean if large delay occur between the scan request and the scan result request, the result will not be up-to-date
Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found
See Also
tstrM2mWifiscanResult m2m_wifi_get_num_ap_found m2m_wifi_request_scan
Precondition
m2m_wifi_request_scan needs to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the m2m_wifi_init function.
  • The event M2M_WIFI_RESP_SCAN_RESULT must be handled in the callback to receive the requested connection information.
Warning
Tthe scan results are updated only if the scan request is called. Calling this function only without a scan request will lead to firmware errors. Refrain from introducing a large delay between the scan request and the scan result request.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found
See Also
tstrM2mWifiscanResult,m2m_wifi_get_num_ap_found,m2m_wifi_request_scan
Returns
The function shall return M2M_SUCCESS for success and a negative value otherwise
Precondition
m2m_wifi_request_scan need to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found
Warning
Function used only in STA mode only. the scan result updated only if scan request called, else it will be cashed in firmware for the host scan request result, which mean if large delay occur between the scan request and the scan result request, the result will not be up-to-date
Synchronous call to read the AP information from the SCAN Result list with the given index.
This function is expected to be called when the response events @ref M2M_WIFI_RESP_SCAN_RESULT or
@ref M2M_WIFI_RESP_SCAN_DONE are received in the wi-fi callback function.
The response information received can be obtained through the casting to the 
@ref tstrM2mWifiscanResult structure.
Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tstrM2mWifiscanResult m2m_wifi_get_num_ap_found m2m_wifi_request_scan
Precondition
  • m2m_wifi_request_scan needs to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found.
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the m2m_wifi_init function.
  • The event M2M_WIFI_RESP_SCAN_RESULT must be handled in the callback to receive the requested scan information.
Warning
  • Function used in STA mode only. the scan results are updated only if the scan request is called.
  • Calling this function only without a scan request will lead to firmware errors.
  • Application code should refrain from introducing a large delay between the scan request and the scan result request, to prevent errors occurring.

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found
See Also
tstrM2mWifiscanResult,m2m_wifi_get_num_ap_found,m2m_wifi_request_scan
Returns
The function shall return M2M_SUCCESS for success and a negative value otherwise
Precondition
m2m_wifi_request_scan need to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found
Warning
Function used only in STA mode only. the scan result updated only if scan request called, else it will be cashed in firmware for the host scan request result, which mean if large delay occur between the scan request and the scan result request, the result will not be up-to-date
This function allows the information of any discovered access point to be retrieved. When a
scan is completed, the application is informed of the number of networks (access points)
discovered. Calling this function with an index, N, will return the information for the Nth
access point. The information will be returned to the application via a
@ref M2M_WIFI_RESP_SCAN_RESULT event, and the response data may be obtained through casting
the pointer (pvMsg) to @ref tstrM2mWifiscanResult.
Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tstrM2mWifiscanResult m2m_wifi_get_num_ap_found m2m_wifi_request_scan
Precondition
  • m2m_wifi_request_scan must be called first to ensure up to date results are available.
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered in order to receive scan data after calling this function. Registration of the callback is done via the m2m_wifi_init function.
  • The event M2M_WIFI_RESP_SCAN_RESULT must be handled in the callback to receive the requested scan information.
Warning
  • This API is valid only for STA mode, it may be called regardless of the connection state (connected or disconnected).
  • Calling this function without first issuing a scan request may lead to stale data being recovered.
  • Application code should refrain from introducing significant delays between issuing the scan request and scan result requests.

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in the response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SCAN_RESULT, NULL, and tstrM2mReqScanResult::u8Index.

NMI_API sint8 m2m_wifi_req_server_init ( uint8  ch)

Initialize the PS Server, The WINC support non secure communication with another WINC, (SERVER/CLIENT) through one byte command (probe request and probe response) without any connection setup.

Synchronous function to initialize the PS Server.

Parameters
[in]chServer listening channel
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_req_client_ctrl
Warning
The server mode can't be used with any other modes (STA/AP).
The WINC supports non secure communication with another WINC,
(SERVER/CLIENT) through one byte command (probe request and probe response) without any connection setup.
The server mode can't be used with any other modes (STA/AP)
Parameters
[in]chServer listening channel
See Also
m2m_wifi_req_client_ctrl
Warning
This mode is not supported in the current release.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

References hif_send(), M2M_ERR, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SERVER_INIT, NULL, and tstrM2mServerInit::u8Channel.

sint8 m2m_wifi_request_scan ( uint8  ch)

Asynchronous API to request the WINC IC to scan for networks.

Asynchronous API to request the WINC to scan for networks.

Parameters
[in]chRF Channel ID for SCAN operation. It should be set according to tenuM2mScanCh. With a value of M2M_WIFI_CH_ALL(255)), means to scan all channels.
Precondition
See Also
M2M_WIFI_RESP_SCAN_DONE M2M_WIFI_RESP_SCAN_RESULT tpfAppWifiCb tstrM2mWifiscanResult tenuM2mScanCh m2m_wifi_init m2m_wifi_handle_events m2m_wifi_req_scan_result
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
Scan statuses are delivered to the application via the Wi-Fi event callback (@ref tpfAppWifiCb) in
three stages. The first step involves the event @ref M2M_WIFI_RESP_SCAN_DONE which, if successful,
provides the number of detected networks (access points). The application must then read the list
of access points via multiple calls to the asynchronous @ref m2m_wifi_req_scan_result API. For
each call to this function, the application will receive (step three) the event
@ref M2M_WIFI_RESP_SCAN_RESULT.
Parameters
[in]chRF Channel ID for SCAN operation. It should be set according to tenuM2mScanCh, with a value of M2M_WIFI_CH_ALL to scan all channels.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Precondition
Warning
This API is valid only for STA mode, it may be called regardless of connection state (connected or disconnected states).
See Also
M2M_WIFI_RESP_SCAN_DONE M2M_WIFI_RESP_SCAN_RESULT tpfAppWifiCb tstrM2mWifiscanResult tenuM2mScanCh m2m_wifi_init m2m_wifi_handle_events m2m_wifi_req_scan_result

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
Scan statuses are delivered to the application via the Wi-Fi event callback (@ref tpfAppWifiCb) in
three stages. The first step involves the event @ref M2M_WIFI_RESP_SCAN_DONE which, if successful,
provides the number of detected networks (access points). The application must then read the list
of access points via multiple calls to the asynchronous @ref m2m_wifi_req_scan_result API. For
each call to this function, the application will receive (step three) the event
@ref M2M_WIFI_RESP_SCAN_RESULT.
Parameters
[in]chRF Channel ID for SCAN operation. It should be set according to tenuM2mScanCh, with a value of M2M_WIFI_CH_ALL to scan all channels.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Precondition
Warning
This API is valid only for STA mode, it may be called regardless of connection state (connected or disconnected states).
See Also
M2M_WIFI_RESP_SCAN_DONE M2M_WIFI_RESP_SCAN_RESULT tpfAppWifiCb tstrM2mWifiscanResult tenuM2mScanCh m2m_wifi_init m2m_wifi_handle_events m2m_wifi_req_scan_result

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult = (tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}

References gu8scanInProgress, hif_send(), M2M_ERR_INVALID_ARG, M2M_ERR_SCAN_IN_PROGRESS, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_CH_1, M2M_WIFI_CH_14, M2M_WIFI_CH_ALL, M2M_WIFI_REQ_SCAN, NULL, and tstrM2MScan::u8ChNum.

sint8 m2m_wifi_send_crl ( tstrTlsCrlInfo pCRL)

Asynchronous API that notifies the WINC with the Certificate Revocation List.

Parameters
[in]pCRLPointer to the structure containing certificate revocation list details.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.

References hif_send(), M2M_ERR_FAIL, M2M_REQ_DATA_PKT, M2M_REQ_GROUP_SSL, M2M_SSL_IND_CRL, and NULL.

sint8 m2m_wifi_set_cust_InfoElement ( uint8 pau8M2mCustInfoElement)

API to add or remove a user-defined Information Element.

Asynchronous API to add or remove a user-defined Information Element.

Synchronous function to Add/Remove user-defined Information Element to the WIFIBeacon and Probe Response frames while chip mode is Access Point Mode.\n
According to the information element layout shown bellow, if it is required to set new data for the information elements, pass in the buffer with the
information according to the sizes and ordering defined bellow. However, if it's required to delete these IEs, fill the buffer with zeros.
Parameters
[in]pau8M2mCustInfoElementPointer to Buffer containing the IE to be sent. It is the application developer's responsibility to ensure on the correctness of the information element's ordering passed in.
Warning
Size of All elements combined must not exceed 255 byte. Used in Access Point Mode.
Note
IEs Format will be follow the following layout:
    --------------- ---------- ---------- ------------------- -------- -------- ----------- -----------------------
              | Byte[0]       | Byte[1]  | Byte[2]  | Byte[3:length1+2] | ..... | Byte[n] | Byte[n+1] | Byte[n+2:lengthx+2]  | 
    |---------------|----------|----------|-------------------|-------- --------|-----------|---------------------|
              | #of all Bytes | IE1 ID   | Length1  | Data1(Hex Coded)  | ..... | IEx ID  | Lengthx   | Datax(Hex Coded)     | 
    --------------- ---------- ---------- ------------------- -------- -------- ----------- -----------------------
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
m2m_wifi_enable_sntp

Example

The example demonstrates how the information elements are set using this function.

char elementData[21];
static char state = 0; // To Add, Append, and Delete
if(0 == state) { //Add 3 IEs
state = 1;
//Total Number of Bytes
elementData[0]=12;
//First IE
elementData[1]=200; elementData[2]=1; elementData[3]='A';
//Second IE
elementData[4]=201; elementData[5]=2; elementData[6]='B'; elementData[7]='C';
//Third IE
elementData[8]=202; elementData[9]=3; elementData[10]='D'; elementData[11]=0; elementData[12]='F';
} else if(1 == state) {
//Append 2 IEs to others, Notice that we keep old data in array starting with\n
//element 13 and total number of bytes increased to 20
state = 2;
//Total Number of Bytes
elementData[0]=20;
//Fourth IE
elementData[13]=203; elementData[14]=1; elementData[15]='G';
//Fifth IE
elementData[16]=204; elementData[17]=3; elementData[18]='X'; elementData[19]=5; elementData[20]='Z';
} else if(2 == state) { //Delete All IEs
state = 0;
//Total Number of Bytes
elementData[0]=0;
}
This function allows the application to provide a custom Information Element to the
WINC that will be included in all beacon and probe response frames, while in Access Point mode.
If it is required to delete these IEs, fill the buffer with zeros.
Parameters
[in]pau8M2mCustInfoElementPointer to Buffer containing the IE to be used. It is the application developer's responsibility to ensure on the correctness of the information element's ordering passed in. If the pointer is null, this removes any current custom IE. If non-null, the pointer must reference data in the following format:
    --------------- ---------- ---------- ------------------- -------- -------- ----------- -----------------------
    | Byte[0]       | Byte[1]  | Byte[2]  | Byte[3:length1+2] | ..... | Byte[n] | Byte[n+1] | Byte[n+2:lengthx+2] |
    |---------------|----------|----------|-------------------|-------- --------|-----------|---------------------|
    | #of all Bytes | IE1 ID   | Length1  | Data1(Hex Coded)  | ..... | IEx ID  | Lengthx   | Datax(Hex Coded)    |
    --------------- ---------- ---------- ------------------- -------- -------- ----------- -----------------------
Warning
Size of All elements combined must not exceed 255 byte. Used in Access Point Mode.
Note
IEs Format will follow the above format.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
m2m_wifi_enable_sntp

Example

The example demonstrates how the information elements are set using this function.

char elementData[21];
static char state = 0; // To Add, Append, and Delete
if(0 == state) { //Add 3 IEs
state = 1;
//Total Number of Bytes
elementData[0]=12;
//First IE
elementData[1]=200; elementData[2]=1; elementData[3]='A';
//Second IE
elementData[4]=201; elementData[5]=2; elementData[6]='B'; elementData[7]='C';
//Third IE
elementData[8]=202; elementData[9]=3; elementData[10]='D'; elementData[11]=0; elementData[12]='F';
} else if(1 == state) {
//Append 2 IEs to others, Notice that we keep old data in array starting with\n
//element 13 and total number of bytes increased to 20
state = 2;
//Total Number of Bytes
elementData[0]=20;
//Fourth IE
elementData[13]=203; elementData[14]=1; elementData[15]='G';
//Fifth IE
elementData[16]=204; elementData[17]=3; elementData[18]='X'; elementData[19]=5; elementData[20]='Z';
} else if(2 == state) { //Delete All IEs
state = 0;
//Total Number of Bytes
elementData[0]=0;
}

References hif_send(), M2M_CUST_IE_LEN_MAX, M2M_ERR_FAIL, M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_CUST_INFO_ELEMENT, and NULL.

sint8 m2m_wifi_set_device_name ( uint8 pu8DeviceName,
uint8  u8DeviceNameLength 
)

Set the WILC1000 device name which is used as P2P device name.

Asynchronous API to set the Wi-Fi Direct "Device Name" of the WINC.

Set the WINC3400 device name which is used as P2P device name.

Asynchronous API to set the "Device Name" of the WINC IC.

Sets the WINC device name. The name string is used as a device name in DHCP hostname (option 12).

m2m_wifi_set_device_name Set the WILC device name which is to be used as a P2P device name.

Parameters
[in]pu8DeviceNameBuffer holding the device name.
[in]u8DeviceNameLengthLength of the device name.
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
Warning
The Function called once after initialization.
Parameters
[in]pu8DeviceNameBuffer holding the device name.
[in]u8DeviceNameLengthLength of the device name. Should not exceed the maximum device name's length M2M_DEVICE_NAME_MAX.
Warning
The function called once after initialization.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Sets the WINC device name. The name string is used as a device name in DHCP
hostname (option 12).
If a device is not set through this function a default name is assigned.
The default name is WINC-XX-YY, where XX and YY are the last 2 octets of the OTP 
MAC address. If OTP (eFuse) is programmed, then the default name is WINC-00-00.
Warning
The function called once after initialization.
Used for DHCP client hostname option (12).
Device name shall contain only characters allowed in valid internet host name as defined in RFC 952 and 1123.
Parameters
[in]pu8DeviceNameBuffer holding the device name. Device name is a null terminated C string.
[in]u8DeviceNameLengthLength of the device name. Should not exceed the maximum device name's length M2M_DEVICE_NAME_MAX (including null character).
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Sets the WINC device name. The name string is used as a device name in DHCP
hostname (option 12).
If a device is not set through this function a default name is assigned.
The default name is WINC-XX-YY, where XX and YY are the last 2 octets of the OTP
MAC address. If OTP (eFuse) is programmed, then the default name is WINC-00-00.
Warning
The function called once after initialization.
Used for DHCP client hostname option (12).
Device name shall contain only characters allowed in valid internet host name as defined in RFC 952 and 1123.
Parameters
[in]pu8DeviceNameBuffer holding the device name. Device name is a null terminated C string.
[in]u8DeviceNameLengthLength of the device name. Should not exceed the maximum device name's length M2M_DEVICE_NAME_MAX (including null character).
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.

References tstrM2MDeviceNameConfig::au8DeviceName, hif_send(), M2M_DEVICE_NAME_MAX, m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_DEVICE_NAME, and NULL.

sint8 m2m_wifi_set_lsn_int ( tstrM2mLsnInt pstrM2mLsnInt)

Set the Wi-Fi listen interval for power save operation. It is represented in units of AP Beacon periods.

Asynchronous API to set Wi-Fi listen interval for power save operation.

API to set Wi-Fi listen interval for power save operation.

Parameters
[in]pstrM2mLsnIntStructure holding the listen interval configurations.
Returns
The function SHALL return 0 for success and a negative value otherwise.
See Also
tstrM2mLsnInt , m2m_wifi_set_sleep_mode
Precondition
m2m_wifi_set_sleep_mode shall be called first
Warning
The Function called once after initialization.
Parameters
[in]pstrM2mLsnIntStructure holding the listen interval configurations.
Precondition
Function m2m_wifi_set_sleep_mode shall be called first
Warning
The function should be called once after initialization.
See Also
tstrM2mLsnInt m2m_wifi_set_sleep_mode
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
This is one of the two synchronous power-save setting functions that
allow the host MCU application to tweak the system power consumption. Such tweaking can be done by modifying the 
Wi-Fi listen interval. The listen interval is how many beacon periods the station can sleep before it wakes up to receive data buffered in the AP.
It is represented in units of AP beacon periods(100ms).  
Warning
The function should be called once after initialization.
Parameters
[in]pstrM2mLsnIntStructure holding the listen interval configuration.
Precondition
The function m2m_wifi_set_sleep_mode shall be called first, to set the power saving mode required.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tstrM2mLsnInt m2m_wifi_set_sleep_mode
This is one of the two synchronous power-save setting functions that
allow the host MCU application to tweak the system power consumption. Such tweaking can be done by modifying the
Wi-Fi listen interval. The listen interval is how many beacon periods the station can sleep before it wakes up to receive data buffered in the AP.
It is represented in units of AP beacon periods(100ms).
Warning
The function should be called once after initialization.
Parameters
[in]pstrM2mLsnIntStructure holding the listen interval configuration.
Precondition
The function m2m_wifi_set_sleep_mode shall be called first, to set the power saving mode required.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tstrM2mLsnInt m2m_wifi_set_sleep_mode

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_LSN_INT, and NULL.

NMI_API sint8 m2m_wifi_set_receive_buffer ( void *  pvBuffer,
uint16  u16BufferLen 
)

set the ethernet receive buffer, should be called in the receive call back.

Synchronous function for setting or modifying the receiver buffer's length.

Parameters
[in]pvBufferPointer to the ethernet receive buffer.
[in]u16BufferLenLength of the buffer.
Returns
The function SHALL return 0 for success and a negative value otherwise.
Synchronous function for setting or modifying the receiver buffer's length. 
In the ETHERNET/bypass mode the application should define a callback of type 
@ref tpfAppEthCb, through which the application handles the received 
ethernet frames. It is through this callback function that the user can 
dynamically modify the length of the currently used receiver buffer.
Parameters
[in]pvBufferPointer to Buffer to receive data. NULL pointer causes a negative error M2M_ERR_FAIL.
[in]u16BufferLenLength of data to be received. Maximum length of data should not exceed the size defined by TCP/IP defined as SOCKET_BUFFER_MAX_LENGTH
Warning
This function is available in the Ethernet/bypass mode ONLY. Make sure that the application defines ETH_MODE.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
m2m_wifi_enable_mac_mcast m2m_wifi_send_ethernet_pkt
Synchronous function for setting or modifying the receiver buffer's length.
In the ETHERNET/bypass mode the application should define a callback of type
@ref tpfAppEthCb, through which the application handles the received
ethernet frames. It is through this callback function that the user can
dynamically modify the length of the currently used receiver buffer.
Parameters
[in]pvBufferPointer to Buffer to receive data. NULL pointer causes a negative error M2M_ERR_FAIL.
[in]u16BufferLenLength of data to be received. Maximum length of data should not exceed the size defined by TCP/IP defined as SOCKET_BUFFER_MAX_LENGTH
Warning
This function is available in the Ethernet/bypass mode ONLY. Make sure that the application defines ETH_MODE.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
m2m_wifi_enable_mac_mcast m2m_wifi_send_ethernet_pkt

References gau8ethRcvBuf, gu16ethRcvBufSize, M2M_ERR, M2M_ERR_FAIL, M2M_SUCCESS, and NULL.

sint8 m2m_wifi_set_sleep_mode ( uint8  PsTyp,
uint8  BcastEn 
)

Set the power saving mode for the WILC1000.

Synchronous API to set the power-save mode of the WINC.

Set the power saving mode for the WINC3400.

Synchronous API to set the power-save mode of the WINC IC.

Set the power saving mode for the WINC1500.

Parameters
[in]PsTypDesired power saving mode. Supported types are defined in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WILC1000 must be awake each DTIM Beacon for receiving Broadcast traffic. If it is 0, the WILC1000 will not wakeup at the DTIM Beacon, but its wakeup depends only on the the configured Listen Interval.
Returns
The function SHALL return 0 for success and a negative value otherwise.
See Also
tenuPowerSaveModes
Warning
The function called once after initialization.
Parameters
[in]PsTypDesired power saving mode. Supported types are defined in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WILC1000 must be awake each DTIM beacon for receiving broadcast traffic. If it is 0, the WILC1000 will not wakeup at the DTIM beacon, but its wakeup depends only on the the configured Listen Interval.
See Also
tenuPowerSaveModes m2m_wifi_get_sleep_mode
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Parameters
[in]PsTypDesired power saving mode. Supported types are defined in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WINC1500 must be awake each DTIM Beacon for receiving Broadcast traffic. If it is 0, the WINC1500 will not wakeup at the DTIM Beacon, but its wakeup depends only on the the configured Listen Interval.
Returns
The function SHALL return 0 for success and a negative value otherwise.
See Also
tenuPowerSaveModes
Warning
The function called once after initialization.
This is one of the two synchronous power-save setting functions that allow the host MCU application
to tweak the system power consumption. Such tweaking can be done through one of two ways:
- 1) Changing the power save mode, to one of the allowed power save modes (see @ref tenuPowerSaveModes). This is done by setting the first parameter.
- 2) Configuring DTIM monitoring: Configuring beacon monitoring parameters by enabling or disabling the reception of broadcast/multicast data.
     This is done by setting the second parameter.
Parameters
[in]PsTypDesired power saving mode. Supported types are enumerated in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WINC will be awake for each DTIM beacon in order to check for and receive broadcast traffic. If it is 0, the WINC will ignore broadcast traffic. Through this flag the WINC will not wakeup at the DTIM beacon, but instead it will wakeup only based on the configured Listen Interval.
Warning
The function called once after initialization.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
See Also
tenuPowerSaveModes m2m_wifi_get_sleep_mode m2m_wifi_set_lsn_int
Parameters
[in]PsTypDesired power saving mode. Supported types are defined in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WINC3400 must be awake each DTIM Beacon for receiving Broadcast traffic. If it is 0, the WINC3400 will not wakeup at the DTIM Beacon, but its wakeup depends only on the the configured Listen Interval.
Returns
The function SHALL return 0 for success and a negative value otherwise.
See Also
tenuPowerSaveModes
Warning
The function called once after initialization.
This is one of the two synchronous power-save setting functions that allow the host MCU application
to tweak the system power consumption. Such tweaking can be done through one of two ways:
- 1) Changing the power save mode, to one of the allowed power save modes (see @ref tenuPowerSaveModes). This is done by setting the first parameter.
- 2) Configuring DTIM monitoring: Configuring beacon monitoring parameters by enabling or disabling the reception of broadcast/multicast data.
     This is done by setting the second parameter.
Parameters
[in]PsTypDesired power saving mode. Supported types are enumerated in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If set to 1, the WINC will wake for each DTIM beacon to ensure broadcast traffic can be received. If set to 0, the WINC will not wakeup at the DTIM beacon, ignoring broadcast traffic, instead it will wake every N beacon periods, as per the negotiated Listen Interval.
Warning
The function called once after initialization.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
See Also
tenuPowerSaveModes m2m_wifi_get_sleep_mode m2m_wifi_set_lsn_int

References hif_send(), hif_set_sleep_mode(), M2M_INFO, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SLEEP, NULL, tstrM2mPsType::u8BcastEn, and tstrM2mPsType::u8PsType.

sint8 m2m_wifi_set_tx_power ( uint8  u8TxPwrLevel)

set the TX power

Set the TX power tenuM2mTxPwrLevel.

set the TX power tenuM2mTxPwrLevel

Parameters
[in]u8TxPwrLevelTX power ppa to one of these values: 0dBm, 3dBm, 6dBm, 9dBm, 12dBm, 15dBm, 18dBm. Other values between these steps will be floored to the nearest supported level. A maximum level might be enforced by the firmware to comply to RF regulations
Returns
The function SHALL return M2M_SUCCESE for success and a negative value otherwise.
See Also
Precondition
m2m_wifi_init
Warning
Parameters
[in]u8TxPwrLevelchange the TX power tenuM2mTxPwrLevel
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See Also
tenuM2mTxPwrLevel
Precondition
m2m_wifi_init
Warning
Parameters
[in]u8TxPwrLevelChange the TX power based on the enumeration tenuM2mTxPwrLevel.
Precondition
Must be called after the initialization and before any connection request and can't be changed in runtime.
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See Also
tenuM2mTxPwrLevel m2m_wifi_init
Parameters
[in]u8TxPwrLevelchange the TX power tenuM2mTxPwrLevel
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See Also
tenuM2mTxPwrLevel
Precondition
m2m_wifi_init
Warning
Parameters
[in]u8TxPwrLevelChange the TX power based on the enumeration tenuM2mTxPwrLevel.
Precondition
Must be called after the initialization and before any connection request and can't be changed in runtime.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
tenuM2mTxPwrLevel m2m_wifi_init

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SET_TX_POWER, NULL, and tstrM2mTxPwrLevel::u8TxPwrLevel.

sint8 m2m_wifi_wps ( uint8  u8TriggerType,
const char *  pcPinNumber 
)

Asynchronous API to engage the WINC IC's Wi-Fi Protected Setup (enrollee) function.

Asynchronous API to engage the WINC Wi-Fi Protected Setup (enrollee) function.

Parameters
[in]u8TriggerTypeWPS Trigger method. Could be:
[in]pcPinNumberPIN number for WPS PIN method. It is not used if the trigger type is WPS_PBC_TRIGGER. It must follow the rules stated by the WPS Standard.
Warning
This function is not allowed in AP or P2P modes.
Precondition
  • A Wi-Fi notification callback of type (tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the m2m_wifi_init.
  • The event M2M_WIFI_REQ_WPS must be handled in the callback to receive the WPS status.
  • The WILC device MUST be in IDLE or STA mode. If AP or P2P mode is active, the WPS will not be performed.
  • The m2m_wifi_handle_events MUST be called to receive the responses in the callback.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_REQ_WPS tenuWPSTrigger tstrM2MWPSInfo
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Example

The code snippet shows an example of how wifi wps is triggered .

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
tstrM2MWPSInfo *pstrWPS = (tstrM2MWPSInfo*)pvMsg;
if(pstrWPS->u8AuthType != 0)
{
printf("WPS SSID : %s\n",pstrWPS->au8SSID);
printf("WPS PSK : %s\n",pstrWPS->au8PSK);
printf("WPS SSID Auth Type : %s\n",pstrWPS->u8AuthType == M2M_WIFI_SEC_OPEN ? "OPEN" : "WPA/WPA2");
printf("WPS Channel : %d\n",pstrWPS->u8Ch + 1);
// establish Wi-Fi connection
m2m_wifi_connect((char*)pstrWPS->au8SSID, (uint8)m2m_strlen(pstrWPS->au8SSID),
pstrWPS->u8AuthType, pstrWPS->au8PSK, pstrWPS->u8Ch);
}
else
{
printf("(ERR) WPS Is not enabled OR Timedout\n");
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Trigger WPS in Push button mode.
while(1)
{
}
}
}
This function is called for the WINC to enter the WPS (Wi-Fi Protected Setup) mode. The result 
is passed to the Wi-Fi notification callback with the event @ref M2M_WIFI_REQ_WPS.
Parameters
[in]u8TriggerTypeWPS Trigger method. This may be:
[in]pcPinNumberPIN number for WPS PIN method. It is not used if the trigger type is WPS_PBC_TRIGGER. It must follow the rules stated by the WPS standard.
Precondition
  • A Wi-Fi notification callback of type (tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to m2m_wifi_init.
  • The event M2M_WIFI_REQ_WPS must be handled in the callback to receive the WPS status.
  • The WINC device MUST be in IDLE or STA mode. If AP mode is active, the WPS will not be performed.
  • The m2m_wifi_handle_events MUST be called periodically to receive the responses in the callback.
Warning
This function is not allowed in AP mode.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_REQ_WPS tenuWPSTrigger tstrM2MWPSInfo

Example

The code snippet shows an example of how wi-fi WPS is triggered .

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
tstrM2MWPSInfo *pstrWPS = (tstrM2MWPSInfo*)pvMsg;
if(pstrWPS->u8AuthType != 0)
{
// establish Wi-Fi connection
tstrNetworkId strNetworkId = {NULL, pstrWPS->au8SSID, (uint8)strlen((char*)(pstrWPS->au8SSID)), pstrWPS->u8Ch};
if(pstrWPS->u8AuthType == M2M_WIFI_SEC_OPEN)
{
}
else
{
tstrAuthPsk strAuthPsk = {NULL, pstrWPS->au8PSK, (uint8)strlen((char*)(pstrWPS->au8PSK))};
m2m_wifi_connect_psk(WIFI_CRED_SAVE_ENCRYPTED, &strNetworkId, &strAuthPsk);
}
printf("WPS SSID : %s\n",pstrWPS->au8SSID);
printf("WPS PSK : %s\n",pstrWPS->au8PSK);
printf("WPS SSID Auth Type : %s\n",pstrWPS->u8AuthType == M2M_WIFI_SEC_OPEN ? "OPEN" : "WPA/WPA2");
printf("WPS Channel : %d\n",pstrWPS->u8Ch);
}
else
{
printf("(ERR) WPS Is not enabled OR Timed out\n");
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Trigger WPS in Push button mode.
while(1)
{
}
}
}
This function can be called to make the WINC enter WPS (Wi-Fi Protected Setup) mode. The result
is passed to the Wi-Fi notification callback with the event @ref M2M_WIFI_REQ_WPS.
Parameters
[in]u8TriggerTypeWPS Trigger method. This may be:
[in]pcPinNumberValid only if the u8TriggerType is WPS_PIN_TRIGGER, this parameter contains the PIN number. The number must follow the format as given in the WSC1.0 specification.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Warning
This function is not allowed in AP or P2P modes.
Precondition
  • A Wi-Fi notification callback of type (tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to m2m_wifi_init.
  • The event M2M_WIFI_REQ_WPS must be handled in the callback to receive the WPS status.
  • The WINC device MUST be in IDLE or STA mode. If AP or P2P mode is active, the WPS will not be performed.
  • The m2m_wifi_handle_events MUST be called periodically to receive the responses in the callback.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_REQ_WPS tenuWPSTrigger tstrM2MWPSInfo

Example

The code snippet shows an example of how wi-fi WPS is triggered .

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
tstrM2MWPSInfo *pstrWPS = (tstrM2MWPSInfo*)pvMsg;
if(pstrWPS->u8AuthType != 0)
{
// establish Wi-Fi connection
tstrNetworkId strNetworkId = {NULL, pstrWPS->au8SSID, (uint8)strlen((char*)(pstrWPS->au8SSID)), pstrWPS->u8Ch};
if(pstrWPS->u8AuthType == M2M_WIFI_SEC_OPEN)
{
}
else
{
tstrAuthPsk strAuthPsk = {NULL, pstrWPS->au8PSK, (uint8)strlen((char*)(pstrWPS->au8PSK))};
m2m_wifi_connect_psk(WIFI_CRED_SAVE_ENCRYPTED, &strNetworkId, &strAuthPsk);
}
printf("WPS SSID : %s\n",pstrWPS->au8SSID);
printf("WPS PSK : %s\n",pstrWPS->au8PSK);
printf("WPS SSID Auth Type : %s\n",pstrWPS->u8AuthType == M2M_WIFI_SEC_OPEN ? "OPEN" : "WPA/WPA2");
printf("WPS Channel : %d\n",pstrWPS->u8Ch);
}
else
{
printf("(ERR) WPS Is not enabled OR Timed out\n");
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Trigger WPS in Push button mode.
while(1)
{
}
}
}

References tstrM2MWPSConnect::acPinNumber, gu8scanInProgress, hif_send(), m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_WPS, NULL, tstrM2MWPSConnect::u8TriggerType, and WPS_PIN_TRIGGER.

sint8 m2m_wifi_wps_disable ( void  )

Disable the WILC WPS operation.

Asynchronous API that disables Wi-Fi Protected Setup mode in the WINC.

Stops the ongoing WPS session.

Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Precondition
WINC should be already in WPS mode using m2m_wifi_wps.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
m2m_wifi_wps

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_DISABLE_WPS, and NULL.

tpfAppEthCb gpfAppEthCb = NULL
static

Referenced by m2m_wifi_cb(), and m2m_wifi_init_start().

tpfAppWifiCb gpfAppWifiCb = NULL
static
uint16 gu16ethRcvBufSize
static
volatile uint8 gu8ChNum
static