Controlled WiFi deauth / Disconnect reason question
Posted: Wed Mar 11, 2026 4:50 am
Hello, everybody!
I have a question about how to implement user deauthentication in such a way that the client does not immediately try to reconnect. ESP32 is in SoftAP mode.
Right now I am using the standard deauth procedure, but a Windows client reconnects almost instantly.
What I would like to do is make the decision whether the connection is allowed or not at the event level. For example, when the `STA_CONNECTED` event is received, the callback checks some condition and performs a deauth if the client should not be allowed to connect.
If it were possible to specify the disconnect reason code sent to the remote side, this problem could be solved by returning a code similar to *"password incorrect"*. In my experience Windows usually stops retrying after such an error. However, I couldn't find a way to set the disconnect reason.
At the moment I implemented a workaround where I maintain my own blacklist with a timer, but this does not feel like a proper solution.
Is there a way in ESP-IDF to control the deauth/disconnect reason code sent to the station?
I have a question about how to implement user deauthentication in such a way that the client does not immediately try to reconnect. ESP32 is in SoftAP mode.
Right now I am using the standard deauth procedure, but a Windows client reconnects almost instantly.
What I would like to do is make the decision whether the connection is allowed or not at the event level. For example, when the `STA_CONNECTED` event is received, the callback checks some condition and performs a deauth if the client should not be allowed to connect.
If it were possible to specify the disconnect reason code sent to the remote side, this problem could be solved by returning a code similar to *"password incorrect"*. In my experience Windows usually stops retrying after such an error. However, I couldn't find a way to set the disconnect reason.
At the moment I implemented a workaround where I maintain my own blacklist with a timer, but this does not feel like a proper solution.
Is there a way in ESP-IDF to control the deauth/disconnect reason code sent to the station?