function Decode(fPort, bytes) {
switch (fPort) {
case 1:
case 1: {
var output = {};
var decoded = {};
var outputdecoded.DEV_EUI = {LoRaObject.devEUI;
decoded.RSSI = LoRaObject.rxInfo[0].rssi;
Current_Valve_Position: bytesdecoded.SNR = LoRaObject.rxInfo[0],.loRaSNR;
decoded.Data = LoRaObject.data;
decoded.ADR = LoRaObject.txInfo.adr;
Flow_Sensor_Raw: bytes[1] * 0.5, decoded.coderate = LoRaObject.txInfo.codeRate;
decoded.FCnt = LoRaObject.fCnt;
Flow_Temperature: bytes[2] * 0.5, decoded.Port = LoRaObject.fPort;
decoded.Frequency = LoRaObject.txInfo.frequency;
Ambient_Sensor_Raw: bytes[3] * 0decoded.25,Modulation = LoRaObject.txInfo.dataRate.modulation;
decoded.Bandwidth = LoRaObject.txInfo.dataRate.bandwidth;
Ambient_Temperature: bytes[4] * 0.25, decoded.SpreadingFactor = LoRaObject.txInfo.dataRate.spreadFactor;
output.Current_Valve_Position = bytes[0];
Energy_Storage:output.Flow_Sensor_Raw = bytes[51] >> 6 & 0x01,* 0.5;
output.Flow_Temperature = bytes[2] * 0.5;
Harvesting_Active:output.Ambient_Sensor_Raw = bytes[53] >> 5 & 0x01,* 0.25;
output.Ambient_Temperature = bytes[4] * 0.25;
Ambient_Sensor_Failure:output.Energy_Storage = bytes[5] >> 46 & 0x01,;
output.Harvesting_Active = bytes[5] >> 5 & 0x01;
Flowoutput.Ambient_Sensor_Failure: = bytes[5] >> 34 & 0x01,;
output.Flow_Sensor_Failure = bytes[5] >> 3 & 0x01;
output.Radio_Communication_Error: = bytes[5] >> 2 & 0x01,;
output.Received_Signal_Strength: = bytes[5] >> 1 & 0x01,;
output.Motor_Error: = bytes[5] >> 0 & 0x01,;
output.Storage_Voltage: = Number((bytes[6] * 0.02).toFixed(2)),;
output.Average_Current_Consumed: = bytes[7] * 10,;
output.Average_Current_Generated: = bytes[8] * 10,;
output.Reference_Completed: = bytes[9] >> 4 & 0x01,;
output.Operating_Mode: = bytes[9] >> 7 & 0x01,;
output.Storage_Fully_Charged: = bytes[9] >> 6 & 0x01,
};
if (bytes.length === 11) {
var um = bytes[9] & 0x03;
var uv if = (um === 0) {
var uv = ? bytes[10] }
else {
var uv = : bytes[10] * 0.5
;
}
output.User_Mode = um
;
output.User_Value = uv
;
}
return {status: return output;
decoded, uplink_decoded: output};
}
default:
return {
errors: ['unknown FPort'],
};
}
}
} |