title: Using WINC1500 with a PIC32, scan not working properly
body: <p>I'm currently working on a project using a PIC32 and the wifi module ATWINC1500. I won't be able to give all the code but I'm on a test function that I can share.
  First, here is some settings and configuration I'm using:</p>
  <ul>
  <li>Processor : PIC32MZ1024EFE064</li>
  <li>IDE : MPLAB IDE 5.45</li>
  <li>Harmony version : 2.06</li>
  <li>Wifi Module : ATWINC1500</li>
  <li>Real Time OS : FreeRTOS</li>
  </ul>
  <p>What I'm trying to do is to connect the Wifi module to an existing Access Point using the Infrastructure mode. I'm able to get the number of access point around me but when I try to read information from those access points, information are empty, void or incorrect.
  Here is my code:</p>
  <pre><code>bool WIFI_Test_Infrastructure(void)
  {
      //Example: https://www.microchip.com/forums/m906568.aspx
      
      //Wait for WINC1500 to be initialized
      if(isWdrvExtReady() == false)
          return false;
      
      //Start a scan or wait for result
      IWPRIV_PARAM_SCAN scanner;
      IWPRIV_GET_PARAM param_scan = {
          .scan = scanner
      };
      iwpriv_get(SCANSTATUS_GET, &amp;param_scan);
      IWPRIV_SCAN_STATUS status = param_scan.scan.scanStatus;
      IWPRIV_EXECUTE_PARAM dummy_param;
      
      //Process StateMachine while scanning
      if(status == IWPRIV_SCAN_IDLE)
      {
          vTaskDelay(1000 / portTICK_PERIOD_MS);
  
          //Disconnect wifi from everything
          WDRV_Disconnect();
          
          vTaskDelay(1000 / portTICK_PERIOD_MS);
          
          while(WDRV_ConnectionState_Get() != WDRV_CONNECTION_STATE_NOT_CONNECTED)
              vTaskDelay(10 / portTICK_PERIOD_MS);
  
          vTaskDelay(1000 / portTICK_PERIOD_MS);
          
  
          WDRV_EXT_CmdScanStart();
          
          return false;
      }
      else if(status == IWPRIV_SCAN_IN_PROGRESS)
      {
          return false;
      }
      else if(status == IWPRIV_SCAN_NO_AP_FOUND)
      {
          iwpriv_execute(SCAN_START, &amp;dummy_param);
          return false;
      }
      else if(status == IWPRIV_SCAN_SUCCESSFUL)
      {
          vTaskDelay(1000 / portTICK_PERIOD_MS);
          
          //Read liste of wifi access point
          uint16_t wifi_number_AP;
          wifi_number_AP = m2m_wifi_get_num_ap_found();
          
          WDRV_SCAN_RESULT scanResult;
          tstrM2mWifiscanResult result;
          int i;
          for(i=0; i&lt;wifi_number_AP; i++)
          {
              m2m_wifi_req_scan_result(i);
  
              vTaskDelay(1000 / portTICK_PERIOD_MS);
  
              winc1500_scan_result_read(&amp;result); //ISSUE HAPPENED HERE
  
              vTaskDelay(1000 / portTICK_PERIOD_MS);
  
              memcpy((void *)scanResult.bssid, (void *)result.au8BSSID, sizeof(scanResult.bssid));
          }
          
          //SUCCESS
          return true;
      }
      else
      {
          return false;
      }
  }
  </code></pre>
  <p>So what happened here:</p>
  <ul>
  <li>First, you need to know that this function is called by a Thread Manager, that's why it returns false or true. I'm checking the state in which the scan is.</li>
  <li>I'm able to reach the SCAN_SUCCESSFUL part and the number of access point detected is correct.</li>
  <li>I labeled the line where the issue is happening. When I'm reading the result information of an access point, it is quite empty. Here is what I see in Debug Session (and it is the same result for all of access points):</li>
  </ul>
  <p><a href="https://i.stack.imgur.com/OB0FY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OB0FY.png" alt="Bug ATWINC1500" /></a></p>
  <p>I have been waiting for weeks before asking this. Hope someone can help or at least give me hints on things to check.
  If I missed information, do not hesitate to ask me.</p>
  <p>Thanks in advance!</p>
  <p>Adrien</p>