Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
…intext MQTT 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
This was referenced Dec 6, 2026
Tichael
marked this pull request as ready for review
December 6, 2026 06:26
5 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Michaël · project thread
Closes #122. Part of OpenCarControls/contracts#44, phase 3. Needs OpenCarControls/contracts#53 (submodule pinned to its branch until it merges); ships with OpenCarControls/mobile-app#140. #139 (WiFi + LTE together) is stacked on this one.
What and why
Any MQTT broker becomes a relay for the secure channel, and plaintext MQTT is gone, so remote commands are as authenticated as on the LAN and the broker never sees state or commands.
core-interface/src/relay.rs(new): the relay's logic, host-tested. The device connects with its device key ID as client ID and subscribes toopencar/{device_key_id}/d/+; each client publishes on its ownd/{client_key_id}topic and gets answers onc/{client_key_id}. A handshake whose client key doesn't hash to the topic's key ID is dropped. Per broker connection (relay_connect/relay_disconnect): one session per client key (newest wins), and a reconnect ends them all, so clients get an unknown-session frame and handshake again.relay_try_next_frame, in order): command responses, a system state when due (session start, availability or LAN address change, every 30 s), then the basic state, throttled per session: at most 1/s while the client sent something within 35 s (its 15 s heartbeat), otherwise every 30 s. Nothing is published without a session. QoS 1, no retain; a frame the client can't queue yet (in-flight limit) waits.REJECTED_UNAVAILABLE, system commands dropped.MQTT_TX/RX/STATE_TX,Transport::Mqtt, the plaintext MQTT dispatcher,mqtt_client_id(config andSystemState), and the topic constants.[network.mqtt].client_idis ignored with a warning.mqtt_driver_taskrun the relay loop on top of the existing TCP/TLS connection.auth_mode = "none"for a broker without a password;basicstays the default. TLS remains optional hardening. Building without TLS saves about 540 KB of flash on the ESP.Docs:
docs/mqtt-tls.mdrewritten asdocs/mqtt-relay.md; architecture, README, ble, commands, lan, lte, testing andconfig.toml.exampleupdated.How it was tested
core-interface/tests/relay.rs: topics, topic/key mismatch, nothing without a session, system and basic state on a new session, per-client topics, system state repeat, active and idle throttle, newer handshake replaces the older, basic command and its response, advanced refused, no plaintext accepted, broker reconnect gives an unknown session, stale broker connection. MQTT tests that tested plaintext were removed.cargo test -p xtasklocally; CI passes (tests, host lint, PC and ESP builds for both vehicles, ESP LTE mTLS build).Checklist
feat(scope):,fix(scope):,docs:,chore:)cargo fmt --all -- --check,cargo xtask clippyandcargo xtask testpass (CI)docs/or README) updated if behaviour changedconfig.toml, credentials, build artifacts or.binfiles committedSafety
is_can_read_only()and BLE checks are intact (explain below)Commands from the relay go through the same secure-channel dispatcher as the LAN: the validated-phone check, the CAN approval and
CommandAuthorizationare unchanged, andsource_device_idcomes from the session's client key, never from the app. Plaintext MQTT commands are no longer accepted at all.https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
Generated by Claude Code