// Decode decodes an array of bytes into an object. // - fPort contains the LoRaWAN fPort number // - bytes is an array of bytes, e.g. [225, 230, 255, 0] // - variables contains the device variables e.g. {"calibration": "3.5"} (both the key / value are of type string) // The function must return an object, e.g. {"temperature": 22.5} function Decode(fPort, bytes, variables) { var BatV = (bytes[0] << 8 | bytes[1]) / 1000 + 0.277; var PayVER = bytes[2]; // If AT+DATAUP=1, PayloadCount=1 byte, payload#=1 byte var Temp = (bytes[3] << 8 | bytes[4]) / 10; var Humid = (bytes[5] << 8 | bytes[6]) / 10; return {"BatV":BatV, "PayVER":PayVER, "Temp":Temp, "Humid":Humid}; }