Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages

Asynchronous WPS triggering function.

This function is called for the WILC to enter the WPS (Wi-Fi Protected Setup) mode. The result is passed to the Wi-Fi notification callback with the event M2M_WIFI_REQ_WPS.

Functions

NMI_API sint8 m2m_wifi_wps (uint8 u8TriggerType, const char *pcPinNumber)
 Asynchronous API to engage the WINC IC's Wi-Fi Protected Setup (enrollee) function. More...
 

NMI_API 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)
{
}
}
}