Page 1 of 1

Scan without connecting to AP

Posted: Tue Sep 18, 2018 8:45 am
by Dmytro_Medvid
Hi, everybody!

Is it possible to start scanning of available Wi-Fi network without connection to AP in STA mode? I always got next error:

Code: Select all

W (3298) wifi: Now is connecting, user scan invalid now!

Re: Scan without connecting to AP

Posted: Tue Sep 18, 2018 3:02 pm
by fly135
Totally possible. I do it all the time and send all the scanned APs to a phone app, which then allows the user to assign the SSID and password. It's not even possible to be connected since I don't have the SSID and password in the beginning.

John A

Re: Scan without connecting to AP

Posted: Wed Sep 19, 2018 7:21 am
by Dmytro_Medvid
May you send your code of Wi-Fi initializing and sanning process?

Re: Scan without connecting to AP

Posted: Wed Sep 19, 2018 3:43 pm
by fly135
Dmytro_Medvid wrote:May you send your code of Wi-Fi initializing and sanning process?
It's already on your computer....

$IDF_PATH\examples\wifi\scan\main

That example seems incomplete. I put this in the event handler...

Code: Select all

        case SYSTEM_EVENT_SCAN_DONE:
          wifiScanCallback(event->event_info.scan_done.number);
          break;
In the callback routine I process all the records...

Code: Select all

  uint16_t apCount;
  esp_wifi_scan_get_ap_num(&apCount);
  //printf("Number of access points found: %d:%d\n",apCount,num_ap);
  if (apCount == 0) {
    xTaskNotifyGive(l_scanning_task);
    return;
  }
  wifi_ap_record_t *list = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount);
  ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&apCount, list));
I really can't post all the code because it belongs to my employer.

John A