MQTT is the workhorse protocol for fleets that keep a persistent connection and
need both telemetry up and commands down over the same session. CORE-M brokers
MQTT through EMQX; the device-link adapter subscribes to the broker,
normalizes each message into a TelemetryPoint, and publishes it onto the
internal bus — exactly like every other protocol.
Authentication happens in the MQTT CONNECT packet. The device identifies
itself with its device_id and authenticates with its API key (or PSK):
CONNECT field
Value
Client ID
the device’s device_id
Username
the device’s device_id
Password
the device’s API key (sk_live_...) or PSK
Because the client ID is the device identity, the broker rejects a second
connection trying to use the same client ID, and the adapter attributes every
message on that session to that device. Identity comes from the authenticated
session — never from anything inside the payload.
Publish a JSON object of metric → value pairs. The adapter normalizes it into a
TelemetryPoint, mapping numeric fields into numeric_values and string fields
into string_values:
{
"temperature": 22.5,
"humidity": 65,
"state": "running"
}
The device_id and tenant_id are taken from the authenticated session, and
the timestamp is stamped on arrival unless your payload decoder extracts one. See
sending telemetry for the full
TelemetryPoint model.
The first telemetry message flips the device to online. CORE-M tracks
liveness from telemetry arrival, not just the TCP connection: if no telemetry
arrives for longer than the offline threshold (default 120 seconds), the device
is marked offline even if the MQTT session is technically still open. Devices
that report infrequently should either publish a heartbeat reading or have their
threshold tuned accordingly.