Skip to content

Commit a1bd906

Browse files
Veijo Pesonencarlescufi
authored andcommitted
net: lwm2m: adds README
Includes instructions for generating the SenML CBOR encoder and decoder. Signed-off-by: Veijo Pesonen <[email protected]>
1 parent 98b22a1 commit a1bd906

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

subsys/net/lib/lwm2m/README_lwm2m

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
LwM2M Client in Zephyr
2+
----------------------
3+
4+
### SenML CBOR
5+
6+
SenML CBOR content format support takes advantage of the Zcbor library's capability of generating
7+
domain specific code. To generate the SenML encoder and decoder the following CDDL file
8+
is used as an input for the generator:
9+
10+
```
11+
lwm2m_senml = [1* record]
12+
13+
record = {
14+
? bn => tstr, ; Base Name
15+
? n => tstr, ; Name
16+
? ( vi => int .size 8 // ; Integer Value
17+
vf => float // ; Float Value
18+
vs => tstr // ; String Value
19+
vb => bool // ; Boolean Value
20+
vd => bstr ), ; Data Value
21+
0*3 key-value-pair ; To handle unordered maps; length-first ordered map keys
22+
}
23+
24+
; now define the generic versions
25+
key-value-pair = ( int => value )
26+
27+
value = tstr / bstr / int .size 8 / float / bool
28+
29+
n = 0
30+
bn = -2
31+
vi = 2
32+
vf = 2
33+
vs = 3
34+
vd = 8
35+
vb = 4
36+
```
37+
38+
The CDDL description is based on the RFC 8428 - Sensor Measurement Lists (SenML). For further
39+
details please see the chapter 11 - CDDL.
40+
41+
To generate the encoder and decoder:
42+
43+
```console
44+
zcbor --default-max-qty 99 -c CDDL_FILE code -e -t lwm2m_senml --oc lwm2m_senml_cbor_encode.c --oh lwm2m_senml_cbor_encode.h
45+
zcbor --default-max-qty 99 -c CDDL_FILE code -d -t lwm2m_senml --oc lwm2m_senml_cbor_decode.c --oh lwm2m_senml_cbor_decode.h
46+
```
47+
48+
The default value of the number of maximum allowed records doesn't really matter as it's replaced
49+
with a Kconfig option.
50+

0 commit comments

Comments
 (0)