//THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY!
//USE AT YOUR OWN RISK!
//uplink payload formatter (decoder)
//author: daa792
function decodeUplink(input) {
var bytes = input.bytes;
var decoded;
var tem;
var hum;
var bat;
if (bytes[0] == 0x01 && bytes[1] == 0x41 && bytes[2] == 0x10 && bytes[3] == 0x01) {
tem = (((bytes[8] * 256 + bytes[9]) >> 4) - 500) / 10;
hum = ((bytes[9] * 256 + bytes[10]) & 0xFFF) / 10;
bat = bytes[13];
decoded = {temperature: tem, humidity: hum, battery: bat};
} else {
decoded = {};
}
return {
data: decoded,
warnings: [],
errors: []
};
}