IDF example scan does not show ap's returned

iseries1
Posts: 4
Joined: Tue Apr 16, 2024 11:38 am

IDF example scan does not show ap's returned

Postby iseries1 » Fri Apr 19, 2024 3:16 pm

In the example code this function is used:
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));
It always returns 0 even though there are APs return in the results.

Code: Select all

����x�x⌂�������x�x���x��ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:7172
load:0x40078000,len:15540
load:0x40080400,len:4
0x40080400: _init at ??:?

ho 8 tail 4 room 4
load:0x40080404,len:3904
entry 0x40080640
I (31) boot: ESP-IDF v5.2.1 2nd stage bootloader
I (31) boot: compile time Apr 19 2024 09:51:20
I (31) boot: Multicore bootloader
I (35) boot: chip revision: v0.0
I (40) boot.esp32: SPI Speed      : 40MHz
I (43) boot.esp32: SPI Mode       : DIO
I (48) boot.esp32: SPI Flash Size : 2MB
I (52) boot: Enabling RNG early entropy source...
I (58) boot: Partition Table:
I (61) boot: ## Label            Usage          Type ST Offset   Length
I (69) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (76) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (84) boot:  2 factory          factory app      00 00 00010000 00100000
I (91) boot: End of partition table
I (95) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=22254h (139860) map
I (152) esp_image: segment 1: paddr=0003227c vaddr=3ffb0000 size=03ba4h ( 15268) load
I (158) esp_image: segment 2: paddr=00035e28 vaddr=40080000 size=0a1f0h ( 41456) load
I (174) esp_image: segment 3: paddr=00040020 vaddr=400d0020 size=81294h (529044) map
I (356) esp_image: segment 4: paddr=000c12bc vaddr=4008a1f0 size=0c48ch ( 50316) load
I (387) boot: Loaded app from partition at offset 0x10000
I (387) boot: Disabling RNG early entropy source...
I (398) cpu_start: Multicore app
I (407) cpu_start: Pro cpu start user code
I (407) cpu_start: cpu freq: 160000000 Hz
I (407) cpu_start: Application information:
I (410) cpu_start: Project name:     scan
I (415) cpu_start: App version:      1
I (419) cpu_start: Compile time:     Apr 19 2024 09:51:06
I (426) cpu_start: ELF file SHA256:  cf21d9c7d...
I (431) cpu_start: ESP-IDF:          v5.2.1
I (436) cpu_start: Min chip rev:     v0.0
I (440) cpu_start: Max chip rev:     v3.99
I (445) cpu_start: Chip rev:         v0.0
I (450) heap_init: Initializing. RAM available for dynamic allocation:
I (457) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (463) heap_init: At 3FFB7CB8 len 00028348 (160 KiB): DRAM
I (470) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (476) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (482) heap_init: At 4009667C len 00009984 (38 KiB): IRAM
I (490) spi_flash: detected chip: gd
I (493) spi_flash: flash io: dio
W (497) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (511) main_task: Started on CPU0
I (521) main_task: Calling app_main()
I (551) wifi:wifi driver task: 3ffbfae8, prio:23, stack:6656, core=0
I (551) wifi:wifi firmware version: a9f5b59
I (551) wifi:wifi certification version: v7.0
I (551) wifi:config NVS flash: enabled
I (551) wifi:config nano formating: disabled
I (561) wifi:Init data frame dynamic rx buffer num: 32
I (561) wifi:Init static rx mgmt buffer num: 5
I (571) wifi:Init management short buffer num: 32
I (571) wifi:Init dynamic tx buffer num: 32
I (571) wifi:Init static rx buffer size: 1600
I (581) wifi:Init static rx buffer num: 10
I (581) wifi:Init dynamic rx buffer num: 32
I (591) wifi_init: rx ba win: 6
I (591) wifi_init: tcpip mbox: 32
I (591) wifi_init: udp mbox: 6
I (601) wifi_init: tcp mbox: 6
I (601) wifi_init: tcp tx win: 5760
I (601) wifi_init: tcp rx win: 5760
I (611) wifi_init: tcp mss: 1440
I (611) wifi_init: WiFi IRAM OP enabled
I (621) wifi_init: WiFi RX IRAM OP enabled
I (621) phy_init: phy_version 4791,2c4672b,Dec 20 2023,16:06:06
W (631) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (721) wifi:mode : sta (24:0a:c4:05:34:a4)
I (721) wifi:enable tsf
I (3221) scan: Max AP number ap_info can hold = 10
I (3221) scan: Total APs scanned = 0, actual AP number ap_info holds = 4
I (3221) scan: SSID             NETGEAR07
I (3221) scan: RSSI             -3
I (3221) scan: Authmode         WIFI_AUTH_WPA2_WPA3_PSK
I (3231) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_CCMP
I (3241) scan: Group Cipher     WIFI_CIPHER_TYPE_CCMP
I (3241) scan: Channel          4
I (3241) scan: SSID             ORBI13-IoT
I (3251) scan: RSSI             -6
I (3251) scan: Authmode         WIFI_AUTH_WPA2_PSK
I (3261) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_CCMP
I (3261) scan: Group Cipher     WIFI_CIPHER_TYPE_CCMP
I (3271) scan: Channel          4
I (3271) scan: SSID             ORBI13-IoT
I (3271) scan: RSSI             -38
I (3281) scan: Authmode         WIFI_AUTH_WPA2_PSK
I (3281) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_CCMP
I (3291) scan: Group Cipher     WIFI_CIPHER_TYPE_CCMP
I (3291) scan: Channel          4
I (3301) scan: SSID             NETGEAR07
I (3301) scan: RSSI             -39
I (3301) scan: Authmode         WIFI_AUTH_WPA2_WPA3_PSK
I (3311) scan: Pairwise Cipher  WIFI_CIPHER_TYPE_CCMP
I (3321) scan: Group Cipher     WIFI_CIPHER_TYPE_CCMP
I (3321) scan: Channel          4
I (3321) main_task: Returned from app_main()
Is this function broke?

Mike

douglasbaird
Posts: 3
Joined: Sun Apr 21, 2024 6:25 pm

Re: IDF example scan does not show ap's returned

Postby douglasbaird » Sun Apr 21, 2024 6:36 pm

Hi,
I think the ap_info buffer provided to store the scan results might not have enough space to accommodate all the APs found during the scan. By default, the example code you mentioned uses an ap_info buffer that can hold a maximum of 10 APs. If there are more than 10 APs in the scan results, only the first 10 will be stored in the buffer. You can increase the buffer size to handle a larger number of APs if needed.

Here's an example of how you can modify the example code to handle a larger number of APs:

Code: Select all

c
#define MAX_AP_COUNT 20  // Increase the buffer size to handle more APs

wifi_ap_record_t ap_info[MAX_AP_COUNT];

// Perform the Wi-Fi scan
ESP_ERROR_CHECK(esp_wifi_scan_start(NULL, true));
vTaskDelay(2000 / portTICK_PERIOD_MS);  // Wait for the scan to complete

// Get the number of APs found
uint16_t ap_count = 0;
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_num(&ap_count));

// Retrieve the scan results
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&ap_count, ap_info));

// Process the scan results
for (int i = 0; i < ap_count; i++) {
    // Access the AP information in ap_info[i]
    // Example: printf("SSID: %s, RSSI: %d\n", ap_info[i].ssid, ap_info[i].rssi);
}
By modifying the code as shown above, you should be able to retrieve the correct number of APs found during the scan and access their information from the ap_info buffer.

iseries1
Posts: 4
Joined: Tue Apr 16, 2024 11:38 am

Re: IDF example scan does not show ap's returned

Postby iseries1 » Mon Apr 22, 2024 10:16 am

I think your missing the point here. The correct number of AP's was returned by the function that returns the APs found returns zero.

Code: Select all

I (3221) scan: Total APs scanned = 0, actual AP number ap_info holds = 4
The sample shows total APs scanned is 0 but the number returned is 4 which is correct. I think total APs scanned use to return 4.

Mike

chegewara
Posts: 2378
Joined: Wed Jun 14, 2017 9:00 pm

Re: IDF example scan does not show ap's returned

Postby chegewara » Wed Apr 24, 2024 12:57 am

I dont know the example code, but this function return the correct value after wifi scan is finished, so either the API finish and event is received or you call scan stop before call this

Code: Select all

esp_wifi_scan_get_ap_num

Who is online

Users browsing this forum: No registered users and 176 guests