5.4.1.2 Example Code for Connecting to PEAP Enterprise Network with TLS as Phase2 Authentication and EAP- TLS

/** security information for Wi-Fi connection */
#define MAIN_WLAN_SSID		           "WINC1500_ENTERPRISE" /**< Destination SSID */
#define MAIN_WLAN_802_1X_USR_NAME       "DEMO_USER" /**< RADIUS user account name */
const uint8_t modulus[] = { /** private key modulus extracted from key file */ };
const uint8_t exponent[] = { /** private key exponent coefficient extracted from  key file */ };
const uint8_t certificate[] = { /** certificate coefficient  corresponding to Private Key */ };

int main(void)
{
	int8_t ret;
	tstrWifiInitParam param;
	tstrNetworkId networkId;
	tstrAuth1xTls tls_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) {
		}
	}
	printf("Username:%s\r\n",MAIN_WLAN_802_1X_USR_NAME);

	/* Connect to the enterprise network. */
	networkId.pu8Bssid = NULL;
	networkId.pu8Ssid = (uint8 *)MAIN_WLAN_SSID;
	networkId.u8SsidLen = strlen(MAIN_WLAN_SSID);
	networkId.enuChannel = M2M_WIFI_CH_ALL;

	tls_credential.pu8Domain = NULL;
	tls_credential.pu8UserName = (uint8 *)MAIN_WLAN_802_1X_USR_NAME;
	tls_credential.pu8PrivateKey_Mod = (uint8 *)modulus;
 	tls_credential.pu8PrivateKey_Exp = (uint8 *)exponent;
 	tls_credential.pu8Certificate = (uint8 *)certificate;
 	tls_credential.u16UserNameLen = strlen(MAIN_WLAN_802_1X_USR_NAME);
 	tls_credential.u16PrivateKeyLen = sizeof(modulus);
 	tls_credential.u16CertificateLen = sizeof(certificate);
  	tls_credential.bUnencryptedUserName = true;
  	tls_credential.bPrependDomain = true;

	printf("Connecting to %s...\r\n\t\tUsername:%s\r\n",networkId.pu8Ssid,tls_credential.pu8UserName);
			
 	m2m_wifi_connect_1x_tls(WIFI_CRED_SAVE_ENCRYPTED, &networkId, &tls_credential);

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

	return 0;
}