Decode Python struct on TTN using Javascript



  • Hey everyone,
    I'm having some trouble in my attempt to send multiple pieces of data over LoRa. I'm currently just messing around with the python struct module and sending random float values.

    I'm using the struct.pack('>f', <value>), but since I'm needing to send multiple values I'm unsure if my method of simply adding the byte strings together (using the above function twice and adding the string together) will get me what I need. Anyways my problem mostly comes out on the decoder side. If I send two floats, that comes out to a total of 8 bytes. How exactly can I pull out the individual values on the Javascript end using the TTN decoder. I've looked around for a while and have seen some answers as far as decoding goes. I mostly looked at this thread here for lat and long, but most people encode the data before sending it and modify it back on the other end.

    So my basic question is, if I send data packed using struct.pack() (assume big endian format), how can I pull those values out in Javascript?



  • Found my answer after hours of looking around.

    Found this beautiful post on TTN regarding decoding the values of different types and what have you found here by
    Arjanvanb on TTN

    The main answer was posted on Stackoverflow by Ilya Bursov.



Pycom on Twitter