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/command.pb.c
- Revision:
- 1:78f2fa2c125e
- Parent:
- 0:fbdd0d307c19
--- a/source/protocol/command.pb.c Wed Jul 12 22:40:29 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* Automatically generated nanopb constant definitions */ -/* Generated by nanopb-0.3.8 at Wed Jul 12 11:04:33 2017. */ - -#include "command.pb.h" - -/* @@protoc_insertion_point(includes) */ -#if PB_PROTO_HEADER_VERSION != 30 -#error Regenerate this file with the current version of nanopb generator. -#endif - - - -const pb_field_t protocol_Command_fields[4] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, protocol_Command, issuedDT, issuedDT, &google_protobuf_Timestamp_fields), - PB_FIELD( 2, UINT32 , SINGULAR, STATIC , OTHER, protocol_Command, commandType, issuedDT, 0), - PB_FIELD( 10, BYTES , SINGULAR, CALLBACK, OTHER, protocol_Command, payload, commandType, 0), - PB_LAST_FIELD -}; - -const pb_field_t protocol_CommandBatch_fields[3] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, protocol_CommandBatch, sn, sn, 0), - PB_FIELD( 10, MESSAGE , REPEATED, CALLBACK, OTHER, protocol_CommandBatch, items, sn, &protocol_Command_fields), - PB_LAST_FIELD -}; - -const pb_field_t protocol_SecureCommandBatch_fields[3] = { - PB_FIELD( 1, BYTES , SINGULAR, CALLBACK, FIRST, protocol_SecureCommandBatch, signature, signature, 0), - PB_FIELD( 2, BYTES , SINGULAR, CALLBACK, OTHER, protocol_SecureCommandBatch, content, signature, 0), - PB_LAST_FIELD -}; - -const pb_field_t protocol_CommandResponse_fields[3] = { - PB_FIELD( 1, MESSAGE , SINGULAR, STATIC , FIRST, protocol_CommandResponse, issuedDT, issuedDT, &google_protobuf_Timestamp_fields), - PB_FIELD( 2, UENUM , SINGULAR, STATIC , OTHER, protocol_CommandResponse, status, issuedDT, 0), - PB_LAST_FIELD -}; - -const pb_field_t protocol_CommandResponseBatch_fields[3] = { - PB_FIELD( 1, STRING , SINGULAR, CALLBACK, FIRST, protocol_CommandResponseBatch, sn, sn, 0), - PB_FIELD( 2, MESSAGE , REPEATED, CALLBACK, OTHER, protocol_CommandResponseBatch, items, sn, &protocol_CommandResponse_fields), - PB_LAST_FIELD -}; - - - -/* Check that field information fits in pb_field_t */ -#if !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_32BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in 8 or 16 bit - * field descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(protocol_Command, issuedDT) < 65536 && pb_membersize(protocol_CommandResponse, issuedDT) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_protocol_Command_protocol_CommandBatch_protocol_SecureCommandBatch_protocol_CommandResponse_protocol_CommandResponseBatch) -#endif - -#if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT) -/* If you get an error here, it means that you need to define PB_FIELD_16BIT - * compile-time option. You can do that in pb.h or on compiler command line. - * - * The reason you need to do this is that some of your messages contain tag - * numbers or field sizes that are larger than what can fit in the default - * 8 bit descriptors. - */ -PB_STATIC_ASSERT((pb_membersize(protocol_Command, issuedDT) < 256 && pb_membersize(protocol_CommandResponse, issuedDT) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_protocol_Command_protocol_CommandBatch_protocol_SecureCommandBatch_protocol_CommandResponse_protocol_CommandResponseBatch) -#endif - - -/* @@protoc_insertion_point(eof) */