CoAP is the protocol for the smallest, most constrained devices — battery-powered
sensors on lossy networks where TCP and TLS are too heavy. It runs over UDP, uses
compact CBOR payloads, and secures the link with DTLS. CORE-M terminates CoAP in
the device-link adapter, authenticates the device from the DTLS handshake,
decodes the CBOR body with the device profile’s decoder, and publishes a normal
TelemetryPoint.
CoAP devices authenticate during the DTLS handshake, before any CoAP request
is processed. Two modes are supported:
DTLS-PSK — the device presents a PSK identity; the adapter looks that
identity up to resolve the tenant, device, and pre-shared key, and completes
the handshake only if all three resolve. The negotiated cipher suite is
TLS_PSK_WITH_AES_128_CCM_8.
Certificate — the device presents an X.509 client certificate that maps to
a registered device identity.
Send telemetry by issuing a CoAP POST to the telemetry resource:
Method
POST
Resource
/telemetry
Payload
CBOR (application/cbor)
The payload is a CBOR-encoded object of metric → value pairs. The device
profile’s payload decoder turns it into a TelemetryPoint, mapping numeric
fields into numeric_values and string fields into string_values. The
conceptual content matches the JSON you would send over HTTP — just CBOR-encoded
to save bytes on the wire:
Using coap-client from libcoap over DTLS-PSK. The -u flag is the PSK
identity, -k is the pre-shared key, and the CBOR body is read from a file:
Prepare the CBOR payload. For example, encode
{"temperature":22.5,"humidity":65} to reading.cbor with your toolchain
(most CBOR libraries do this in one call).
POST it to the telemetry resource over CoAPS:
Terminal window
coap-client-mpost\
-u'psk-identity-d7b1c0e2'\
-k's3cr3t-pre-shared-key'\
-tapplication/cbor\
-freading.cbor\
'coaps://coap.kronoxdata.com:5684/telemetry'
A successful POST returns a 2.04 Changed response. The reading is now
normalized and on its way through the pipeline.
If the CBOR body is malformed or does not match the profile decoder, the payload
is rejected: the rejection metric
corem_protocol_payload_rejections_total{protocol="coap",reason="decode_error"}
is incremented and no telemetry is published to the bus. A decode failure
never produces a partial point. Inspect rejected samples in the protocol
diagnostics UI to find the offending field.
After the first accepted reading the device flips to online, and goes
offline if it stops sending for longer than the offline threshold (default
120 seconds).