void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
if(u8WiFiEvent == M2M_WIFI_RESP_PROVISION_INFO)
{
tstrM2MProvisionInfo *provInfo = (tstrM2MProvisionInfo*)pvMsg;
if(provInfo->u8Status == M2M_SUCCESS)
{
// connect to the provisioned AP.
m2m_wifi_connect((char*)provInfo->au8SSID, strlen(provInfo ->au8SSID),
provInfo->u8SecType, provInfo->au8Password, M2M_WIFI_CH_ALL);
printf("PROV SSID : %s\n", provInfo->au8SSID);
printf("PROV PSK : %s\n", provInfo->au8Password);
}
else
{
printf("(ERR) Provisioning Failed\n");
}
}
}
int main()
{
tstrWifiInitParam param;
// Platform specific initializations.
// Driver initialization.
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(¶m))
{
tstrM2MAPConfig apConfig;
uint8 bEnableRedirect = 1;
strcpy(apConfig.au8SSID, "WINC_AP");
apConfig.u8ListenChannel = 1;
apConfig.u8SecType = M2M_WIFI_SEC_OPEN;
apConfig.u8SsidHide = 0;
// IP Address
apConfig.au8DHCPServerIP[0] = 192;
apConfig.au8DHCPServerIP[1] = 168;
apConfig.au8DHCPServerIP[2] = 1;
apConfig.au8DHCPServerIP[0] = 1;
m2m_wifi_start_provision_mode(&apConfig, "atmelconfig.com", bEnableRedirect);
while(1)
{
m2m_wifi_handle_events(NULL);
}
}
}