|
|
Nanopb
|
|
|
![Test Cost Pyramid](test_pyramid.png) |
|
|
\ No newline at end of file |
|
|
**Table of Contents**
|
|
|
|
|
|
[[_TOC_]]
|
|
|
|
|
|
----
|
|
|
# Introduction
|
|
|
|
|
|
## Protocol Buffer
|
|
|
|
|
|
[Protocol Buffer](https://developers.google.com/protocol-buffers/) is a tool developed by Google for serializing structured data which can then be used to transmit data from one medium to another. For example, sensor readings captured from a microcontroller could be sent to the cloud for logging and diagnostics after encoding the data in a serialized format for easier byte-byte transmission.
|
|
|
|
|
|
Protocol buffer can serialize data from variety of languages such as Java, Python, Objective-C C++, Dart, Go, Ruby, and C# along with running on any platform.
|
|
|
|
|
|
## Nanopb
|
|
|
[Nanopb](https://jpa.kapsi.fi/nanopb/) provides a C based library for encoding and decoding messages in Google's Protocol Buffers format with suitable for microcontrollers with less RAM and code space availability. Google's Protocol Buffer Tool can generate data structures for C++ and not for C, thus making it less suitable for Microcontrollers.
|
|
|
|
|
|
# Installation and Setup
|
|
|
|
|
|
## Setup for Nanopb
|
|
|
To use Nanopb, protocol compiler needs to be installed. Follow the [installation instructions](https://github.com/protocolbuffers/protobuf#protocol-compiler-installation) here.
|
|
|
|
|
|
Protocol Buffers messages are defined in a `proto file` as follows:
|
|
|
```
|
|
|
//foo.proto
|
|
|
message Foo {
|
|
|
required int id = 1;
|
|
|
}
|
|
|
```
|
|
|
Headers(.h) and source files(.c) are generated using a python script provided by Nanopb.
|
|
|
```
|
|
|
python generator/nanopb_generator.py myprotocol.proto
|
|
|
```
|
|
|
These header and source files are required to be used with Nanopb.
|
|
|
Follow the [instructions here](Follow the [installation instructions]).
|
|
|
|
|
|
# Implementation and Examples
|
|
|
|
|
|
|
|
|
## Simple Getting started Example
|
|
|
Todo
|
|
|
|
|
|
## Using Callback for Nanopb
|
|
|
Todo
|
|
|
|
|
|
# External Resources
|
|
|
* [Protocol Buffer](https://developers.google.com/protocol-buffers/)
|
|
|
* [Nanopb](https://jpa.kapsi.fi/nanopb/)
|
|
|
* [Nanopb Github](https://github.com/nanopb/nanopb)
|
|
|
* [Nanopb simple callback example](https://stackoverflow.com/questions/45979984/creating-callbacks-and-structs-for-repeated-field-in-a-protobuf-message-in-nanop) |
|
|
\ No newline at end of file |