app/rcc/ai/skills/mqtt.md
MQTT lets Serial Studio either publish parsed telemetry to a broker
(publisher) or subscribe to a broker and treat incoming payloads as
device frames (subscriber). The two sides are configured independently
through project.mqtt.publisher.* and project.mqtt.subscriber.*.
project.mqtt.subscriber.*): the dashboard
subscribes to a topic and every incoming payload is parsed as if it
came from a serial device. Use when an IoT sensor or gateway already
publishes and you want to visualize it. This is the more common case.
The subscriber is an I/O driver: after configuring it, select the
mqtt bus (io.setBusType -- discover the right value with
io.listBuses) and io.connect. Both calls are device-gated.project.mqtt.publisher.*): the dashboard publishes
its data to a topic. Use when Serial Studio is the gateway between a
local device and a fleet/cloud. Publisher modes (mode field):
0=RawRxData (raw bytes as received), 1=ScriptDriven (a JS script
shapes each message), 2=DashboardCsv, 3=DashboardJson. Setting
enabled: true starts publishing; no io.connect involved.Both sides use a single patch-style command; pass only the keys you want to change:
project.mqtt.subscriber.getConfig{} or
project.mqtt.publisher.getConfig{}. The response carries the
canonical enum tables (mqttVersions, sslProtocols,
peerVerifyModes, and modes for the publisher). Use them to
interpret and choose integer fields instead of guessing.project.mqtt.subscriber.setConfig{hostname, port, ...} or
project.mqtt.publisher.setConfig{...}. Typical broker defaults:
port 1883 (plaintext) or 8883 (TLS).topicFilter supports + (exactly one level)
and # (multi-level, only at the end). Publisher topic root is
topicBase; notificationTopic + publishNotifications forward
app notifications.io.setBusType to the mqtt bus, then
io.connect. Publisher start: setConfig{enabled: true}.project.mqtt.subscriber.getStatus{} (isOpen, endpoint) or
project.mqtt.publisher.getStatus{} (connected, messagesSent).setConfig call requires an explicit per-call user click in
the chat (alwaysConfirm), since credentials and TLS settings ride on
it. Batch the fields into as few calls as possible.password requires username in the same call; the pair lands in
the encrypted vault (publisher) or driver settings (subscriber),
never in the project file. getConfig never returns the password --
check hasCredentials on the publisher instead. To clear publisher
credentials, pass empty strings for both.sslEnabled: true, then pick sslProtocol and
peerVerifyMode from the enum tables. Production brokers usually
want peer verification enabled, not 0/None.Even in subscriber mode, the frame parser runs on every incoming MQTT payload. The payload IS the frame body, the same shape your UART parser would see. If the broker publishes JSON, use a JSON-capable frame parser; if CSV, the default delimited parser works as-is.
sslEnabled and the port (8883).clientId. Set an explicit
id per instance, or (publisher) customClientId: false to
regenerate one automatically.# only at the end, + exactly one level.
Malformed filters are rejected on subscribe, not at setConfig time.publishFrequency is clamped to 1-30 Hz; it
decouples broker traffic from the device frame rate.