thesolarnomad / lora-serialization

LoraWAN serialization/deserialization library for The Things Network
MIT License
165 stars 27 forks source link

Integration of opcodes #22

Open aparcar opened 5 years ago

aparcar commented 5 years ago

Hi, great library, thanks for creating!

I'm working on a setup where used sensors may change over time, meaning a static decoding on the backend won't work. Searching for a solution I found things4u's message format - which isn't implemented anywhere.

The idea is to have 6 Bit prefixes announcing the type followed by a 2 Bit length field. The decode would read the first bite and may automatically add "temperature" or whatever as a dict key.

This would increase the message size by a single Byte per transported value but allows dynamic decoding.

A possible implementation could give the LoraMessage a parameter setting the use of opcodes, or not.

joscha commented 5 years ago

You may want to have a look at https://github.com/thesolarnomad/ttn-proto-utils and especially the proto format, which will be really low-cost byte-wise but brings all the flexibility you need.

aparcar commented 5 years ago

I created a POV here https://github.com/thesolarnomad/lora-serialization/pull/23

aparcar commented 5 years ago

I guess proto is great, but somewhat more complicated for the cases I'm working on...