Skip to content

Fix reconnect bugs, add watchdog & HTTP push OTA#1

Open
nuketownada wants to merge 2 commits into
joshperry:masterfrom
nuketownada:ada/fixes-and-ota
Open

Fix reconnect bugs, add watchdog & HTTP push OTA#1
nuketownada wants to merge 2 commits into
joshperry:masterfrom
nuketownada:ada/fixes-and-ota

Conversation

@nuketownada

Copy link
Copy Markdown

Summary

  • Registration bug fix: Clear registration state on WiFi disconnect — previously the device would skip re-registration after WiFi reconnect and publish on stale topic paths
  • MQTT re-resolve: Re-resolve hostname when MQTT broker drops in RUNNING state, in case the IP changed (DHCP renewal etc.)
  • Hardware watchdog: 30s WDT via esp_task_wdt_reconfigure — reboots device if loop() stalls
  • HTTP push OTA: Web server on port 80 with /update endpoint. Push firmware via curl, no reverse connection needed (unlike espota). mDNS advertises as dusa.local
  • Dead code cleanup: Removed unused ESPmDNS.h include (re-added with OTA), lastPublishedLevel tracking, lastHeartbeatTime, HEARTBEAT_INTERVAL_MS, ADC_MAX, ADC_VREF

Usage

pio run && curl -F "firmware=@.pio/build/xiao_esp32s3/firmware.bin" http://dusa.local/update

Test plan

  • Build clean (pio run)
  • Flash via USB, verify WiFi + MQTT connect
  • Verify dusa.local resolves (mDNS)
  • OTA push via curl, verify device restarts with new firmware
  • Kill WiFi, verify re-registration after reconnect
  • Verify watchdog doesn't fire during normal operation

🤖 Generated with Claude Code

nuketownada and others added 2 commits February 16, 2026 18:57
Registration state wasn't cleared on WiFi disconnect — device would
skip re-registration and publish on stale topic paths. Also re-resolve
MQTT hostname on broker disconnect in case IP changed.

30s hardware WDT reboots device if loop() stalls.

Removed: unused ESPmDNS include, lastPublishedLevel tracking,
lastHeartbeatTime, HEARTBEAT_INTERVAL_MS, ADC_MAX, ADC_VREF.

Co-Authored-By: Joshua Perry <josh@6bit.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Device runs a web server on port 80 after WiFi connects.
Push firmware with: curl -F "firmware=@firmware.bin" http://dusa.local/update

No reverse connection (unlike espota), so no workstation firewall needed.
mDNS init is idempotent — safe across WiFi reconnects.

Co-Authored-By: Joshua Perry <josh@6bit.com>
Co-Authored-By: Claude Opus 4.6 <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.

1 participant