Skip to content

fix: ZeDMD reconnect resilience + mDNS re-resolution - #58

Merged
ojacques merged 1 commit into
mainfrom
fix/zedmd-reconnect-resilience
Jul 26, 2026
Merged

ojacques merged 1 commit into
mainfrom
fix/zedmd-reconnect-resilience

Conversation

@ojacques

Copy link
Copy Markdown
Contributor

Problem

After a network outage (WiFi down for ~1 hour), zeClock could not reconnect to the ZeDMD because:

  1. The ZeDMD's IP changed (DHCP renewal) but zeClock kept retrying the stale IP
  2. In WiFi mode, UDP sends don't fail when the device disappears — zeClock didn't detect the disconnection
  3. The retry loop only tried WiFi when wifi_addr was set, never falling back to USB
  4. NetworkManager didn't auto-reconnect the Pi's WiFi (missing autoconnect-retries setting)

Changes

ZeDMD backend (zeclock/backends/zedmd.py)

  • Detailed connection logging: logs the method (USB/WiFi) and target host at each attempt
  • HTTP health check: probes http://<zedmd-ip>/get_version every 10s to detect silent WiFi disconnections (since UDP is fire-and-forget)
  • Health check starts after 10s grace period to avoid false positives on first frame

Clock retry loop (zeclock/clock.py)

  • Alternates USB and WiFi on each retry (odd=USB, even=WiFi)
  • Always re-resolves zedmd-wifi.local via mDNS before each WiFi attempt — handles IP changes transparently
  • Persists new IP to zeclock.ini when mDNS returns a different address
  • Same mDNS-first logic in the runtime reconnection path (when send_frame fails)
  • Replaced emoji print() statements with proper logger calls

WiFi setup (zeclock/wifi_setup.py)

  • Added autoconnect-retries=0 (infinite) to connection profiles created by the captive portal

Testing

  • Deployed on RPi, unplugged ZeDMD — logs show alternating USB/WiFi retries with mDNS resolution
  • Reconnection works when ZeDMD is plugged back in
  • 676 tests pass

- Improve connection logging: log method (USB/WiFi) and host at each attempt
- Alternate USB and WiFi (via zedmd-wifi.local) during retry loop
- Re-resolve mDNS on every WiFi retry to handle IP changes after
  network outages or DHCP renewal
- Add periodic HTTP health check (every 10s) to detect silent WiFi
  disconnections (UDP sends don't fail when device disappears)
- Add autoconnect-retries=0 (infinite) to WiFi connection profiles
  created by the captive portal
- Replace emoji print() with logger calls in clock.py
@ojacques
ojacques merged commit a9406f9 into main Jul 26, 2026
1 check passed
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.

1 participant