Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
The MQTT transport now carries secure channel frames only (contracts docs/mqtt-relay.md): per-client topics named by the device and client key IDs, a new client ID per connection, heartbeats through the session, and a new handshake after a broker reconnect or when the device goes quiet. The plaintext topics and mqtt_client_id are gone. The broker is set per vehicle in Settings > MQTT broker (address, optional username and password, optional CA and client certificate), kept in secure storage. config.toml's broker is only a debug default. Relay problems show as a dashboard banner the user can act on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
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 #131. Part of OpenCarControls/contracts#44, phase 3. Ships with OpenCarControls/firmware#138 (relay) and needs OpenCarControls/contracts#53 (pinned to its branch until it merges).
What and why
The app reaches the car through any MQTT broker, with the broker only carrying secure channel frames, so it doesn't need to be trusted and no certificates are required.
MqttCarTransportrewritten on the secure channel: subscribes toopencar/{device_key_id}/c/{client_key_id}, publishes to.../d/{client_key_id}(QoS 1, no retain), client ID{client_key_id}-{8 hex}new per connection. Heartbeat (AppToDevice.heartbeat) through the session every 15 s in the foreground (stops 30 s after backgrounding). New handshake after a broker reconnect, and when nothing arrives for 90 s. Reconnects with a growing delay. The broker client is behindMqttRelayClient, so tests use a fake broker in front of the existing fake secure device.REJECTED_UNAVAILABLE(battery preconditioning stays Bluetooth-only, as decided), the app refuses system commands.mqtt://ormqtts://, optional port), optional username/password, optional CA and client certificate/key (mTLS). Stored in secure storage (MqttBrokerStore), deleted on unpair. Withmqtts://and no CA, the phone's usual authorities are trusted (hosted brokers). The screen shows the device and phone key IDs for the broker's ACL.config.toml's broker is now only a debug default.SystemState.mqtt_client_idhandling, the unused broker fields inPairedVehicleConfig, and the per-vehicle MQTT topic constants. NewMqttRelayConstantsBuildergeneratesmqtt_relay_constants.g.dartfrom[mqtt].SecretStoregetsdelete.Docs:
docs/mqtt-tls.mdrewritten asdocs/mqtt-relay.md; architecture, code generation, UI (banner, settings screen), README andconfig.toml.exampleupdated.Not done here: the phone's trust level over remote links (#92 follow-up). The device doesn't send it over the LAN or the relay yet, so the access providers still ignore remote links.
How it was tested
test/mqtt_relay_test.dart: topics and client IDs, URL parsing, settings validation, secure storage round trip, and the transport against a fake broker and fake device (handshake via heartbeat, commands, system commands refused, broker refusal, bad certificates stop retrying, device silent, re-handshake after silence, reconnect with a new client ID, dispose).mqtt://<pc-ip>with a local Mosquitto), turn Bluetooth and Wi-Fi off, and check state and basic commands; thenmqtts://with your CA.Checklist
feat:,fix:,docs:,chore:); CI validates itdart format,flutter analyze --fatal-infosandflutter testpass (CI)docs/or README) updated if behaviour changedconfig.tomlor credentials committed; generated files not hand-editedSafety
Remote commands now reach the vehicle over MQTT, but only through the authenticated secure channel: the device decides (validated phone, CAN approval, basic commands only). BLE pairing and bonding are unchanged.
Generated by Claude Code