Repository navigation
fix(wifi): keep FAIL_TO_AP mode reachable and truthful after failover - #315
Open
ClutchplateDude wants to merge 1 commit into
Open
ClutchplateDude wants to merge 1 commit into
ClutchplateDude wants to merge 1 commit into
Conversation
WIFI_MODE_ATTEMPT_INFRASTRUCTURE_FAIL_TO_AP had two pre-existing defects, deferred from #295: 1. After infraToAPFailover() switched the radio to the access point, WifiControl::loop() kept hitting the return in the _status != WL_CONNECTED branch on every pass, so tcpLoop()/udpLoop() were never reached again - the soft-AP was up but no client was ever serviced. Split the concerns: the station-monitoring block now stops once _failedOver is set, and a _tcpServer/_udp null-check lifecycle guard controls the early return instead of the connection status. 2. getIP() and getStatus() keyed off the compile-time WIFI_MODE, so after failover the UDP discovery reply and :GN# response advertised the station IP (0.0.0.0) instead of the AP address, and reported station status/SSID fields that no longer applied. Track the failover in the new _failedOver flag and consult it at runtime; after failover the mount now reports exactly what a WIFI_MODE_AP_ONLY mount would. Fixes #307 Co-Authored-By: Claude Code <noreply@anthropic.com>
This was referenced Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #307
What
WIFI_MODE_ATTEMPT_INFRASTRUCTURE_FAIL_TO_APhad two pre-existing defects, explicitly deferred from #295 (analysis by @rbhbokka in this comment):1. The mount was unreachable after failover
After
infraToAPFailover()switched the radio to the access point,WifiControl::loop()kept hitting thereturnin the_status != WL_CONNECTEDbranch on every pass — the soft-AP was up and the port bound, buttcpLoop()/udpLoop()were never reached again, so no client was ever serviced.One condition was answering two different questions ("should we attempt failover" vs "are the servers up"). This PR splits them:
_failedOveris set (this also prevents a post-failover status flap from re-runningestablishServers()and killing the AP client), andinfraToAPFailover()remains self-guarding via_infraStart;_tcpServer == nullptr || _udp == nullptrlifecycle guard now controls the early return.2.
getIP()/getStatus()reported the wrong interface after failoverBoth keyed off the compile-time
WIFI_MODE, so after failover the UDP discovery reply and the:GN#response advertisedWiFi.localIP()(0.0.0.0or the stale station IP) instead of the AP address, plus station status/SSID fields that no longer applied.This PR adds a
_failedOverruntime flag set byinfraToAPFailover()and consulted inloop(),getIP(), andgetStatus(), keepingWIFI_MODEas the policy input. After failover the mount now reports exactly what aWIFI_MODE_AP_ONLYmount would ("Access Point,"mode label, AP-shaped fields,softAPIP).Behavior notes
WIFI_MODE_INFRASTRUCTURE: unchanged while connected; while disconnected the server loops now no-op on the dead interface instead of early-returning (they re-arm automatically on reconnect, which was already handled by the status-change block).WIFI_MODE_AP_ONLY: no behavioral change.softAP()itself fails to start, the mount ends in the same dead state as before this PR (servers never established); no regression.Testing
Compiled all three
WIFI_MODEs locally withpio run -e esp32(each is a distinct compile-time path) — all pass. Runtime testing still needs real hardware: an ESP32 in failover mode plus an infrastructure network that refuses the credentials.matrix_build.pynever setsWIFI_ENABLED. A follow-up to add a WIFI-enabled matrix variant would give this code path CI coverage (happy to do that separately).🤖 Generated with Claude Code