Device protocol
Inspectable MQTT, strict envelopes.
Nivalo devices speak Cloud MQTT v1.1: per-device credentials bound to an exact client ID, bounded topic ownership, byte-limited JSON envelopes, session-epoch presence and at-most-once operations. The immutable protocol files published with this site are authoritative when this overview and a machine-readable contract differ.
Topics
| Direction | Topic | Purpose |
|---|---|---|
| Device → cloud | nivalo/v1.1/devices/{deviceId}/telemetry | Batched measurements: up to 8 samples and 24 readings per message |
| Device → cloud | nivalo/v1.1/devices/{deviceId}/events | Structured events with a severity |
| Device → cloud | nivalo/v1.1/devices/{deviceId}/state | Reported state observations |
| Device → cloud | nivalo/v1.1/devices/{deviceId}/definitions | Capability catalog deltas (variables and functions) |
| Device → cloud | nivalo/v1.1/devices/{deviceId}/availability | Retained birth and end, periodic heartbeat |
| Cloud → device | nivalo/v1.1/devices/{deviceId}/commands/{commandId} | Generic command delivery |
| Cloud → device | nivalo/v1.1/devices/{deviceId}/ota/{commandId} | Signed firmware update job |
| Device → cloud | …/commands/{commandId}/ack, …/ota/{commandId}/ack | Operation acknowledgements |
Envelope
Every message is one UTF-8 JSON object of at most 3072 bytes with a unique message ID, the exact device ID and a UTC timestamp from a synchronised clock. Operation routes carry a correlation ID equal to the route ID; only the availability birth carries the firmware identity.
{
"schema": "nivalo.iot.v1.1",
"messageId": "33333333-3333-4333-8333-333333333333",
"deviceId": "22222222-2222-4222-8222-222222222222",
"sentAt": "2026-11-24T12:00:05Z",
"payload": {
"samples": [
{ "at": "2026-11-24T12:00:00Z", "metrics": [{ "name": "temp", "value": 21.125, "unit": "C" }] },
{ "metrics": [{ "name": "temp", "value": 21.5, "unit": "C" }] }
]
}
}
Presence
- Each connection has an epoch: a persisted boot counter and a connection counter. The Last Will is a retained
endfor the connection being attempted. - After both subscriptions the device publishes a retained
birth, its whole capability catalog, and then a heartbeat with vitals every 10 minutes. - Status is computed:
onlinewhile heartbeats are fresh,offlineafter an end, andunknownbefore the first birth or after 22 minutes without a heartbeat.
Operations
- The API creates a command as
queuedwith a per-device sequence number, an issue time and an expiry. A command must name a function the device reports and the product defines with an argument schema. - Before publishing, the platform durably records that the operation may have been sent (
published), and it publishes at most one operation per device at a time. - The device journals its claim, reports
accepted(and optionallyrunning), runs the effect at most once, and finishes withsucceededorfailed. - An operation that ends without a device result after it may have been sent, or whose effect the device cannot confirm, is
indeterminate: the outcome is unknown and the device may have acted. It is never retried automatically.
Delivery rules
- Devices publish uplinks at QoS 0; the platform republishes live operations and devices answer duplicates from a durable journal, so a lost acknowledgement is recovered without running anything twice.
- A telemetry, event or state message is stored atomically and exactly once per message ID; identical resends are acknowledged as duplicates.
- Usage is counted in units: one per 16 telemetry readings plus one per event or state observation, so batching costs nothing extra.
- Invalid messages are rejected whole and never enter telemetry, event, presence or operation state.
- Firmware images are signed over their product ID, security version, size and digest; devices refuse other products and older versions.
Authoritative references
This page is an integration overview. CI copies an exact, immutable protocol revision into each public documentation artifact. Those published files are the source of truth for compatibility, exact fields, limits, and machine validation; they do not depend on anonymous access to the private engineering repository.
| Reference | Use it for |
|---|---|
| Cloud MQTT v1.1 | Topics, broker identity, envelopes, limits, presence, telemetry, capabilities, operations, OTA, errors and usage units. |
| Device claim v1 | One-use claim exchange, proof-of-possession, retry behavior, and password-free responses. |
| NivaloLink SPI v1 | ESP32-to-application-MCU framing, CRC, flow control, retries, and payload limits. |
| JSON Schemas | Machine validation for the envelope; the adjacent public protocol/schemas/v1.1/ directory contains telemetry, events, state, availability, capability, command, OTA and acknowledgement schemas. |