5.4.1.1 Example Code for Connecting to Enterprise Network (PEAP and TTLSv0) with MSCHAPv2 as Phase2 Authentication

#define MAIN_WLAN_SSID		           "WINC1500_ENTERPRISE" /**< Destination SSID */
#define MAIN_WLAN_802_1X_USR_NAME       "DEMO_USER" /**< RADIUS user account name */
#define MAIN_WLAN_802_1X_PWD            "DemoPassword" /**< RADIUS user account password */

int main(void)
{
	int8_t ret;
	tstrWifiInitParam param;
	tstrNetworkId networkId;
	tstrAuth1xMschap2 mschapv2_credential;

	/* Initialize the board. */
	system_init();

	/* Initialize the UART console. */
	configure_console();
	printf(STRING_HEADER);

	/* Initialize the BSP. */
	nm_bsp_init();

	/* Initialize Wi-Fi parameters structure. */
	memset((uint8_t *)&param, 0, sizeof(tstrWifiInitParam));

	/* Initialize Wi-Fi driver with data and status callbacks. */
	param.pfAppWifiCb = wifi_cb;
	ret = m2m_wifi_init(&param);
	if (M2M_SUCCESS != ret) {
		printf("main: m2m_wifi_init call error!(%d)\r\n", ret);
		while (1) {
		}
	}

	networkId.pu8Bssid = NULL;
	networkId.pu8Ssid = (uint8 *)MAIN_WLAN_SSID;
	networkId.u8SsidLen = strlen(MAIN_WLAN_SSID);
	networkId.enuChannel = M2M_WIFI_CH_ALL;
	
	mschapv2_credential.pu8Domain = NULL;
	//mschapv2_credential.u16DomainLen = strlen(mschapv2_credential.pu8Domain);
	mschapv2_credential.pu8UserName = (uint8 *)MAIN_WLAN_802_1X_USR_NAME;
	mschapv2_credential.pu8Password = (uint8 *)MAIN_WLAN_802_1X_PWD;
	mschapv2_credential.u16UserNameLen = strlen(MAIN_WLAN_802_1X_USR_NAME);
	mschapv2_credential.u16PasswordLen = strlen(MAIN_WLAN_802_1X_PWD);
	mschapv2_credential.bUnencryptedUserName = false;
	mschapv2_credential.bPrependDomain = true;
	
	printf("Connecting to %s\r\n\tUsername:%s\r\n", MAIN_WLAN_SSID, MAIN_WLAN_802_1X_USR_NAME);
		
	m2m_wifi_connect_1x_mschap2( WIFI_CRED_SAVE_ENCRYPTED, &networkId, &mschapv2_credential);

	/* Infinite loop to handle a event from the WINC1500. */
	while (1) {
		while (m2m_wifi_handle_events(NULL) != M2M_SUCCESS) {
		}
	}

	return 0;
}