This sample uses zcbor-generated code to decode 3 instances of a data structure. The 3 data structures are created in 3 different ways:
- Converted from YAML using the zcbor script (See CMakeLists.txt, pet1.yml, and pet1.h).
- Encoded using the zcbor C API.
- Encoded using zcbor-generated C code.
The generated code is found in src and include.
To regenerate the files, invoke the CMakeLists.txt file with -DREGENERATE_ZCBOR=Y
.
pet1.yml files contain the first three representations. Changing pet1.yml will change the printed output for the first pet. To change the output for the second and third, change the code in src/main.c.
mkdir build
cmake . -Bbuild
make -C build
build/app
Name: Carrie Cat Birthday: 0x0012003400560078 Species: Cat
Name: Danny the Dog Birthday: 0x0001020304050607 Species: Dog
Name: Gary Giraffe Birthday: 0x010203040a0b0c0d Species: Other