|
ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
|
SenML (RFC 8428) sensor-measurement pack builder (PC_ENABLE_SENML) - zero-heap SenML-JSON and SenML-CBOR encoders over the shipped JSON / CBOR codecs. SenML is the standard measurement format for CoAP / LwM2M / HTTP telemetry. More...
#include "protocore_config.h"Go to the source code of this file.
SenML (RFC 8428) sensor-measurement pack builder (PC_ENABLE_SENML) - zero-heap SenML-JSON and SenML-CBOR encoders over the shipped JSON / CBOR codecs. SenML is the standard measurement format for CoAP / LwM2M / HTTP telemetry.
A SenML pack is an array of records. Each record carries an optional base name / base time (applied to the records that follow), a name, a unit, and exactly one value (a number, a string, or a boolean), plus an optional time:
SenML-JSON uses the text labels (bn/bt/n/u/v/vs/vb/t); SenML-CBOR uses the integer labels (n=0 u=1 v=2 vs=3 vb=4 t=6, bn=-2 bt=-3) in a CBOR map per record. Numbers that are integral are emitted as integers (so timestamps keep full precision); otherwise as floats.
The caller fills a SenmlRecord array and the builder emits the whole pack into a caller buffer (fail-closed on overflow). Verified against the RFC 8428 example. A resolver (pc_senml_resolve, RFC 8428 ยง4.6) folds the base name / base time into each record so a consumer gets standalone records with a full name and an absolute time.
Definition in file senml.h.