TheThingsNetwork / arduino-device-lib

Arduino Library for TTN Devices
MIT License
208 stars 96 forks source link

Design generic Measurement protobuf #79

Closed johanstokking closed 7 years ago

johanstokking commented 7 years ago

E.g.:

message Measurement {
   optional float temperature = 100;
   optional float humidity = 101;

   repeated uint32 analog_readings = 110;
}
FokkeZB commented 7 years ago

I couldn't sleep tonight and had an idea for a Message class that could contain any number of values, encoded in minimal bytes based on max range and min precision.

https://github.com/TheThingsNetwork/arduino-device-lib/wiki/Proposal:-Message-Class

johanstokking commented 7 years ago

@FokkeZB this is what protobufs will be for 👍

This allows for a generic, reusable Message that contains many optional fields and arrays for custom data. The device sets the fields it needs and the protobuf marshaler only puts the used values in the buffer with a tiny header. It also supports variable length integers.

I have a demo ready shortly.

johanstokking commented 7 years ago

@FokkeZB see some example code in #81. The file https://github.com/johanstokking/ttn-protobuf-demo/blob/master/api/measurement.proto contains required fields, but they will be optional and a long list of things we can send. We can also send variable length arrays of analog readings, but putting values in the right fields helps upstream.

FokkeZB commented 7 years ago

wow, I did quite some C coding lately, but that puzzles me 😛

FokkeZB commented 7 years ago

Done by #108