Skip to content

Commit

Permalink
Modify r603,add r315la (#846)
Browse files Browse the repository at this point in the history
* r718pa,r718pa4,r718pb,rp02 insert,r718n

* add r718pa,r718pa4,r718pb,rp02,r718n3 support

* add r718pa,r718pa4,r718pb,rp02,r718n3 support

* add photos

* R312A、R312FunctionKeyTrigger

* photo submission

* photo submission

* Report type 0x11,0x12 support

* RA02G  R603

* ra02g,r603,r718pa,r718pb update

* modify r603,add r315la

---------

Co-authored-by: Jaime Trinidad <[email protected]>
  • Loading branch information
netvox-tech and Jaime-Trinidad authored Nov 20, 2024
1 parent 05a9e85 commit 3c69b2e
Show file tree
Hide file tree
Showing 7 changed files with 390 additions and 2 deletions.
1 change: 1 addition & 0 deletions vendor/netvox/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ endDevices:
- r31508
- r31509
- r31510
- r315la
- r602a
- r603
- r711
Expand Down
184 changes: 184 additions & 0 deletions vendor/netvox/payload/r315la.js
Original file line number Diff line number Diff line change
@@ -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,
};
}
2 changes: 1 addition & 1 deletion vendor/netvox/payload/r603.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Binary file added vendor/netvox/photos/r315la.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
140 changes: 140 additions & 0 deletions vendor/netvox/r315la-codec.yaml
Original file line number Diff line number Diff line change
@@ -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]
Loading

0 comments on commit 3c69b2e

Please sign in to comment.