/*============================================================================================================================= Author: lefake Date: April 2020 Description: Header file of the nanopb communication protocol Encode and decode protobuf messages with an id on the serial port The messages are of the form : (can have from one to MAX_NBS_MSG messages) ==============================================================================================================================*/ #ifndef PBUTILS_H #define PBUTILS_H #include #include #include #include #include #define MAX_MSG_LEN 1000 #define MAX_NBS_MSG 10 struct Topic { int id; pb_msgdesc_t* type; void* msg; }; class PBUtils { public: PBUtils(Topic*, int); ~PBUtils(); bool decode_pb(char* , int *, int &); bool pb_send(int, ...); private: int parse_msg(char[], int *, char **); void chars2bytes(char* , uint8_t*); uint8_t char2hex(char, char); pb_msgdesc_t** _id_2_type; void** _id_2_msg; }; #endif