This post really helped me. Belated 2017 thanks… sharing back my resultant TTNv3 payload decoder for box/evb lora-demo: hope it is of use to someone…
function decodeUplink(input) {
var data = {};
var acc_x = input.bytes[1];
var acc_y = input.bytes[2];
var acc_z = input.bytes[3];
var press = (input.bytes[5]<<16) | (input.bytes[6]<<8) | input.bytes[7];
var lux = (input.bytes[9]<<8) | input.bytes[10];
var temp = (input.bytes[12]<<8) | input.bytes[13];
data.acc_x = acc_x * .0625;
data.acc_y = acc_y * .0625;
data.acc_z = acc_z * .0625;
data.press = +((press * 0.25 / 1000).toFixed(2));
data.lux = lux;
data.temp = +((temp * 0.0625).toFixed(1));
return {
data: data
};
}