|
ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
|
The OMA LightweightM2M TLV data format (PROTOCORE_ENABLE_LWM2M): a zero-heap writer and reader for application/vnd.oma.lwm2m+tlv.
More...
#include "protocore_config.h"Go to the source code of this file.
The OMA LightweightM2M TLV data format (PROTOCORE_ENABLE_LWM2M): a zero-heap writer and reader for application/vnd.oma.lwm2m+tlv.
TLV is not an IETF format. It is specified by the Open Mobile Alliance in OMA-TS-LightweightM2M_Core-V1_2-20201110-A sec 7.4.5. The octets travel as a CoAP payload (RFC 7252), tagged by the Content-Format Option (RFC 7252 sec 5.10.3); LwM2M Core sec 7.4 Table 7.4.-1 pairs the media type application/vnd.oma.lwm2m+tlv with the numeric Content-Format 11542.
LwM2M Core sec 7.4.5 Table 7.4.5.-1 lays one entry out as Type(1) Identifier(1-2) Length(0-3) Value(n):
LwM2M Core Appendix C Table C.-2 gives the Value forms: Integer is a binary signed integer in network byte order and two's complement representation, 1, 2, 4 or 8 octets; Float is binary32 or binary64, and this writer emits binary64; Boolean is an 8-bit unsigned integer 0 or 1 whose "Length of a Boolean value MUST always be 1 byte"; String is UTF-8 of Length octets; Opaque is Length octets as they stand.
The writer emits entries into a caller buffer and fails closed: the first entry that does not fit poisons the cursor, so a finish reports 0 rather than a truncated payload. The reader is a cursor over a caller buffer that decodes the entry at its head and advances past it, pointing at the Value where it lies rather than copying it.
No slot member: the module keeps one writer cursor and one reader cursor, so no call names a row.
The module exports one symbol, Lwm2mTlv. Everything in lwm2m_tlv.c has internal linkage.
Definition in file lwm2m_tlv.h.