Skip to content

feat(esp): join WiFi and LTE together, relay prefers WiFi - #139

Draft
Tichael wants to merge 7 commits into
mainfrom
feat/dual-uplink
Draft

Tichael wants to merge 7 commits into
mainfrom
feat/dual-uplink

Conversation

@Tichael

@Tichael Tichael commented Dec 6, 2026

Copy link
Copy Markdown
Collaborator

Requested by Michaël · project thread

Stacked on #138 (MQTT relay). CI only runs on PRs to main, so this targets main and shows #138's commits too; the change of its own is the last three commits. Merge #138 first.

What and why

Phase 3 of OpenCarControls/contracts#44, dual uplink (Michaël's call on the phase 3 decision): an ESP build can enable [network.wifi] and [network.lte] together, so the car uses WiFi at home and LTE on the road.

  • select_uplink returns Uplink::Both instead of an error. xtask starts WiFi as net_stack and LTE as lte_stack, and spawns mqtt_driver_task(net_stack, Some(lte_stack), …). WiFi-only and LTE-only builds pass None.
  • mqtt_driver_task connects on WiFi when it is up, on LTE otherwise. A session ends when its stack loses its configuration (reconnects on the other one), and a session on LTE moves back to WiFi once WiFi has stayed up for 20 s, so a car at the edge of WiFi range doesn't bounce. Each move is a new broker session, so the app re-handshakes (unknown-session frame, as for any broker reconnect).
  • LAN direct and the SavvyCAN logger run on WiFi, also in a build that joins LTE.
  • The modem stays online while the relay is on WiFi, so the fallback is immediate.
  • CI's esp-lte-mtls.toml now enables WiFi, LTE and LAN, so the dual-uplink path is linted and built on Xtensa.

Docs: lte.md (new "WiFi and LTE together" section), lan.md, mqtt-relay.md, architecture.md, config.toml.example.

How it was tested

  • cargo test -p xtask passes, with new tests for Uplink::Both, the spawn code with and without the fallback, and the LTE stack variable name.
  • cargo fmt --all -- --check passes.
  • Not run here: ESP builds (CI builds them) and anything on hardware. To test on the LilyGO: enable WiFi and LTE, start near WiFi, then switch the WiFi off (relay should reconnect over LTE within a few seconds) and back on (relay should move back about 20 s later). The serial log says MQTT: using WiFi / MQTT: using LTE.

Checklist

  • PR title uses conventional-commit style (feat(scope):, fix(scope):, docs:, chore:)
  • cargo fmt --all -- --check, cargo xtask clippy and cargo xtask test pass (fmt and xtask tests pass locally; clippy and builds by CI)
  • Docs (docs/ or README) updated if behaviour changed
  • No config.toml, credentials, build artifacts or .bin files committed
  • If the wire format changed: the contracts PR is linked and the submodule bump is its own commit (no wire change here)

Safety

  • This change does not touch CAN TX, BLE pairing/encryption, or OTA
  • It does, and CAN TX is still gated by is_can_read_only() and BLE checks are intact (explain below)

Generated by Claude Code

…intext MQTT

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
A build can enable [network.wifi] and [network.lte] at once. The relay
runs on WiFi while it is up and on LTE otherwise, and moves back to
WiFi once it has stayed up for 20 s. LAN direct and the SavvyCAN logger
run on WiFi, also in a build that joins LTE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
The ESP32-S3 build with both uplinks overflowed static RAM by ~47 KB
(stack.x: cannot move location counter backwards).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
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