`Hi, this is my first post here in this forum, so im excited if will help me continue my quest.
Im working on decoding protobuf streams, and have come to a snag.
im using nanopb, because i need a small footprint, as im trying to get this to work in a microprocessor.
I have tried simple .proto files and everything is ok, i can decode fine, however when i go to more advanced .proto definitions, that contains other custom .proto structures with strings with variable field lengths in it, i cant get my head around how to use the protobuf to decode this. i have tried with decode functions, and with pb_decode_ex, and i cant get it to work.
I havent been able to find any realy good reading source for how this should be accomplished, so maybe someone knows my problem, and knows how its done…
Like this:
message Data {
fixed32 age = 1;
bytes payload = 2;
fixed32 distance = 3;
}
Where payload is:
message UserData {
uint32 num = 1;
User user = 2;
Position position = 3;
}
where user is
message User {
string id = 1;
string full_name = 2;
string short_name = 3;
string home = 4;
string speed = 5;
}
I would need to be able to read the full_name
That is first problem im trying to solve, the other is the use of the decode functions:
out_message.data.funcs.decode = &print_string;
out_message.data.arg = &outbuf;
When i call the function, how to i get the data back in the scope i called it from. there are several examples on how to print out from the function, and providing arguments into the function, but how do i get data out of the function, not just printing it.
any help much appriciated.
/Kim
I have tried to find information to read up on this, but for nanopb there anre not that much information available on google. I was expecting to be able to read all the data from the 3 level nested .proto definitions.
kimfm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.