I've built some wireless temperature sensors which work fine on my current setup, but I'm looking to improve it. Without going into all the boring details, I have some data I need to manually decode.
This data contains a float, long and char*.
I've figured out the long and char and need to decode the float. Ideally in a bash script since that's how I'm currently working
Some examples of the payload data and the known actual values.
Payload : 0, 0, 108, 65, 60, 16, 0, 0, 97, 0
temp=14.75
bat=4156
adr=a
Payload : 0, 0, 63, 65, 30, 16, 0, 0, 111, 0
temp=11.94
bat=4126
adr=o
Payload : 0, 0, 157, 65, 98, 19, 0, 0, 98, 0
temp=19.62
bat=4962
adr=b
Payload : 0, 0, 144, 65, 208, 17, 0, 0, 108, 0
temp=18.00
bat=4560
adr=l
And my decoding so far of the first example
Payload : 0, 0, 108, 65, 60, 16, 0, 0, 97, 0
char = adr = a
Payload : 0, 0, 108, 65, 60, 16, 0, 0, 97, 0
long 8bit to 16bit
(16 x 256) + 60 = 4156
bat=4156
edit - made an error here
Payload : 0, 0, 108, 65, 60, 16, 0, 0, 97, 0
I need to decode this to the temp 14.75 float value.
Any ideas? |