All in one solution demonstrating how to use nanopb Protocol Buffers library from within mbed environment. Test case is very simple. It works.

Dependencies:   nanopb protocol

Original import was an all-in-one solution that only depends on mbed.

Current implementation extracted 2 librarires:

1) nanopb contains code required to use nanopb and Timestamp dependency. 2) protocol is a specific research protocol used by LCE at Itron at the moment of commit.

The application decodes Protocol Buffers message generated with GO application using the same 'protocol'. This test level application decodes message and validates that it matches expected.

It is simply a proof that nanopb library can be used.

source/protocol/sample.pb.h

Committer:
sgnezdov
Date:
2017-07-12
Revision:
0:fbdd0d307c19

File content as of revision 0:fbdd0d307c19:

/* Automatically generated nanopb header */
/* Generated by nanopb-0.3.8 at Wed Jul 12 11:04:33 2017. */

#ifndef PB_PROTOCOL_SAMPLE_PB_H_INCLUDED
#define PB_PROTOCOL_SAMPLE_PB_H_INCLUDED
#include <pb.h>

#include "google/protobuf/timestamp.pb.h"

/* @@protoc_insertion_point(includes) */
#if PB_PROTO_HEADER_VERSION != 30
#error Regenerate this file with the current version of nanopb generator.
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* Struct definitions */
typedef struct _protocol_SecureSampleBatch {
    pb_callback_t signature;
    pb_callback_t content;
/* @@protoc_insertion_point(struct:protocol_SecureSampleBatch) */
} protocol_SecureSampleBatch;

typedef struct _protocol_Sample {
    google_protobuf_Timestamp takenDT;
    uint32_t alarm;
    pb_callback_t Payload;
/* @@protoc_insertion_point(struct:protocol_Sample) */
} protocol_Sample;

typedef struct _protocol_SampleBatch {
    pb_callback_t sn;
    uint32_t dataType;
    uint32_t intervalLenghtInSeconds;
    pb_callback_t items;
/* @@protoc_insertion_point(struct:protocol_SampleBatch) */
} protocol_SampleBatch;

/* Default values for struct fields */

/* Initializer values for message structs */
#define protocol_Sample_init_default             {google_protobuf_Timestamp_init_default, 0, {{NULL}, NULL}}
#define protocol_SampleBatch_init_default        {{{NULL}, NULL}, 0, 0, {{NULL}, NULL}}
#define protocol_SecureSampleBatch_init_default  {{{NULL}, NULL}, {{NULL}, NULL}}
#define protocol_Sample_init_zero                {google_protobuf_Timestamp_init_zero, 0, {{NULL}, NULL}}
#define protocol_SampleBatch_init_zero           {{{NULL}, NULL}, 0, 0, {{NULL}, NULL}}
#define protocol_SecureSampleBatch_init_zero     {{{NULL}, NULL}, {{NULL}, NULL}}

/* Field tags (for use in manual encoding/decoding) */
#define protocol_SecureSampleBatch_signature_tag 1
#define protocol_SecureSampleBatch_content_tag   2
#define protocol_Sample_takenDT_tag              1
#define protocol_Sample_alarm_tag                2
#define protocol_Sample_Payload_tag              10
#define protocol_SampleBatch_sn_tag              1
#define protocol_SampleBatch_dataType_tag        2
#define protocol_SampleBatch_intervalLenghtInSeconds_tag 3
#define protocol_SampleBatch_items_tag           10

/* Struct field encoding specification for nanopb */
extern const pb_field_t protocol_Sample_fields[4];
extern const pb_field_t protocol_SampleBatch_fields[5];
extern const pb_field_t protocol_SecureSampleBatch_fields[3];

/* Maximum encoded size of messages (where known) */
/* protocol_Sample_size depends on runtime parameters */
/* protocol_SampleBatch_size depends on runtime parameters */
/* protocol_SecureSampleBatch_size depends on runtime parameters */

/* Message IDs (where set with "msgid" option) */
#ifdef PB_MSGID

#define SAMPLE_MESSAGES \


#endif

#ifdef __cplusplus
} /* extern "C" */
#endif
/* @@protoc_insertion_point(eof) */

#endif