Skip to content

Improve WiFi connection resilience and skip MQTT when offline#44

Open
totolouis wants to merge 2 commits into
nmaupu:masterfrom
totolouis:pr/wifi-resilience
Open

Improve WiFi connection resilience and skip MQTT when offline#44
totolouis wants to merge 2 commits into
nmaupu:masterfrom
totolouis:pr/wifi-resilience

Conversation

@totolouis
Copy link
Copy Markdown

@totolouis totolouis commented Apr 15, 2026

PR 1.

  • Skip MQTT connection attempts when WiFi is not connected
  • Add better retry system for WiFi connections

Les PRs sont à la suite, j'avais tout fait en même temps dans mon fork.

- Skip MQTT connection attempts when WiFi is not connected
- Add better retry system for WiFi connections
Comment thread src/main.cpp Outdated
// Phase 3: nothing worked, restart
LOG.println("WiFi reconnect failed after 6 attempts, restarting...");
delay(100);
ESP.restart();
Copy link
Copy Markdown
Owner

@nmaupu nmaupu Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that if the wifi is out for whatever reason, the boards reboot in an infinite loop.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I removed the restart. are you good with infinite retry to connect to the wifi?

Comment thread src/net/mqtt.cpp Outdated
Comment thread src/main.cpp
LOG.println(")...");
WiFi.disconnect(true);
delay(100);
WiFi.mode(WIFI_STA);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about that. Mode is already set as per the initial configuration.

Comment thread src/main.cpp
LOG.handle(); // telnetspy handling
ArduinoOTA.handle();

#if WIFI_ENABLED
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a function to reconnectWifi which does exactly that declared in src/net/wifi.cpp (reconnectWifi).

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

Successfully merging this pull request may close these issues.

2 participants