Skip to content

Commit c1a9866

Browse files
oyvindronningstadcarlescufi
authored andcommitted
west.yml: Update zcbor to v. 0.5.1
lwm2m: Regenerate lwm2m_senml code from the CDDL description. Reapply manual changes. Create a sh script to perform the regeneration. tests: zcbor_bulk: Adapt to zcbor 0.5.1 zcbor_new_decode_state() now has no return value. Signed-off-by: Øyvind Rønningstad <[email protected]>
1 parent d96f361 commit c1a9866

File tree

11 files changed

+544
-144
lines changed

11 files changed

+544
-144
lines changed

subsys/net/lib/lwm2m/README_lwm2m

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,44 +7,30 @@ SenML CBOR content format support takes advantage of the Zcbor library's capabil
77
domain specific code. To generate the SenML encoder and decoder the following CDDL file
88
is used as an input for the generator:
99

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-
```
10+
.. include:: lwm2m_senml.cddl
11+
:code: txt
3712

3813
The CDDL description is based on the RFC 8428 - Sensor Measurement Lists (SenML). For further
3914
details please see the chapter 11 - CDDL.
4015

4116
To generate the encoder and decoder:
4217

4318
```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
19+
sh lwm2m_senml_cbor_regenerate.sh
20+
```
21+
22+
The above command also applies the lwm2m_senml_cbor.patch patch file.
23+
If the patch fails to apply, you can attempt to use the 3-way merge capabilities by committing the un-patched changes (i.e. up to and including the clang-format), and the running
24+
25+
```console
26+
git am -3 < lwm2m_senml_cbor.patch
27+
```
28+
29+
The patch was created by, committing the unpatched changes, then committing the desired patches in a subsequent commit, then creating the patch file with the command
30+
31+
```console
32+
git format-patch --stdout HEAD~1.. > lwm2m_senml_cbor.patch
4633
```
4734

4835
The default value of the number of maximum allowed records doesn't really matter as it's replaced
4936
with a Kconfig option.
50-
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
lwm2m_senml = [1* record]
2+
3+
record = {
4+
? bn => tstr, ; Base Name
5+
? n => tstr, ; Name
6+
? ( vi => int .size 8 // ; Integer Value
7+
vf => float // ; Float Value
8+
vs => tstr // ; String Value
9+
vb => bool // ; Boolean Value
10+
vd => bstr ), ; Data Value
11+
0*3 key-value-pair ; To handle unordered maps; length-first ordered map keys
12+
}
13+
14+
; now define the generic versions
15+
key-value-pair = ( int => value )
16+
17+
value = tstr / bstr / int .size 8 / float / bool
18+
19+
n = 0
20+
bn = -2
21+
vi = 2
22+
vf = 2
23+
vs = 3
24+
vd = 8
25+
vb = 4

0 commit comments

Comments
 (0)