Is there support for google.protobuf.Timestamp datatype and encode decode function in nanopb ? Or we should encode/decode as int64 or may be uint32 (if possible till year 2106) ? The target device is a 32bit MCU and server end is a java based implementation.
Timestamp in nanopb
513 views Asked by Dhiman At
3
There are 3 answers
0
On
I know this is a comment on a old post, but I had a similar question on the ESP32 and came across this so I thought I would chime in.
As stated by JPA, if you build the nanopb files it is fairly easy to use.
How I used it:
google_protobuf_Timestamp timestamp;
timestamp.seconds = esp_log_timestamp()/1000;
I was only interested in second intervals and not miliseconds so that is why I divided by 1000.
I works well and it is still encoded.
google.protobuf.Timestamp
is just a "well known" message type. Its definition is available from timestamp.proto in Google's repository:You can build
timestamp.proto
using nanopb generator the same way you build other.proto
files.