function decodeUplink(input) { return{ data: Decode(input.fPort, input.bytes, input.variables) }; } function toHexString(byteArray) { return Array.from(byteArray, function(byte) { return ('0' + (byte & 0xFF).toString(16)).slice(-2); }).join('') } function Decode(fPort, bytes, variables) { //Payload Formats of RS485-BL Deceive return { //Battery,units:V BatV: ((bytes[0]<<8 | bytes[1])&0x7fff)/1000, //payload of version Pay_ver: bytes[2], //temp1: temperature1: (((bytes[3]<<8 | bytes[04])&0x7fff)/100)-100, soilmoisture1: (((bytes[5]<<8 | bytes[06])&0x7fff)/100), permittivity1: ((bytes[7]<<8 | bytes[08])&0x7fff), temperature2: (((bytes[9]<<8 | bytes[10])&0x7fff)/100)-100, soilmoisture2: (((bytes[11]<<8 | bytes[12])&0x7fff)/100), permittivity2: ((bytes[13]<<8 | bytes[14])&0x7fff), Data: toHexString(bytes), }; }