Skip to content

fix: reconnect reliably after radio restarts (TCP + serial) - #38

Merged
sg merged 1 commit into
mainfrom
fix/radio-reconnect
Jul 6, 2026
Merged

fix: reconnect reliably after radio restarts (TCP + serial)#38
sg merged 1 commit into
mainfrom
fix/radio-reconnect

Conversation

@sg

@sg sg commented Jul 5, 2026

Copy link
Copy Markdown
Owner

What changed

  • Root cause: meshcore lib auto-reconnect tries 3×1s then gives up permanently; mcbot's DISCONNECTED handler only logged, leaving the bot alive but dead. Radio reboots take 5–60s, so recovery ~never happened.
  • _on_disconnected (non-manual) now triggers the !adm restart teardown/rebuild path — every recovery is a full startup resync.
  • amain(): signals (shutdown_event) now override internal restarts; unreachable radio retries with capped exponential backoff (5s→60s, forever) instead of exiting.
  • New watchdog_interval registry setting (default 180s, 0=off): periodic device-query probe; 2 misses → restart. Catches half-open TCP sockets after silent power-cycles (no keepalive, idle bot may never send). Auto-appears in web UI/API/!adm setting.
  • CONNECTED{reconnected} (lib recovered a short blip): refresh self_info + force contact re-sync.
  • Docs: reconnection section in Bot_Usage, conf example entry.
  • tests/test_reconnect.py (11 tests); suite now 96 passing.

Breaking changes

None. Serial unaffected except recovery now works; by-id device paths already recommended.

🤖 Generated with Claude Code

@sg
sg merged commit 2a55156 into main Jul 6, 2026
1 check passed
@sg
sg deleted the fix/radio-reconnect branch July 6, 2026 00:31
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