Nanopb
Nanopb is a C implementation of Google’s Protocol Buffers.
Requirements
Nanopb uses the protocol buffer compiler to generate source and header files,
make sure the protoc executable is installed and available.
Use apt to install dependency:
sudo apt install protobuf-compiler
Use brew to install dependency:
brew install protobuf
Use choco to install dependency:
choco install protoc
Configuration
Make sure to include nanopb within your CMakeLists.txt file as follows:
list(APPEND CMAKE_MODULE_PATH ${ZEPHYR_BASE}/modules/nanopb)
include(nanopb)
Adding proto files can be done with the zephyr_nanopb_sources() CMake function which
ensures the generated header and source files are created before building the specified target.
Nanopb has generator options that can be used to configure messages or fields. This allows to set fixed sizes or skip fields entirely.
The internal CMake generator has an extension to configure *.options.in files automatically
with CMake variables.
See samples/modules/nanopb/src/simple.options.in and samples/modules/nanopb/CMakeLists.txt for usage example.