Hi all, I think I am loosing my marbles…
I have HTTP integration so that the data from my TTN nodes goes to a webpage which will eventually write the data to a database, however I am having problem decoding the payload_raw field.
Using my TheThngsNode as an example, I can see I am getting a payload_raw of “DoYAHQqS”, however in this instance I have decoded it with the following function to give me :- “payload_fields”:{“battery”:3718,“event”:“interval”,“light”:29,“temperature”:27.06}. How does “DoYAHQqS” relate to the data given? When I come to using my node, the data format will be different, so I want to decode it using payload_raw.
function Decoder(bytes, port) {
var decoded = {};
var events = {
1: 'setup',
2: 'interval',
3: 'motion',
4: 'button'
};
decoded.event = events[port];
decoded.battery = (bytes[0] << 8) + bytes[1];
decoded.light = (bytes[2] << 8) + bytes[3];
decoded.temperature = ((bytes[4] << 8) + bytes[5]) / 100;
return decoded;
}
Thank you.