Go Down

Topic: Nanopb String from encoded message (Read 244 times) previous topic - next topic

oyarzopablo

How do I get the whole message in a string? I'm planning on sending it over HTTP.
I thought of using the "pb_read" but it's giving me trouble with the buffers.

Robin2

Without seeing your program it is impossible to make sense of your question.

What is a Nanopb?

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

oyarzopablo

Nanopb is a C implementation of the Protocol Buffers library from google.
I'm compiling this example from the library.
https://github.com/nanopb/nanopb/blob/master/examples/simple/simple.c
As you can see it has the code for coding and decoding the function, but say I print the whole function over serial.

This guy has pretty much my problem, but I didn't understand how he did it.
https://stackoverflow.com/questions/31272735/nanopb-get-string-from-pb-ostream-t

Robin2

What is "Protocol Buffers" ?

If you really want to get help you need to provide as much information as you can.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

oyarzopablo

From their website: "Protocol buffers are a language-neutral, platform-neutral extensible mechanism for serializing structured data." Protocol Buffers.

If you open the second link on my last reply, it sums up the problem I'm having.

dannable

I realise that I'm not the most observant of people, but I am struggling to see the connection with Arduino?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Robin2

From their website: "Protocol buffers are a language-neutral, platform-neutral extensible mechanism for serializing structured data." Protocol Buffers.
I don't understand that and I have a sneaking suspicion that you don't either.

How about a simple explanation that your Granny would understand?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up