WiFi station no longer finds APs after 5 minutes of scanning

stonehouse
Posts: 6
Joined: Wed Mar 22, 2023 7:51 am

WiFi station no longer finds APs after 5 minutes of scanning

Postby stonehouse » Thu Mar 07, 2024 6:15 pm

Hello everyone,

I am currently working on an application for the ESP32S2 in which a WiFi station searches for APs whose SSID starts with a certain prefix. The station should search until it finds such an AP. I have a log running in the background. From this I can conclude the following:
The station always finds APs in the vicinity for around 5 minutes. However, it does not connect to any of them because the SSIDs of the APs do not start with the correct prefix (this was intended to test the behavior of the station). However, after 5 minutes of searching, the station can no longer find a single AP in the vicinity, even though I know that the same APs are still available.
Does anyone have a similar problem?

Best regards,
Louis

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

Re: WiFi station no longer finds APs after 5 minutes of scanning

Postby chegewara » Fri Mar 08, 2024 11:43 am

You should check if you dont have memory leak in code.
When there is no free ram wifi wont work.

stonehouse
Posts: 6
Joined: Wed Mar 22, 2023 7:51 am

Re: WiFi station no longer finds APs after 5 minutes of scanning

Postby stonehouse » Fri Mar 08, 2024 12:34 pm

Thank you for your answer. I don't think it's a memory leak, I've already doubled the available memory for the task and checked to see if it changes anything about the time. The scanning does not stop after the 5 minutes, I can see that in the log. The ESP keeps scanning, but the WiFi stack tells me that there are 0 APs in the vicinity.

RalphD
Posts: 103
Joined: Thu Nov 25, 2021 9:02 pm

Re: WiFi station no longer finds APs after 5 minutes of scanning

Postby RalphD » Fri Mar 08, 2024 1:08 pm

I barely remember something that by error if the station does not find any AP after 10 attempts it stops searching. Each attempt is logged and final a log is fired saying that after 10 attempts without result it stops searching

May be that helps, just bean an issue for me like a year ago

stonehouse
Posts: 6
Joined: Wed Mar 22, 2023 7:51 am

Re: WiFi station no longer finds APs after 5 minutes of scanning

Postby stonehouse » Mon Mar 11, 2024 10:38 am

I added to the code that the ESP should restart if it detects 0 APs 20 times in a row. I let the log run on the side so that I can see how many scans the ESP performs until it finds no more APs. This is the result:

Number of WiFi scans in area 1: 120
Number of WiFi scans in area 2: 109
Number of WiFi scans in area 3: 108
Number of WiFi scans in area 4: 107
Number of WiFi scans in area 5: 114
Number of WiFi scans in area 6: 115
Number of WiFi scans in area 7: 117
Number of WiFi scans in area 8: 112

So it always seems to happen after a similar time. However, it is not always the same value.

boarchuz
Posts: 606
Joined: Tue Aug 21, 2018 5:28 am

Re: WiFi station no longer finds APs after 5 minutes of scanning

Postby boarchuz » Mon Mar 11, 2024 11:44 am

You want to rule out a memory leak exhausting heap memory, not your task's stack.

Log these after each scan: esp_get_free_heap_size(), esp_get_minimum_free_heap_size()

stonehouse
Posts: 6
Joined: Wed Mar 22, 2023 7:51 am

Re: WiFi station no longer finds APs after 5 minutes of scanning

Postby stonehouse » Mon Mar 11, 2024 12:47 pm

Thank you, I have found the mistake. For whatever reason, I had used a malloc for the AP list during the scan, but forgot to release the memory again (classic). I have now removed all mallocs from the code
Last edited by stonehouse on Mon Mar 11, 2024 12:53 pm, edited 1 time in total.

RalphD
Posts: 103
Joined: Thu Nov 25, 2021 9:02 pm

Re: WiFi station no longer finds APs after 5 minutes of scanning

Postby RalphD » Mon Mar 11, 2024 12:51 pm

well then please we spend the time to help you so you spend the time to tell what the cause was !!!!

stonehouse
Posts: 6
Joined: Wed Mar 22, 2023 7:51 am

Re: WiFi station no longer finds APs after 5 minutes of scanning

Postby stonehouse » Mon Mar 11, 2024 1:03 pm

See my last post

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

Re: WiFi station no longer finds APs after 5 minutes of scanning

Postby chegewara » Mon Mar 11, 2024 1:35 pm

stonehouse wrote:
Mon Mar 11, 2024 12:47 pm
Thank you, I have found the mistake. For whatever reason, I had used a malloc for the AP list during the scan, but forgot to release the memory again (classic). I have now removed all mallocs from the code
Yes, its classic. Everyone been there, including me, thats why my previous response


Good you found the issue

Who is online

Users browsing this forum: Baidu [Spider] and 148 guests