forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: services: serialization: Add Nanopb entry
Move part of the Nanopb sample documentation to a serialization entry and add information on how to configure proto files. Signed-off-by: Pieter De Gendt <[email protected]>
- Loading branch information
1 parent
44e8123
commit 6c273f5
Showing
4 changed files
with
98 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.. _seialization_reference: | ||
|
||
Serialization | ||
############# | ||
|
||
Zephyr has support for several data serialization subsystems. These can be used to encode/decode | ||
structured data with a known format on-the-wire. | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
nanopb.rst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.. _nanopb_reference: | ||
|
||
Nanopb | ||
###### | ||
|
||
`Nanopb <https://jpa.kapsi.fi/nanopb/>`_ is a C implementation of Google's | ||
`Protocol Buffers <https://protobuf.dev/>`_. | ||
|
||
Requirements | ||
************ | ||
|
||
Nanopb uses the protocol buffer compiler to generate source and header files, | ||
make sure the ``protoc`` executable is installed and available. | ||
|
||
.. tabs:: | ||
|
||
.. group-tab:: Ubuntu | ||
|
||
Use ``apt`` to install dependency: | ||
|
||
.. code-block:: shell | ||
sudo apt install protobuf-compiler | ||
.. group-tab:: macOS | ||
|
||
Use ``brew`` to install dependency: | ||
|
||
.. code-block:: shell | ||
brew install protobuf | ||
.. group-tab:: Windows | ||
|
||
Use ``choco`` to install dependency: | ||
|
||
.. code-block:: shell | ||
choco install protoc | ||
Additionally, Nanopb is an optional module and needs to be added explicitly to the workspace: | ||
|
||
.. code-block:: shell | ||
west config manifest.project-filter -- +nanopb | ||
west update | ||
Configuration | ||
************* | ||
|
||
Make sure to include ``nanopb`` within your ``CMakeLists.txt`` file as follows: | ||
|
||
.. code-block:: cmake | ||
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 <https://jpa.kapsi.fi/nanopb/docs/reference.html#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 :zephyr_file:`samples/modules/nanopb/src/simple.options.in` and | ||
:zephyr_file:`samples/modules/nanopb/CMakeLists.txt` for usage example. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters