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.
Asked
Active
Viewed 362 times
3 Answers
0
google.protobuf.Timestamp
is just a "well known" message type. Its definition is available from timestamp.proto in Google's repository:
message Timestamp {
int64 seconds = 1;
int32 nanos = 2;
}
You can build timestamp.proto
using nanopb generator the same way you build other .proto
files.

jpa
- 10,351
- 1
- 28
- 45
0
You can use the timestamp.proto file from google protobuf package and compile it with nanopb directly to generate timestamp.pb.h and timestamp.pb.c file.

Cyril
- 151
- 4
0
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.

LappiesJA
- 3
- 4