Skip to content

fix: send RNode TCP activity detect() keepalives#15

Open
rinchen wants to merge 2 commits into
ratspeak:mainfrom
rinchen:fix/rnode-tcp-activity-keepalive
Open

fix: send RNode TCP activity detect() keepalives#15
rinchen wants to merge 2 commits into
ratspeak:mainfrom
rinchen:fix/rnode-tcp-activity-keepalive

Conversation

@rinchen

@rinchen rinchen commented Jul 20, 2026

Copy link
Copy Markdown

Summary

Wi‑Fi / TCP RNodes (tcp://host:7633) close the socket after ~6 seconds without host KISS writes. Python Reticulum prevents this with TCPConnection.ACTIVITY_KEEPALIVE (3.5s) by calling self.detect() when idle (RNodeInterface.py). rsReticulum already applied OS TCP keepalive and reconnect-on-EOF, but never sent the application-level detect keepalive, so interfaces flapped (~6.7s up, then RECONNECT_WAIT 5s).

  • Track last_write on every successful write in the RNode write loop.
  • On TCP transports, wake periodically and send build_detect_sequence() when idle ≥ 3.5s (100ms under cfg(test)).
  • Serial-only paths without beacons are unchanged (still block on recv).

Evidence

mesh-client developer dump (Heltec V4 / ESP32-S3, firmware 1.86, tcp://192.168.1.110:7633): peer FIN with RNode TCP socket closed at mean 6.73s after open, then exact 5s reconnect — same with rnsd-rs.

Test plan

  • cargo test -p rns-interface --features rnode-tcp --lib rnode::
  • cargo clippy -p rns-interface --features rnode-tcp -- -D warnings
  • On a Wi‑Fi RNode: interface stays up for >30s without reconnect churn; logs show RNode TCP activity keepalive (detect) and no RNode TCP socket closed cycle

rinchen added 2 commits July 20, 2026 12:59
- Port Python RNodeInterface ACTIVITY_KEEPALIVE (3.5s) into the TCP
  write loop: when idle, send build_detect_sequence() so Wi‑Fi RNodes
  do not close the socket at ~ACTIVITY_TIMEOUT (6s).
- Track last_write on every successful write; serial-only paths without
  beacons still block on recv (no spin).
- Add parity constant test and TCP mock asserting idle detect frames.

Without this, rnsd-rs / mesh-client sidecars flap Wi‑Fi RNodes every
~6–7s up / 5s reconnect (peer FIN: "RNode TCP socket closed").
rinchen added a commit to Colorado-Mesh/mesh-client that referenced this pull request Jul 20, 2026
* fix(reticulum): overlay RNode TCP activity keepalive

- Add rsReticulum-rnode-tcp-activity-keepalive.patch (Python ACTIVITY_KEEPALIVE
  parity: idle detect() every 3.5s so Wi‑Fi RNodes do not FIN at ~6s).
- Wire apply script into ensure-rsReticulum-patches / clone-ratspeak-stack.
- Track upstream ratspeak/rsReticulum#15 in update.sh RATSPEAK_PATCH_ENTRIES.

Ships the fix in mesh-client builds while the upstream PR may or may not merge.

* fix(reticulum): harden macOS BLE RNode pairing UX and reconnect

- Surface Admin Start pairing PIN prominently (large PIN + status) and
  warn that the radio display may stay blank; never use Meshtastic 123456.
- Extend BLE connect grace / connecting hint to 60s to match OS passkey.
- Latch blePairingTimedOut from sidecar logs into Connection + Diagnostics.
- Debounce pairing-transition reconnects (1s → 30s) via rsReticulum overlay.
- Document wrong-PIN / Admin PIN location / empty macOS Bluetooth list.

Reporter used 123456 after Admin Start pairing showed no on-display PIN;
7s hold + real PIN connected. These changes make that path clearer and less
thrashy while the OS passkey dialog is open.

* fix(reticulum): address PR #698 review findings

- Fail closed on rsReticulum overlay apply (match packet-tap); document BLE
  debounce overlay in sidecar README.
- Isolate Admin pairing pending timer/generation so disable/re-pair cannot
  clear a newer attempt; cover with fake-timer unit tests.
- Neutralize blePairingTimedOut copy (passkey exchange timed out), parse BLE
  iface names without backtracking regex, use <output> for pairing status,
  derive local-health delays from MS_PER_SECOND, and axe-test the new alert.
- Translate pairing/timeout strings across locales; fix IT wifi netmask typo.

* fix(reticulum): wait for BT PIN before closing flasher port

- startBluetoothPairing now settles on CMD_BT_PIN or timeout (not the KISS
  write), so runWithRNode no longer closes USB before the PIN arrives.
- Cover PIN delivery and timeout with fake-timer SerialPort mocks.
- Strengthen rsReticulum overlay "already present" guards to require const
  declaration + use site; bound BLE iface name parse whitespace for Sonar.
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