Skip to content

feat(transport): carry the secure channel over any MQTT broker as a relay - #53

Open
Tichael wants to merge 1 commit into
mainfrom
feat/mqtt-relay
Open

Tichael wants to merge 1 commit into
mainfrom
feat/mqtt-relay

Conversation

@Tichael

@Tichael Tichael commented Dec 6, 2026 •

Copy link
Copy Markdown
Collaborator

Requested by Michaël · project thread

What and why

Phase 3 of #44: the contract for carrying the secure channel over any MQTT broker, used as an untrusted relay. Closes #48. Implemented by OpenCarControls/firmware#138 (relay; OpenCarControls/firmware#139 adds WiFi + LTE together on top) and OpenCarControls/mobile-app#140 (app).

  • [mqtt] in transport.toml: one topic per client in both directions, opencar/{device_key_id}/d/{client_key_id} (the device subscribes to d/+) and opencar/{device_key_id}/c/{client_key_id}, plus the reserved retained state topic. QoS 1, never retained. Device client ID = device key ID; app client ID = client key ID + 4 random bytes per connection.
  • Relay timing: heartbeat every 15 s in the foreground, a session is active for 35 s after an inbound frame (state at most once per second), idle sessions get the newest state every 30 s, system state repeats every 30 s, and the app re-handshakes after 90 s of silence.
  • Deprecated: the plaintext command_topic_template / data_topic_template and SystemState.mqtt_client_id (field kept, marked deprecated).
  • Client key ID defined in docs/secure-channel.md and added to the test vectors (and their generator).
  • docs/mqtt-relay.md: topics, client IDs, what the relay carries (remote tier: basic state and basic commands only), optional broker hardening (none / password / TLS / mTLS), what the broker can still see, a suggested Mosquitto ACL, and WiFi + LTE devices. docs/lan.md updated for devices with both uplinks.

Why one topic per client for client → device too: #48 proposed a single device topic for every client. With it the device can't route the unknown session frame (it doesn't know which client a frame for an unknown session came from), which clients rely on after a device restart or a broker reconnect. The device also drops a handshake init whose client key doesn't match the key ID in its topic.

Checklist

  • PR title uses conventional-commit style (feat:, fix:, docs:, chore:)
  • buf format, buf lint and buf breaking pass (CI)
  • Append-only rules followed: no renumbered, retyped or deleted fields; new fields appended and optional
  • BLE message size limit still respected (state updates fit in ble.payload.max_message_bytes)
  • Matching firmware and mobile-app changes exist or are linked

Source of the data

No vehicle signals: transport only.

https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp


Generated by Claude Code

…elay

Per-client topics in both directions, device and app client IDs, relay
state throttling and timeouts in [mqtt] of transport.toml, the client key
ID in the test vectors, docs/mqtt-relay.md, and deprecate the plaintext
topics and SystemState.mqtt_client_id.

Closes #48

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XkZEiWoJmJsqnYdysAR9wp
@Tichael Tichael self-assigned this Dec 6, 2026
@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Proto Check / check (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedDec 6, 2026, 6:00 AM

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.

Carry the secure channel over MQTT: topics and broker settings

2 participants