Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No wifi reconnection after connection loss - Heishamon Large (ESP32) #621

Open
oxyde42 opened this issue Jan 8, 2025 · 4 comments
Open

Comments

@oxyde42
Copy link

oxyde42 commented Jan 8, 2025

Sometimes my Heishamon loses the wifi connection, but there is no reconnection.

Has this been forgotten for the ESP32?

void check_wifi() {
int wifistatus = WiFi.status();
if ((wifistatus != WL_CONNECTED) && (WiFi.localIP())) {
// special case where it seems that we are not connect but we do have working IP (causing the -1% wifi signal), do a reset.
#ifdef ESP8266
log_message(_F("Weird case, WiFi seems disconnected but is not. Resetting WiFi!"));
setupWifi(&heishamonSettings);
#else // here for ESP32
log_message(_F("WiFi just got disconnected, still have IP addres."));
#endif
...

Or can a reconnection be triggered with a rule?

@geduxas
Copy link
Contributor

geduxas commented Jan 8, 2025

I can confirm this behavior, i noticed after updating rebooting my AP heishamon will go to failsafe hotspot mode, and will not reconnect, just rebooted heishamon and it connect's back.

@IgorYbema
Copy link
Contributor

No there is something else weird going on with ESP32 wifi. I haven't figured it out yet. Will keep searching when I have some more spare time

@oxyde42
Copy link
Author

oxyde42 commented Jan 9, 2025

I have found the problem. It is a logical error in the function check_wifi(). The ESP32 also loses the IP address at the same time as the connection. This means that result of line 173 is always false:
if ((wifistatus != WL_CONNECTED) && (WiFi.localIP()))

On the ESP32 you get the correct information WL_CONNECTION_LOST as wifistatus if the connection is lost.

I suggest the following change:

void check_wifi() {
int wifistatus = WiFi.status();
#ifdef ESP8266
if ((wifistatus != WL_CONNECTED) && (WiFi.localIP())) {
#else
if (wifistatus == WL_CONNECTION_LOST) {
#endif
// special case where it seems that we are not connect but we do have working IP (causing the -1% wifi signal), do a reset.
log_message(_F(“Weird case, WiFi seems disconnected but is not. Resetting WiFi!”));
setupWifi(&heishamonSettings);

} else if ((wifistatus != WL_CONNECTED) || (!WiFi.localIP())) {
...

@IgorYbema
Copy link
Contributor

No that is not it. That if statement is specially written for the ESP8266 which can be in this state. I know that for the ESP32 it will never go in that statement.
The next if is for the real check (else if ((wifistatus != WL_CONNECTED) || (!WiFi.localIP()))
From there it sometimes doesn't go to the part where it retries the connection.
I'll try to debug more later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants