Skip to content

WiFi observability: stop failing silently (4/7) - #45

Merged
bring42 merged 3 commits into
mainfrom
claude/pr4-wifi-observability
Sep 12, 2026
Merged

bring42 merged 3 commits into
mainfrom
claude/pr4-wifi-observability

Conversation

@bring42

@bring42 bring42 commented Sep 12, 2026 •

Copy link
Copy Markdown
Owner

Stacked PR — part 4 of 7. Merge in order (1 → 7) using a merge commit, not squash: the per-commit messages are the documentation, and squashing would also break the PRs stacked on top. Split from claude/next-goal-notes-merge-prep-6bb680; the top of the stack is byte-identical to that branch.

What

WiFi stops failing silently. This is mostly logging. The one behavior change: the automatic reconnect now waits for a running diagnostic scan to finish (a few seconds, bounded at 15 s), because the two used to collide.

  • Event logging: association, got-IP on every acquire (with RSSI), lost-IP, disconnects with the IDF reason code translated to text (AUTH_EXPIRE, NO_AP_FOUND, …), and setup-AP client join/leave.

  • The deliberate "reconnect paused while a client is on the setup AP" rule now says so, instead of staying silent.

  • Diagnostic scan while disconnected: every BSSID broadcasting your SSID (channel, RSSI, auth mode). If the SSID isn't found, it lists what the radio can hear, which separates "the router is gone" from "this radio is deaf" (e.g. a loose u.FL antenna).

  • Review follow-up: a reconnect issued mid-scan aborted the scan, and the truncated result was logged as a real reading. That faked the "deaf radio" signature the listing exists to detect, about one scan in six. The scan and reconnect are now gated against each other. A user-initiated connect cancels a running scan. Results from a scan the WiFi stack reports as incomplete are discarded. Hidden networks log as "(hidden)".

Review notes

A single file (src/network/wifi.cpp).

Verification

Built and tested on this branch alone. This stacked state is new, so it was verified independently rather than assumed: 81/81 native tests pass, the firmware builds for seeed_xiao_esp32c3 (91.3% of the app partition), and the web UI JS passes node --check.

Field-proven: these logs diagnosed a marginal-RF AUTH_EXPIRE (−87 dBm) and a NO_AP_FOUND on real hardware.

🤖 Generated with Claude Code


The stack (merge top to bottom):

  1. Premium render substrate + 13 premium modes (1/7) #42 — Premium render substrate + 13 premium modes (1/7)
  2. Web UI: data/ as the single source of truth (2/7) #43 — Web UI: data/ as the single source of truth (2/7)
  3. Live viz: the channel visualizer mirrors the real strip (3/7) #44 — Live viz: the channel visualizer mirrors the real strip (3/7)
  4. WiFi observability: stop failing silently (4/7) #45 — WiFi observability: stop failing silently (4/7)
  5. 4 MB partition table: 1.75 MB A/B app slots (5/7) #46 — 4 MB partition table: 1.75 MB A/B app slots (5/7)
  6. AI prompt pipeline: key save, live model, honest outcomes (6/7) #47 — AI prompt pipeline: key save, live model, honest outcomes (6/7)
  7. Core hardening from the external review (7/7) #48 — Core hardening from the external review (7/7)

benno6 and others added 3 commits September 12, 2026 18:08
…ode scan diagnostic

The firmware swallowed every WiFi outcome: begin() was fired and nothing was
ever reported — a failing link just looked idle, and even successful
reconnects never printed the acquired IP. Debugging meant guessing between
password, signal, router, and firmware. (This is how a marginal-RF AUTH_EXPIRE
failure burned an evening being mistaken for a config bug.)

- WiFi.onEvent handler: STA start / association / got-IP (with RSSI, printed
  on EVERY acquire) / lost-IP / disconnect with the IDF reason code translated
  to text (AUTH_EXPIRE, NO_AP_FOUND, 4WAY_HANDSHAKE_TIMEOUT, ...), plus
  setup-AP client join/leave. Pure logging on the event task; connect edges
  are still handled by the handleWifiMaintenance() poll (P0.1 untouched).
- The silent skip is now spoken: when a reconnect is due but held off because
  a client is parked on the setup AP (the deliberate #40 guard), a
  rate-limited line says so instead of nothing. lastWifiAttempt is not reset
  by the log, so the retry still fires the moment the client leaves.
- Diagnostic scan while disconnected (every ~95 s, same AP-client guard):
  async scan logging every BSSID broadcasting the target SSID with channel,
  RSSI and auth mode — distinguishes not-visible / too-weak / wrong-auth /
  mesh-node-that-won't-answer from the device's own radio.

Field-proven on hardware: the new logs pinned tonight's failure in minutes
(reason 2 AUTH_EXPIRE + scan showing the SSID at -87 dBm on ch 11 = marginal
RF at the auth handshake; connection recovered and verified end-to-end).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The scan only logged networks matching the configured SSID, so a scan
result of "0 broadcasting Untz" could not distinguish two very different
failures: the AP is gone/renamed, versus this radio is deaf (e.g. the
XIAO's u.FL antenna knocked loose — it detaches easily during handling).

When the target isn't found, log every visible network (SSID, channel,
RSSI), capped at 8 so a dense 2.4 GHz band can't spam the log. One line
now separates "sees 7 networks, none are ours" from "sees 1 network".

Prompted by a live NO_AP_FOUND on hardware where the device could see a
single network while a laptop beside it saw seven.
Found in review of the scan diagnostic. A WiFi.begin() issued while the
async diagnostic scan runs aborts the scan (the IDF returns
ESP_ERR_WIFI_STATE), and the Arduino core's scan-done handler posts the
truncated count without checking its status — so scanComplete() returned
0 or a partial result as if the scan had finished. Logged, that reads as
"0 networks visible" or one weak `heard:` entry: exactly the "deaf radio /
antenna knocked off" signature the listing exists to detect. With the scan
every 95 s and the reconnect every 30 s, about one scan in six collided
(~every 10 minutes), and the collision also cost that reconnect attempt.

- The scan and the reconnect are gated against each other. The automatic
  reconnect holds off while a scan is pending (lastWifiAttempt is not
  reset, so it fires as soon as the scan finishes; the wait is bounded at
  15 s so a lost event can never wedge reconnects), and a scan never
  starts within 10 s of a connect attempt.
- A user-initiated connect (credentials just saved) outranks the
  diagnostic: it stops the scan (esp_wifi_scan_stop) and drops the
  partial result.
- The IDF's own scan-done status is captured in the event handler; a
  result from a scan that didn't complete is discarded and logged as
  interrupted rather than reported as a reading.
- Hidden networks log as "(hidden)" instead of an empty quoted string.
- The old comment claiming a collision "just aborts the scan — retried
  next cycle" was wrong and is gone.

Verified: firmware builds; 82/82 native tests. The IDF event path has no
native coverage — it is hardware-only.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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