Skip to content

Implement WiFi auto-reconnect functionality#2482

Closed
Rococo88 wants to merge 1 commit intomeshcore-dev:mainfrom
Rococo88:main
Closed

Implement WiFi auto-reconnect functionality#2482
Rococo88 wants to merge 1 commit intomeshcore-dev:mainfrom
Rococo88:main

Conversation

@Rococo88
Copy link
Copy Markdown

@Rococo88 Rococo88 commented May 6, 2026

Added auto-reconnect feature for WiFi and event handler for disconnection. Tested on Xiao-S3 board, it reconnects properly after router reboot.

Added auto-reconnect feature for WiFi and event handler for disconnection.
Copy link
Copy Markdown
Member

@liamcottle liamcottle left a comment

Choose a reason for hiding this comment

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

Hey, thanks for the PR.

I've left a few review comments.

Please also change the PR branch to dev. You may need to rebase your fork to prevent the PR pulling in other commits if you change it from main.

#ifdef WIFI_SSID
board.setInhibitSleep(true); // prevent sleep when WiFi is active
// Enable ESP-IDF auto-reconnect
WiFi.setAutoReconnect(true);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This shouldn't be needed since auto reconnect defaults to true in the underlying library, however we might as well be explicit about it. So it can stay.

// Attach an event handler to force a reconnect specifically on disconnect events
WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info){
#ifdef WIFI_DEBUG_LOGGING
Serial.println("WiFi disconnected. Forcing reconnect...");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please remove the #ifdef sections and replace Serial.println(...) with WIFI_DEBUG_PRINTLN(...). The latter automatically handles the case where wifi debug logging is disabled.

@Rococo88
Copy link
Copy Markdown
Author

Rococo88 commented May 7, 2026

Hey Liam, thanks for the review! I've updated the print statements to use WIFI_DEBUG_PRINTLN. I actually couldn't change the base branch to dev in the UI (the option wasn't there for me), so I'm closing this and opening a fresh PR targeting dev right now!

@Rococo88 Rococo88 closed this May 7, 2026
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