Zenner Wasserzähler Minomess
Zenner Water Meter Minomess
Last updated
Zenner Water Meter Minomess
Last updated
waterMeter1
telemetry
waterMeter2
telemetry
waterMeter3
telemetry
{
"cmd": "gw",
"seqno": 102729,
"EUI": "04B6480455088493",
"ts": 1662593561213,
"fcnt": 1417,
"port": 1,
"freq": 868300000,
"toa": 1318,
"dr": "SF12 BW125 4/5",
"ack": false,
"gws": [{
"rssi": -65,
"snr": 9.5,
"ts": 1662593561288,
"time": "2022-09-06T23:13:27.326933Z",
"gweui": "000800FFFF4A3F5E",
"ant": 0,
"lat": 47.4965808,
"lon": 8.718909100000019
}, {
"rssi": -112,
"snr": 0.5,
"ts": 1662593561213,
"time": "2022-09-07T23:32:41.238866Z",
"gweui": "9C65F9FFFF4334E5",
"ant": 0,
"lat": 46.8076885,
"lon": 7.100528
}],
"bat": 113,
"data": "11d5420100",
"_id": "63192a195798ca044bde5c17"
}
{
"msg": {
"waterMeter": 82.645,
"ts": 1661262701281,
"rssi": -80,
"snr": 9.8,
"toa": 61,
"frequency": 867700000,
"dr": "SF7 BW125 4/5",
"bat": "External power source",
"hex": "11d5420100"
},
"metadata": {
"deviceType": "default",
"deviceName": "Test Device",
"ts": "1662624173561"
},
"msgType": "POST_TELEMETRY_REQUEST"
}
All Downlinks shall be sent on Port 3
//V2.0, 23.12.2021,DS
if (msg.data) {
var decoded = decodeFromHex(msg.data);
for (var i = 0; i < decoded.length; i++) {
decoded[i]['values']['rssi'] = msg.rssi;
decoded[i]['values']['snr'] = msg.snr;
decoded[i]['values']['toa'] = msg.toa;
decoded[i]['values']['frequency'] = msg.frequency;
decoded[i]['values']['dr'] = msg.dr;
decoded[i]['values']['bat'] = decodeBattery(msg.bat);
decoded[i]['values']['hex'] = msg.data;
}
return {
msg: decoded,
metadata: metadata,
msgType: msgType
};
} else {
return {
msg: msg,
metadata: metadata,
msgType: msgType
};
}
function HexToFloat32(str) {
var int = parseInt(str, 16);
if (int > 0 || int < 0) {
var sign = (int >>> 31) ? -1 : 1;
var exp = (int >>> 23 & 0xff) - 127;
var mantissa = ((int & 0x7fffff) + 0x800000)
.toString(2);
var float32 = 0;
for (i = 0; i < mantissa.length; i += 1) {
float32 += parseInt(mantissa[i]) ? Math.pow(
2, exp) : 0;
exp--;
}
return float32 * sign;
} else return 0;
}
function decodeFromHex(data) {
var telemetry = [];
if (data.substr(0, 2) == "11") {
var dataString = data.substr(8, 2) + data.substr(6,
2) + data.substr(4, 2) + data.substr(2, 2);
waterMeter = parseInt(dataString, 16) / 1000;
telemetry[0] = {
"ts": msg.ts,
"values": {
"waterMeter": waterMeter
}
};
} else if (data.substr(0, 1) == "c") {
var dataString1 = data.substr(12, 2) + data.substr(
10, 2) + data.substr(8, 2) + data.substr(6,
2);
var dataString2 = data.substr(20, 2) + data.substr(
18, 2) + data.substr(16, 2) + data.substr(
14, 2);
var dataString3 = data.substr(28, 2) + data.substr(
26, 2) + data.substr(24, 2) + data.substr(
22, 2);
var waterMeter1 = parseInt(dataString1, 16) /
1000;
var waterMeter2 = parseInt(dataString2, 16) /
1000;
var waterMeter3 = parseInt(dataString3, 16) /
1000;
telemetry[0] = {
"ts": msg.ts - 7200000,
"values": {
"waterMeter": waterMeter1
}
};
telemetry[1] = {
"ts": msg.ts - 3600000,
"values": {
"waterMeter": waterMeter2
}
};
telemetry[2] = {
"ts": msg.ts,
"values": {
"waterMeter": waterMeter3
}
};
}
return telemetry;
}
function decodeBattery(byte) {
if (byte == 0) {
return 'External power source';
} else if (byte > 0 && byte < 255) {
return byte / 254 * 100;
} else {
return 'Unknown battery state';
}
}