Difference between revisions of "Protobuf notes"

From Wiki at Neela Nurseries
Jump to: navigation, search
m (Add protobuf.dev links.)
m (Entering some notes on nanopb and pb_callback_t for accessing nested protobuf messages.)
Line 4: Line 4:
 
*  https://protobuf.dev/getting-started/cpptutorial/
 
*  https://protobuf.dev/getting-started/cpptutorial/
 
*  https://protobuf.dev/programming-guides/proto3/
 
*  https://protobuf.dev/programming-guides/proto3/
 +
 +
When compiling nanopb Protobuf library as part of C language programs, nested Protobuf messages require use of nanopb defined function type `pb_callback_t` in order to encode and to decode those nested messages.  Some examples of this on github:
 +
 +
*  https://github.com/particle-iot/device-os/blob/9338b13b1e611f1b57f71f702795c2ca71142c1f/proto_defs/src/cloud/describe.pb.h#L9
 +
 +
*  https://github.com/hello/kitsune/blob/6a28afa80dd4547907e58341a84bd0b5bec5d88e/kitsune/protobuf/periodic.pb.h#L11
 +
 +
In the first example an early on file instance of `pb_callback_t` occurs on [https://github.com/particle-iot/device-os/blob/9338b13b1e611f1b57f71f702795c2ca71142c1f/proto_defs/src/cloud/describe.pb.h#L56 line 56]. 
 +
  
 
== [[#top|^]] References To Sort ==
 
== [[#top|^]] References To Sort ==

Revision as of 04:42, 6 October 2024

Introduction:

When compiling nanopb Protobuf library as part of C language programs, nested Protobuf messages require use of nanopb defined function type `pb_callback_t` in order to encode and to decode those nested messages. Some examples of this on github:

In the first example an early on file instance of `pb_callback_t` occurs on line 56.


^ References To Sort

Protobuf references, somewhat arbitrary starting point yet introduces some key topics of Protobuf standard and use cases:

JSON supported data types:


First Protobuf .proto file, compiles using `protoc-c`, part of a package available with Ubuntu 20.04:

// syntax = "proto3";
syntax = "proto2";

// Notes:
// $ protoc-c --c_out=. ./first.proto

message sensorUpdates {
  required int32 message_id = 1;
  optional float vrms = 2;
}

. . . It appears that the integer values which message elements are assigned as tantamount to key names in JSON.

^ Nanopb

2022-01-08 Saturday

Cmake script to locate Nanopb headers and sources: