WIFI Scan strange behavior

themindfactory
Posts: 75
Joined: Mon Mar 26, 2018 7:57 pm

WIFI Scan strange behavior

Postby themindfactory » Thu Feb 13, 2025 2:40 am

When I call for a wifi_scan_start and I have DEBUG on I can see it scanning, I think 14 channels, and gathering the results.
In the debug output nearing the end of the scan it will report apnum=12 meaning it found 12 SSIDs
Then it calls a function called update_wifi_scan_results() and in that function there is a call to esp_wifi_scan_get_ap_num(&count) which returns 0 in count. Now how can that be? it just found 12....

The 12 SSID is about right for my network, sometimes it finds 11, sometimes 13... but never returns any due to the call to esp_wifi_scan_get_ap_num() which shows zero.

Example of one channel scan ending... this was channel 11

Code: Select all

D (65780) wifi:scan end: arg=0x3ffc7da2, status=0, ss_state=0x3
D (65781) wifi:perform scan: ss_state=0x9, chan<11,0>, dur<0,120>
At the end of scanning it shows this:

Code: Select all

D (68190) wifi:scan end: arg=0x3ffc7da2, status=0, ss_state=0x3
D (68191) wifi:filter: set rx policy=4
D (68192) wifi:first chan=1
D (68192) wifi:Send scan done event: status=0, apnum=12 <<-- you can see the 12
The the aforementioned functions are called and:

Code: Select all

D (36325) network_prov_mgr: Scan finished
D (36329) network_prov_mgr: Scan result empty
I have 136K available RAM, 94K largest heap block available and in all the output not one ERROR shown.

I am using IDF 5.3.1 in VSCODE and using Arduino as a component, most the mention functions I am watching are part of the IDF.

Hope someone can help!
Thanks!

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

Re: WIFI Scan strange behavior

Postby chegewara » Thu Feb 13, 2025 12:53 pm

Hi,
can you post 2 code snippets:
- with esp_wifi_scan_get_ap_num
- with esp_wifi_scan_start

themindfactory
Posts: 75
Joined: Mon Mar 26, 2018 7:57 pm

Re: WIFI Scan strange behavior

Postby themindfactory » Thu Feb 13, 2025 8:49 pm

These functions are in the IDF, these are not mine, I am using the Provisioning code and when it looks for AP (SSIDs) it finds none, I found that the provisioning code called these functions and this is where it would find out there are 0 avaiable, but clearly in the log files coming out the serial port it had found more.

It finds the count to be 0 here:
https://github.com/espressif/esp-idf/bl ... ger.c#L800

and reports it here:
https://github.com/espressif/esp-idf/bl ... ger.c#L805

and I believe this is where the scan is kicked off:
https://github.com/espressif/esp-idf/bl ... ger.c#L997

I verified this kick off and its parameters were
bool blocking true
bool passive false
group_channels 0
period_m 120

themindfactory
Posts: 75
Joined: Mon Mar 26, 2018 7:57 pm

Re: WIFI Scan strange behavior

Postby themindfactory » Thu Feb 13, 2025 9:52 pm

I am using VSCODE and the IDF but I do have access to Arduino Libs, and used that one to do the scan...

int n = WiFi.scanNetworks();
and this works fine in the same code, I also have a webserver on the device so I did a /ap to display the AP's to a webbrowser...

for some reason when the scan is done through the provisioning library it fails.

I continue the search...

R.

themindfactory
Posts: 75
Joined: Mon Mar 26, 2018 7:57 pm

Re: WIFI Scan strange behavior

Postby themindfactory » Thu Feb 13, 2025 10:14 pm

In both cases of the scan being called, the provisioning libs and the arduino scan lib both call esp_wifi_scan_start() which seems to be a dead end as that function is in the blob :-) (precompiled idf code)

R.

themindfactory
Posts: 75
Joined: Mon Mar 26, 2018 7:57 pm

Re: WIFI Scan strange behavior (solved)

Postby themindfactory » Thu Feb 13, 2025 11:52 pm

So anyone following this and if there are any real ESP32 gurus out there I will tell you what fixed it... can I explain why... no.

So in the IDF setup in VSCODE there is a setting for Arduino event handler, one of the parameters is the core it runs in.... it was set to CORE1, I set it to CORE0 and all good. I changed nothing else. All the TCP and UDP network routines are in CORE0 also, most my stuff expect one function is on CORE1, and that code does not run during provisioning.

Now that said both cores in the code I am running at the time of provisioning are utilized no more that 10%... so its not some overloaded CPU timing issue.

Again Mr. Guru what's up?

Thanks!

PS. It would be nice is someone posted ALL the settings, as there are many, for VSCODE to make sure Arduino Libs and IDF Libs are happy! I have searched for this many times and found nothing.

Who is online

Users browsing this forum: floitsch_toit and 133 guests