Decoding payload to text output for user

I’m looking to decode a payload into text for 4 different ‘values.’
For example, a payload of 01 94 04 85 should give me
“Insight 1 corresponding to what I’ve assigned 01 to mean”
“94% confidence of the first insight”
“Insight 2 corresponding to what I’ve assigned 04 to mean”
“85% confidence of the second insight”

What would the code look like for this example (in TTN payload decoder)? I’m guessing that I’m dealing with a float payload. I’m currently following this website as a starting tutorial.

Many thanks

Then why did you post this in the gateways topic? Gateways have no understanding of message data, when it passes through them is still encrypted with a key they do not have. Gateways don’t even really know if the packet they are reporting in is even LoRaWAN.

Highly unlikely. Your dump of bytes would be hex (as a printable direct-mappable shorthand for the actual binary values) but you are trying to interpret the numbers as if they were decimal, which does not cleanly map to and from binary in a consistent number of digits.

I’m guessing that I’m dealing with a float payload.

To make any progress, you need to be operating from facts, not guesses.

Until you can take a hex dump of the packet, circle bytes and say “these n bytes are the foo encoded representation of the blah” there’s no point in trying to write any code.

Your first step here is to gain a better understanding of exactly what your node is sending.

1 Like

Good point; looking through past questions on the forum related to decoding payloads were also tagged under gateway. My misunderstanding.

I understand now; for my issue, one script is creating the output I mentioned, 4 bytes with 4 different pieces of information. My question is really centered around finding out how to encode that information, find what that encoded hex dump looks like, and decode from there. Thanks for clearing that up.

Working on it now, I’ll reply if/when I’ve made further progress and hit bigger issues down the road. Cheers

The hex dump is not particularly useful if you know how you encoded your values.
Anyway, in this case, you have to know the range of values and precision. If insights 1 and 2 are integers and <255, their coding can be just as bytes. If you can live with confidences without decimals, again the coding is straightforward as a byte. Issues (easily solvable) start if you have wider ranges, negatives, decimals.

1 Like