[WiFi] Cannot reconnect to an AP

ShinyGlossy
Posts: 2
Joined: Thu Sep 19, 2024 8:36 pm

[WiFi] Cannot reconnect to an AP

Postby ShinyGlossy » Thu Sep 19, 2024 9:00 pm

I'm trying out a bare-bone WiFi in station mode (from the examples) and I encountered a weird problem, that has not been ultimately solved but appeared in the forums a few years ago. I decided to open a new thread instead of necroing the old one.

I'm using IDF v5.3.0 and ESP-WROOM-32

The best way to describe this so that nothing gets lost is to present the scenario step by step:

1. AP is up (be it a router, an Android hotspot or even one created with NetworkManager on an RPi)
2. ESP32 is powered
3. ESP32 finds the AP, then authenticates and connects.

Code: Select all

I (758992) wifi:state: init -> auth (0xb0)
I (758992) wifi:state: auth -> assoc (0x0)
I (759002) wifi:state: assoc -> run (0x10)
This is good.
4. ESP32 is either reflashed, rebooted or powered down and up again
5. ESP32 finds the AP but cannot authenticate, thus the retry mechanic kicks in but fails every time in the same way:

Code: Select all

I (717462) wifi:state: init -> auth (0xb0)
I (718462) wifi:state: auth -> init (0x200)
The only way to fix this is to either:
- turn off the ESP32, watch the paint dry for about 15 minutes, power it on and "maybe" it will connect (setting the retry count to some ludicrous amounts does not seem to work)
or
- turn the AP off and on again

Now that wouldn't be a problem if it wasn't a thing on practically any kind of AP I tried, which makes me think that naturally the issue must be related to ESP32 and how it handles either the connection or authentication process.
//Note
The problem now only occurs when I connect ESP32 to the RPi hotspot which I set up using nmcli. What's interesting is that ESP32 now has no problems reconnecting to any other AP, and other station devices have no problems reconnecting with the RPi hotspot either. Finally I changed literally nothing, as I rolled back and started from square one. I have no idea why this is a thing now.

I would very much appreciate any guidance, info, or literally anything as right now I'm just getting frustrated that something so simple seems to be so impossible to do.
I tried fixing the problem by changing the settings of the AP, in which case the hotspot set up on RPi given me the most freedom - but to no avail. I believe there is literally nothing else I could have tried, and the example code itself seems to be handling the reconnecting properly - sadly, reality is disappointing.

Cheers!

// Edit: some new revelations forced me to update the details.

ShinyGlossy
Posts: 2
Joined: Thu Sep 19, 2024 8:36 pm

Re: [WiFi] Cannot reconnect to an AP

Postby ShinyGlossy » Sun Sep 22, 2024 8:03 am

Some new stuff came up.
The answer to what the culprit is was laying in the output the whole time (duh).

It looks like the whole thing boils down to the authentication. The moment I disable auth in the AP completely then the re-connection occurs instantaneously. I have also experimented with, I think, all possible combinations of setting up the security, even ones that did not make any sense for the sake of having a full image of the situation - to no avail. The moment WPA or WPA2 is introduced, ESP just refuses to reauthenticate with the AP.

What's infuriating to me is that I don't really need security in my project and seeing how everything just works when it's disabled grinds my gears.
I would like to know what is the way of setting this thing up, but there seems to be not one setup in which auth functions as expected.

I guess I am the one to blame because of adding another layer of unknown to the equation (I'm talking about the custom AP), as it showed me how not-so-straightforward it is. I always thought I know what I'm doing here - jokes on me.

MicroController
Posts: 1698
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: [WiFi] Cannot reconnect to an AP

Postby MicroController » Mon Sep 23, 2024 7:19 am

Facing similar issues at one point, I figured that the issue might be the AP 'locking out' an STA for some time if the STA tries and fails to connect/authenticate multiple times in quick succession.
To mitigate this issue, I basically delay for a few seconds before retrying after connecting failed.

Who is online

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