3.1.13.1 Execution

main.c - Initialize the ATWINC15x0 and connect to the AP with WPA/WPA2 enterprise security.

  1. Code summary:
    • Modify MAIN_WLAN_802_1X_USR_NAME, MAIN_WLAN_802_1X_PWD to hold the appropriate username and password, respectively. Modify MAIN_WLAN_DEVICE_NAME to hold the desired wireless network name.
      /** security information for Wi-Fi connection */
      #define MAIN_WLAN_DEVICE_NAME           "DEMO_AP" /**< Destination SSID */
      #define MAIN_WLAN_802_1X_USR_NAME       "atmeluser" /**< RADIUS user account name */
      #define MAIN_WLAN_802_1X_PWD            "12345678" /**< RADIUS user account password */
    • Connect to the AP with the given information.
      /* Connect to the enterprise network. */
      m2m_wifi_connect((char *)MAIN_WLAN_DEVICE_NAME, sizeof(MAIN_WLAN_DEVICE_NAME),
           M2M_WIFI_SEC_802_1X, (char *)&gstrCred1x, M2M_WIFI_CH_ALL);
    • The wifi_cb() function is called with the M2M_WIFI_RESP_CON_STATE_CHANGED message, where an appropriate action can be executed as a response. The new Wi-Fi state is passed onto the callback as part of the message.
      static void wifi_cb(uint8_t u8MsgType, void *pvMsg)
      {
          switch (u8MsgType) {
          case M2M_WIFI_RESP_CON_STATE_CHANGED:
          {
      	tstrM2mWifiStateChanged *pstrWifiState = (tstrM2mWifiStateChanged *)pvMsg;
      	if (pstrWifiState->u8CurrState == M2M_WIFI_CONNECTED) {
             /* Take action on connection successful */
    • Once the DHCP negotiation completes, the wifi_cb() function is called with the M2M_WIFI_REQ_DHCP_CONF message.
      static void wifi_cb(uint8_t u8MsgType, void *pvMsg)
      {
          case M2M_WIFI_REQ_DHCP_CONF:
          {
      	uint8_t *pu8IPAddress = (uint8_t *)pvMsg;
      	printf("Wi-Fi connected\r\n");
      	printf("Wi-Fi IP is %u.%u.%u.%u\r\n",
      			pu8IPAddress[0], pu8IPAddress[1], pu8IPAddress[2], pu8IPAddress[3]);
  2. Prepare an AP that supports WPA/WPA2 enterprise security. Before configuring the RADIUS server settings in the AP, you will need to know certain parameters. Ask your network administrator for this information and configure it in the AP.
    • Username
    • Password
    • Name of wireless network
    • Root certificate file
  3. Download the root certificate generated from the previous step to the ATWINC15x0/ATWINC3400 using the RootCertDownload.bat file.
  4. Build and run the application. If the device has connected successfully, the IP address assigned by DHCP will be displayed on the terminal program.
Note: To connect to the enterprise security network, the root certificate must be installed.
Figure 3-19. Supported 802.1x EAP (Extensible Authentication Protocol)