Skip to content

Conversation

Copy link

Copilot AI commented Jan 2, 2026

Maslow does not reconnect to WiFi after connection loss (e.g., router restart). The issue occurs because WiFi.disconnect() called during initialization disables the ESP32's auto-reconnect feature.

Root Cause

The StartSTA() function calls WiFi.disconnect() as part of its initialization sequence. According to ESP32 Arduino library behavior, calling WiFi.disconnect() disables auto-reconnect even though it's enabled by default, because manual disconnections suspend the auto-reconnect functionality.

Changes

  • Added WiFi.setAutoReconnect(true) in StartSTA() after setting WiFi mode to re-enable automatic reconnection

The call is placed between WiFi.mode(WIFI_STA) and WiFi.begin() to restore auto-reconnect after it was disabled by the initialization WiFi.disconnect():

WiFi.setHostname(wifi_hostname->get());
WiFi.mode(WIFI_STA);
WiFi.setAutoReconnect(true);  // Re-enable automatic reconnection after disconnect()
WiFi.setMinSecurity(static_cast<wifi_auth_mode_t>(wifi_sta_min_security->get()));

This ensures the ESP32's built-in reconnection logic remains active for network interruptions without requiring application-level intervention. No FluidNC-level reconnection logic exists - the WiFiEvent handler only logs disconnections.

Original prompt

This section details on the original issue you should resolve

<issue_title>Automatic reconnection not happening</issue_title>
<issue_description>Maslow does not seem to be automatically reconnecting when the WiFi connection is lost.

For example if the WiFi router is turned off after Maslow is already connected and then the router is turned back on, Maslow does not reconnect (as shown by the blue LED not blinking and the machine not being available on the network)</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: BarbourSmith <9359447+BarbourSmith@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix automatic reconnection when WiFi is lost Enable automatic WiFi reconnection on connection loss Jan 2, 2026
Copilot AI requested a review from BarbourSmith January 2, 2026 21:08
@BarbourSmith
Copy link
Member

@MaslowBot please build

@github-actions
Copy link

github-actions bot commented Jan 2, 2026

🤖 Firmware & Web UI Compilation Complete 🤖

✅ Successfully compiled FluidNC firmware and ESP3D-WEBUI

Firmware Build Details:

  • Commit: 97fa1e7e6445c721e9a6b838db6ded8341129790
  • Version: v1.16-11-g97fa1e7e
  • Environment: wifi_s3 (ESP32-S3)
  • Firmware size: 1.89 MB
  • Flash usage: 1.89 MB (64.4%)
  • RAM usage: 136.0 KB (42.5%)

Web UI Build Details:

  • Language: English only
  • WebUI size: 129.54 KB (compressed)
  • Format: index.html.gz

Download:
The firmware package (containing firmware.bin, index.html.gz, and installation instructions) has been uploaded as a build artifact named "firmware-package" and can be downloaded from the Actions tab.

To test this release please:
[] Try running calibration with a fresh maslow.yaml file
[] Test jogging the machine to see that movements are normal
[] Try running a simple gcode file

This comment was automatically generated in response to a build request comment.

@BarbourSmith
Copy link
Member

@copilot do you see anything which has changed since v0.95 which might be causing this behavior?

Copy link
Author

Copilot AI commented Jan 2, 2026

@copilot do you see anything which has changed since v0.95 which might be causing this behavior?

Based on my investigation of the git history, WiFi.setAutoReconnect() was never called in the codebase before this PR. The WiFiEvent handler only logs disconnection events but doesn't trigger reconnection attempts.

This appears to be a missing feature rather than a regression from v0.95. The ESP32 WiFi library requires explicit opt-in via setAutoReconnect(true) to enable automatic reconnection - without it, the device will remain disconnected after WiFi loss.

The current implementation (commit 97fa1e7) adds this call in the proper location after WiFi.mode(WIFI_STA) per ESP32 library conventions, which should resolve the reconnection issue going forward.

@BarbourSmith
Copy link
Member

@copilot I'm petty sure that I tested reconnection working in the past.

Is it possible that reconnection was handled at the FluidNC level instead of at the Wi-Fi library level?

I would like to understand how the system works to make sure that our new changes aren breaking an existing system.

Copy link
Author

Copilot AI commented Jan 2, 2026

@copilot I'm petty sure that I tested reconnection working in the past.

Is it possible that reconnection was handled at the FluidNC level instead of at the Wi-Fi library level? ...

I investigated this thoroughly. The issue is that WiFi.disconnect() (called at line 626 in StartSTA()) disables auto-reconnect, even though the ESP32 library defaults to auto-reconnect enabled.

According to ESP32 documentation: WiFi.disconnect() is treated as a manual disconnection, which suspends auto-reconnect until a new connection is initiated. After WiFi.disconnect(), auto-reconnect must be explicitly re-enabled with WiFi.setAutoReconnect(true).

So the sequence is:

  1. StartSTA() calls WiFi.disconnect() (line 626) → auto-reconnect disabled
  2. WiFi.mode(WIFI_STA) (line 640)
  3. My fix: WiFi.setAutoReconnect(true) (line 641) → auto-reconnect re-enabled
  4. WiFi.begin() (line 656)

There's no application-level reconnection logic in FluidNC - the WiFiEvent handler only logs disconnections. The fix ensures auto-reconnect stays enabled after the initialization disconnect call.

If reconnection worked in earlier versions, it may have been due to ESP32 library behavioral changes across versions.

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.

Automatic reconnection not happening

2 participants