diff --git a/vendor/netvox/index.yaml b/vendor/netvox/index.yaml index f0d70bbb67..8670464bb2 100755 --- a/vendor/netvox/index.yaml +++ b/vendor/netvox/index.yaml @@ -30,6 +30,7 @@ endDevices: - r31508 - r31509 - r31510 + - r315la - r602a - r603 - r711 diff --git a/vendor/netvox/payload/r315la.js b/vendor/netvox/payload/r315la.js new file mode 100755 index 0000000000..8443214f04 --- /dev/null +++ b/vendor/netvox/payload/r315la.js @@ -0,0 +1,184 @@ +function getCfgCmd(cfgcmd){ + var cfgcmdlist = { + 1: "ConfigReportReq", + 129: "ConfigReportRsp", + 2: "ReadConfigReportReq", + 130: "ReadConfigReportRsp", + 3: "SetOnDistanceThresholdRreq", + 131: "SetOnDistanceThresholdRrsq", + 4: "GetOnDistanceThresholdRreq", + 132: "GetOnDistanceThresholdRrsp", + }; + return cfgcmdlist[cfgcmd]; +} + +function getCmdToID(cmdtype){ + if (cmdtype == "ConfigReportReq") + return 1; + else if (cmdtype == "ConfigReportRsp") + return 129; + else if (cmdtype == "ReadConfigReportReq") + return 2; + else if (cmdtype == "ReadConfigReportRsp") + return 130; + else if (cmdtype == "SetOnDistanceThresholdRreq") + return 3; + else if (cmdtype == "SetOnDistanceThresholdRrsq") + return 131; + else if (cmdtype == "GetOnDistanceThresholdRreq") + return 4; + else if (cmdtype == "GetOnDistanceThresholdRrsp") + return 132; +} + +function getDeviceName(dev){ + var deviceName = { + 221: "R315LA" + }; + return deviceName[dev]; +} + +function getDeviceID(devName){ + var deviceName = { + "R315LA": 221 + }; + return deviceName[devName]; +} + +function padLeft(str, len) { + str = '' + str; + if (str.length >= len) { + return str; + } else { + return padLeft("0" + str, len); + } +} + +function decodeUplink(input) { + var data = {}; + switch (input.fPort) { + case 6: + if (input.bytes[2] === 0x00) + { + data.Device = getDeviceName(input.bytes[1]); + data.SWver = input.bytes[3]/10; + data.HWver = input.bytes[4]; + data.Datecode = padLeft(input.bytes[5].toString(16), 2) + padLeft(input.bytes[6].toString(16), 2) + padLeft(input.bytes[7].toString(16), 2) + padLeft(input.bytes[8].toString(16), 2); + + return { + data: data, + }; + } + + data.Device = getDeviceName(input.bytes[1]); + if (input.bytes[3] & 0x80) + { + var tmp_v = input.bytes[3] & 0x7F; + data.Volt = (tmp_v / 10).toString() + '(low battery)'; + } + else + data.Volt = input.bytes[3]/10; + + data.VModbusID = input.bytes[4]; + data.Status = (input.bytes[5] == 0x00) ? 'Off' : 'On'; + data.Distance = (input.bytes[6]<<8 | input.bytes[7])+"mm"; + data.LowDistanceAlarm = input.bytes[8] & 1; + data.HightDistanceAlarm = input.bytes[8]>>1 & 1; + break; + + case 7: + data.Cmd = getCfgCmd(input.bytes[0]); + data.Device = getDeviceName(input.bytes[1]); + + if ((input.bytes[0] === getCmdToID("ConfigReportRsp")) + || (input.bytes[0] === getCmdToID("SetOnDistanceThresholdRrsq"))) + { + data.Status = (input.bytes[2] === 0x00) ? 'Success' : 'Failure'; + } + else if (input.bytes[0] === getCmdToID("ReadConfigReportRsp")) + { + data.MinTime = (input.bytes[2]<<8 | input.bytes[3]); + data.MaxTime = (input.bytes[4]<<8 | input.bytes[5]); + data.BatteryChange = input.bytes[6]/10; + data.DistanceChange = (input.bytes[7]<<8 | input.bytes[8])+"mm" + } + else if (input.bytes[0] === getCmdToID("GetOnDistanceThresholdRrsp")) + { + data.OnDistanceThreshold = (input.bytes[2]<<8 | input.bytes[3])+"mm"; + } + + break; + + default: + return { + errors: ['unknown FPort'], + }; + + } + + return { + data: data, + }; + } + +function encodeDownlink(input) { + var ret = []; + var devid; + var getCmdID; + + getCmdID = getCmdToID(input.data.Cmd); + devid = getDeviceID(input.data.Device); + + if (input.data.Cmd == "ConfigReportReq") + { + var mint = input.data.MinTime; + var maxt = input.data.MaxTime; + var battery = input.data.BatteryChange*10; + var distance = input.data.DistanceChange; + ret = ret.concat(getCmdID, devid, (mint >> 8), (mint & 0xFF), (maxt >> 8), (maxt & 0xFF), battery, (distance >> 8), (distance & 0xFF), 0x00, 0x00); + } + else if (input.data.Cmd == "SetOnDistanceThresholdRreq") + { + var onDistanceThreshold = input.data.OnDistanceThreshold; + ret = ret.concat(getCmdID, onDistanceThreshold, (onDistanceThreshold >> 8), (mint & 0xFF), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); + } + else if ((input.data.Cmd == "ReadConfigReportReq") + || (input.data.Cmd == "GetOnDistanceThresholdRreq")) + { + ret = ret.concat(getCmdID, devid, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); + } + return { + fPort: 7, + bytes: ret + }; +} + +function decodeDownlink(input) { + var data = {}; + switch (input.fPort) { + case 7: + data.Cmd = getCfgCmd(input.bytes[0]); + data.Device = getDeviceName(input.bytes[1]); + if (input.bytes[0] === getCmdToID("ConfigReportReq")) + { + data.MinTime = (input.bytes[2]<<8 | input.bytes[3]); + data.MaxTime = (input.bytes[4]<<8 | input.bytes[5]); + data.BatteryChange = input.bytes[6]/10; + data.DistanceChange = (input.bytes[7]<<8 | input.bytes[8])+"mm" + } + else if (input.bytes[0] === getCmdToID("SetOnDistanceThresholdRreq")) + { + data.OnDistanceThreshold = (input.bytes[2]<<8 | input.bytes[3])+"mm"; + } + break; + + default: + return { + errors: ['invalid FPort'], + }; + } + + return { + data: data, + }; +} diff --git a/vendor/netvox/payload/r603.js b/vendor/netvox/payload/r603.js index 7ac09f16f8..fbc7d41597 100755 --- a/vendor/netvox/payload/r603.js +++ b/vendor/netvox/payload/r603.js @@ -160,7 +160,7 @@ function decodeUplink(input) { data.Volt = input.bytes[3]/10; data.WarningStatus = (input.bytes[4] == 0x00) ? 'NoWarnring' : 'Warning'; - data.ContactSwitchStatus = (input.bytes[5] == 0x00) ? 'Off' : 'On'; + data.DCPowerFailureAlarm = (input.bytes[6] == 0x00) ? 'NoWarnring' : 'Warning'; break; case 7: diff --git a/vendor/netvox/photos/r315la.jpg b/vendor/netvox/photos/r315la.jpg new file mode 100644 index 0000000000..29b4be6635 Binary files /dev/null and b/vendor/netvox/photos/r315la.jpg differ diff --git a/vendor/netvox/r315la-codec.yaml b/vendor/netvox/r315la-codec.yaml new file mode 100755 index 0000000000..b3ddc150ce --- /dev/null +++ b/vendor/netvox/r315la-codec.yaml @@ -0,0 +1,140 @@ +uplinkDecoder: + fileName: payload/r315la.js + examples: + - description: Startup version report + input: + fPort: 6 + bytes: [0x01, 0xDD, 0x00, 0x64, 0x15, 0x20, 0x20, 0x08, 0x11, 0x00, 0x00] + output: + data: + Device: 'R315LA' + SWver: 10 + HWver: 21 + Datecode: '20200811' + + - description: Status report + input: + fPort: 6 + bytes: [0x01, 0xDD, 0x01, 0x30, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00] + output: + data: + Device: 'R315LA' + Volt: 4.8 + VModbusID: 0 + Status: 'On' + Distance: '257mm' + LowDistanceAlarm: 0 + HightDistanceAlarm: 0 + + - description: Configure report response + input: + fPort: 7 + bytes: [0x81, 0xDD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] + output: + data: + Cmd: 'ConfigReportRsp' + Device: 'R315LA' + Status: 'Success' + + - description: Read configure report response + input: + fPort: 7 + bytes: [0x82, 0xDD, 0x03, 0x84, 0x07, 0x08, 0x01, 0x01, 0x00, 0x00, 0x00] + output: + data: + Cmd: 'ReadConfigReportRsp' + Device: 'R315LA' + MinTime: 900 + MaxTime: 1800 + BatteryChange: 0.1 + DistanceChange: '256mm' + + - description: Read configure report response + input: + fPort: 7 + bytes: [0x83, 0xDD, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] + output: + data: + Cmd: 'SetOnDistanceThresholdRrsq' + Device: 'R315LA' + Status: 'Failure' + + - description: Read configure report response + input: + fPort: 7 + bytes: [0x84, 0xDD, 0x01, 0x84, 0x07, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00] + output: + data: + Cmd: 'GetOnDistanceThresholdRrsp' + Device: 'R315LA' + OnDistanceThreshold: '388mm' + +downlinkDecoder: + fileName: payload/r315la.js + examples: + - description: Configure report request + input: + fPort: 7 + bytes: [0x01, 0xDD, 0x03, 0x84, 0x07, 0x08, 0x01, 0x00, 0x11, 0x00, 0x00] + output: + data: + Cmd: 'ConfigReportReq' + Device: 'R315LA' + MinTime: 900 + MaxTime: 1800 + BatteryChange: 0.1 + DistanceChange: '17mm' + + - description: Read configure report request + input: + fPort: 7 + bytes: [0x03, 0xDD, 0x00, 0x84, 0x02, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00] + output: + data: + Cmd: 'SetOnDistanceThresholdRreq' + Device: 'R315LA' + OnDistanceThreshold: '132mm' + +downlinkEncoder: + fileName: payload/r315la.js + examples: + - description: Configure report request + input: + data: + Cmd: 'ConfigReportReq' + Device: 'R315LA' + MinTime: 900 + MaxTime: 1800 + BatteryChange: 10 + DistanceChange: 22 + output: + fPort: 7 + bytes: [0x01, 0xDD, 0x03, 0x84, 0x07, 0x08, 0x64, 0x00, 0x16, 0x00, 0x00] + + - description: Read configure report request + input: + data: + Cmd: 'ReadConfigReportReq' + Device: 'R315LA' + output: + fPort: 7 + bytes: [0x02, 0xDD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] + + - description: Read configure report request + input: + data: + Cmd: 'SetOnDistanceThresholdRreq' + Device: 'R315LA' + OnDistanceThreshold: 221 + output: + fPort: 7 + bytes: [0x03, 0xDD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] + + - description: Read configure report request + input: + data: + Cmd: 'GetOnDistanceThresholdRreq' + Device: 'R315LA' + output: + fPort: 7 + bytes: [0x04, 0xDD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00] diff --git a/vendor/netvox/r315la.yaml b/vendor/netvox/r315la.yaml new file mode 100755 index 0000000000..7bb05d1dd3 --- /dev/null +++ b/vendor/netvox/r315la.yaml @@ -0,0 +1,63 @@ +name: R315LA - Wireless toilet paper detection sensor +description: R315LA is a Wireless toilet paper detection sensor. + +hardwareVersions: + - version: '21' + numeric: 21 + +firmwareVersions: + - version: '10' + numeric: 10 + hardwareVersions: + - '21' + + profiles: + EU863-870: + id: profile-eu868 + codec: r315la-codec + AS923: + id: profile-as923 + codec: r315la-codec + US902-928: + id: profile-us915 + codec: r315la-codec + AU915-928: + id: profile-au915 + codec: r315la-codec + KR920-923: + id: profile-kr920 + codec: r315la-codec + IN865-867: + id: profile-in865 + codec: r315la-codec + CN470-510: + id: profile-cn470 + codec: r315la-codec + +dimensions: + diameter: 106 + height: 40.6 + +battery: + replaceable: true + type: 2 x1.5V AAA alkaline batteries + +operatingConditions: + temperature: + min: -20 + max: 55 + relativeHumidity: + min: 0 + max: 0.9 + +keyProvisioning: + - custom + - join server + +keySecurity: none + +productURL: http://www.netvox.com.tw/product.asp?pro=r315la +dataSheetURL: http://www.netvox.com.tw/um/r315la/r315laGdatasheet.pdf + +photos: + main: photos/r315la.jpg diff --git a/vendor/netvox/r603-codec.yaml b/vendor/netvox/r603-codec.yaml index cd4784253f..427d7593fd 100755 --- a/vendor/netvox/r603-codec.yaml +++ b/vendor/netvox/r603-codec.yaml @@ -21,7 +21,7 @@ uplinkDecoder: Device: 'R603' Volt: 4.8 WarningStatus: 'NoWarnring' - ContactSwitchStatus: 'On' + DCPowerFailureAlarm: 'Warning' - description: Configure report response input: