All in one solution demonstrating how to use nanopb Protocol Buffers library from within mbed environment. Test case is very simple. It works.
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.
Diff: source/protocol/gasQuality.pb.h
- Revision:
- 0:fbdd0d307c19
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/protocol/gasQuality.pb.h Wed Jul 12 22:40:29 2017 +0000 @@ -0,0 +1,95 @@ +/* Automatically generated nanopb header */ +/* Generated by nanopb-0.3.8 at Wed Jul 12 11:04:33 2017. */ + +#ifndef PB_PROTOCOL_GASQUALITY_PB_H_INCLUDED +#define PB_PROTOCOL_GASQUALITY_PB_H_INCLUDED +#include <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 + +/* Enum definitions */ +typedef enum _protocol_GQStatus { + protocol_GQStatus_CQSuccess = 0 +} protocol_GQStatus; +#define _protocol_GQStatus_MIN protocol_GQStatus_CQSuccess +#define _protocol_GQStatus_MAX protocol_GQStatus_CQSuccess +#define _protocol_GQStatus_ARRAYSIZE ((protocol_GQStatus)(protocol_GQStatus_CQSuccess+1)) + +/* Struct definitions */ +typedef struct _protocol_GQSRawSample { + uint32_t Temperature1; + protocol_GQStatus Temperature1Err; + uint32_t Temperature2; + protocol_GQStatus Temperature2Err; + uint32_t Pressure1; + protocol_GQStatus Pressure1Err; + uint32_t Pressure2; + protocol_GQStatus Pressure2Err; + pb_callback_t MemsStatus; + protocol_GQStatus MemsStatusErr; + pb_callback_t MemsMeasurement; + protocol_GQStatus MemsMeasurementErr; + pb_callback_t errors; +/* @@protoc_insertion_point(struct:protocol_GQSRawSample) */ +} protocol_GQSRawSample; + +typedef struct _protocol_GQSRawSample_ErrorsEntry { + uint32_t key; + pb_callback_t value; +/* @@protoc_insertion_point(struct:protocol_GQSRawSample_ErrorsEntry) */ +} protocol_GQSRawSample_ErrorsEntry; + +/* Default values for struct fields */ + +/* Initializer values for message structs */ +#define protocol_GQSRawSample_init_default {0, (protocol_GQStatus)0, 0, (protocol_GQStatus)0, 0, (protocol_GQStatus)0, 0, (protocol_GQStatus)0, {{NULL}, NULL}, (protocol_GQStatus)0, {{NULL}, NULL}, (protocol_GQStatus)0, {{NULL}, NULL}} +#define protocol_GQSRawSample_ErrorsEntry_init_default {0, {{NULL}, NULL}} +#define protocol_GQSRawSample_init_zero {0, (protocol_GQStatus)0, 0, (protocol_GQStatus)0, 0, (protocol_GQStatus)0, 0, (protocol_GQStatus)0, {{NULL}, NULL}, (protocol_GQStatus)0, {{NULL}, NULL}, (protocol_GQStatus)0, {{NULL}, NULL}} +#define protocol_GQSRawSample_ErrorsEntry_init_zero {0, {{NULL}, NULL}} + +/* Field tags (for use in manual encoding/decoding) */ +#define protocol_GQSRawSample_Temperature1_tag 1 +#define protocol_GQSRawSample_Temperature1Err_tag 2 +#define protocol_GQSRawSample_Temperature2_tag 3 +#define protocol_GQSRawSample_Temperature2Err_tag 4 +#define protocol_GQSRawSample_Pressure1_tag 5 +#define protocol_GQSRawSample_Pressure1Err_tag 6 +#define protocol_GQSRawSample_Pressure2_tag 7 +#define protocol_GQSRawSample_Pressure2Err_tag 8 +#define protocol_GQSRawSample_MemsStatus_tag 9 +#define protocol_GQSRawSample_MemsStatusErr_tag 10 +#define protocol_GQSRawSample_MemsMeasurement_tag 11 +#define protocol_GQSRawSample_MemsMeasurementErr_tag 12 +#define protocol_GQSRawSample_errors_tag 15 +#define protocol_GQSRawSample_ErrorsEntry_key_tag 1 +#define protocol_GQSRawSample_ErrorsEntry_value_tag 2 + +/* Struct field encoding specification for nanopb */ +extern const pb_field_t protocol_GQSRawSample_fields[14]; +extern const pb_field_t protocol_GQSRawSample_ErrorsEntry_fields[3]; + +/* Maximum encoded size of messages (where known) */ +/* protocol_GQSRawSample_size depends on runtime parameters */ +/* protocol_GQSRawSample_ErrorsEntry_size depends on runtime parameters */ + +/* Message IDs (where set with "msgid" option) */ +#ifdef PB_MSGID + +#define GASQUALITY_MESSAGES \ + + +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif +/* @@protoc_insertion_point(eof) */ + +#endif