Skip to content

Feature: Station-mode Fallback and Periodic Reconnection Loop (#112)#114

Open
dfry-lhzn wants to merge 5 commits into
CCOMJHC:mainfrom
dfry-lhzn:feature/112-reconnect-loop
Open

Feature: Station-mode Fallback and Periodic Reconnection Loop (#112)#114
dfry-lhzn wants to merge 5 commits into
CCOMJHC:mainfrom
dfry-lhzn:feature/112-reconnect-loop

Conversation

@dfry-lhzn

@dfry-lhzn dfry-lhzn commented May 19, 2026

Copy link
Copy Markdown

Stacked on #113. Review #113 first.
Resolves #112

This PR addresses the indefinite fallback behavior observed when the logger transitions into AP-Mode due to a missing target Station network. It implements a non-blocking background scanner that gracefully restores the Station connection whenever the target Hotspot returns.

Key Changes

  1. Asynchronous Background Scanning: When inside AP-Fallback, the ConnectionStateMachine triggers a non-blocking WiFi.scanNetworks(true). If the target SSID is spotted, it transitions to STATION_CONNECTING.
  2. WIFI_AP_STA Dual Mode: Replaced pure AP mode fallback with WIFI_AP_STA. This ensures the logger can continue hosting its configuration access point while the Station interface asynchronously scans the airways in the background.
  3. mDNS/DHCP Hostname Consistency: WiFi.setHostname is now executed prior to interface initialization on boot, binding the custom mDNS property to the DHCP negotiation so it correctly resolves instead of leaving it stranded as 'espressif'.
  4. WPA3 Baseband Resilience: Fixed a bug in station join configuration where WiFi.begin(ssid, pass) was forcefully overriding the structure memory. It now builds the wifi_config_t cleanly to preserve SAE and PMF constants and performs a hard WiFi.disconnect(true) during transition to kill underlying SDK tracking states from stale attempts.

dfry-lhzn added 5 commits May 19, 2026 13:36
…JHC#111)

- Adds CONFIG_REQUIRE_PMF_S to allow users with modern hotspots (like Pixel 9 Pro) to enforce Protected Management Frames.
- Defaults PMF to capable but not required to preserve compatibility with legacy WPA2 networks.
- Sets sae_pwe_h2e to WPA3_SAE_PWE_BOTH where available to enable WPA3 SAE flow.
Replaces the hard ESP.restart() failure loop when Station connection exhausts its retries. Instead:
- State machine drops to AP-Fallback mode headlessly via apSetup()
- Triggers non-blocking background async scans WiFi.scanNetworks(true)
- Polls for configured hotspot presence over the air
- Transitions seamlessly back to Station mode if detected
- Configured via new parameter CONFIG_STATION_SCAN_INTERVAL_S exposed to Web UI (default: 30000 ms / 30s)
Intercepts CONFIG_MDNS_NAME_S (default value: "wibl") and assigns it using WiFi.setHostname() and WiFi.softAPsetHostname() respectively prior to network connection. Ensures tethered networks explicitly register the logger.
@parkercoates

Copy link
Copy Markdown

Hello @dfry-lhzn,

In a rather suprising coincidence, I just logged into Github to create my own PR to expose WIFI_AP_STA on the WIBL and happened to stumble upon yours.

You can find my changes here: main...parkercoates:WIBL:dual-mode-wifi

There are some differences in our approaches, but I don't know that they are fundamental or irreconcilable:

  • I exposed WIFI_AP_STA as a new, third WiFi mode, while you used it only as a safe mode fallback when station mode fails to connect. @brian-r-calder had expressed some concerns about leaving an AP running at all times, so I chose to make dual mode a new separate mode the user must explicitly opt into. The behaviour of the existing AP and Station modes are left unchanged.
  • Your implementation fires up the AP only after station mode fails and then leaves it running thereafter. Depending on one's station mode settings, that could be quite a while. My implementation fires up the AP at start up before station connection has even been attempted, making the AP available almost immediately. This is quite convenient for local development and testing purposes.
  • You introduced a new CONFIG_STATION_SCAN_INTERVAL_S setting and added an active scan for the station SSID. I (ab)used the existing CONFIG_STATION_DELAY_S and associated logic. I don't have strong feelings about this one. Is there a benefit to scanning for the presence of the SSID instead of just trying to connect to it? I had, perhaps naïvely, assumed the cost of a failed station connection attempt was low.

I'll hold off on creating my own PR for now. Perhaps Dr. Calder can weigh in on his thoughts on the two different approaches.

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.

Feature Request: Station-mode Fallback and Periodic Reconnection Loop

2 participants