You mean something like this:
function Decoder(bytes, port) {
// Decode an uplink message from a buffer
// (array) of bytes to an object of fields.
var decoded = {};
// if (port === 1) decoded.led = bytes[0];
decoded.Temperature = (bytes[1] << 8) + bytes[0];
decoded.Temperature=decoded.Temperature/100.0
decoded.Pressure = (bytes[3] << 8) + bytes[2];
decoded.Humidity = (bytes[5] << 8) + bytes[4];
decoded.Humidity=decoded.Humidity/100.0
return decoded;
}
This converts bytes “01 02 03 04 05 06” to 2 bytes = Temperature, next 2 bytes to Pressure and the final 2 bytes to Humidity.
Naming the return variables like decode.xxx wil return a json object that has this xxx=value.