3.1.9.1 Execution

main.c - Initialize the ATWINC15x0 and start Provision Mode until one of the various APs is selected.

  1. Code summary:
    • Configure the network parameters in main.h.
      #define MAIN_HTTP_PROV_SERVER_DOMAIN_NAME    "atmelconfig.com"
          #define MAIN_M2M_DEVICE_NAME                 "WINC1500_00:00"
    • Start provision mode before entering the main loop.
      m2m_wifi_start_provision_mode((tstrM2MAPConfig *)&gstrM2MAPConfig, (char *)gacHttpProvDomainName, 1);
    • When your mobile device sends configuration information, the wifi_cb() function will be called with the M2M_WIFI_RESP_PROVISION_INFO message and you can connect to the AP with the given information.
      static void wifi_cb(uint8_t u8MsgType, void *pvMsg)
      {
          case M2M_WIFI_RESP_PROVISION_INFO:
          {
      	tstrM2MProvisionInfo *pstrProvInfo = (tstrM2MProvisionInfo *)pvMsg;
      	printf("wifi_cb: M2M_WIFI_RESP_PROVISION_INFO.\r\n");
      	if (pstrProvInfo->u8Status == M2M_SUCCESS) {
      	    m2m_wifi_connect((char *)pstrProvInfo->au8SSID, strlen((char *)pstrProvInfo->au8SSID), pstrProvInfo->u8SecType,
      		pstrProvInfo->au8Password, M2M_WIFI_CH_ALL);
  2. Build the program and download it into the board.
  3. Start the application.