3.5 Example Code

The following example code shows the initialization flow, as described in the previous sections.

static void wifi_cb(uint8_t u8MsgType, void *pvMsg)
{

}
int main (void)
{
	tstrWifiInitParam param;
	nm_bsp_init();
	
	m2m_memset((uint8*)&param, 0, sizeof(param));
	param.pfAppWifiCb = wifi_cb;
	
	/*intilize the WINC Driver*/
	ret = m2m_wifi_init(&param);
	if (M2M_SUCCESS != ret){
		M2M_ERR("Driver Init Failed <%d>\n",ret);
		while(1);
	}
	
	while(1){
		/* Handle the app state machine plus the WINC event handler */ 
		while(m2m_wifi_handle_events(NULL) != M2M_SUCCESS) {
		}
	}
}