Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ra02a,ra02c modify #879

Merged
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vendor/netvox/payload/r315la.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function encodeDownlink(input) {
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);
ret = ret.concat(getCmdID, devid, (onDistanceThreshold >> 8), (onDistanceThreshold & 0xFF), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
}
else if ((input.data.Cmd == "ReadConfigReportReq")
|| (input.data.Cmd == "GetOnDistanceThresholdRreq"))
Expand Down
42 changes: 5 additions & 37 deletions vendor/netvox/payload/ra02a.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ function getCfgCmd(cfgcmd){
1: "ConfigReportReq",
129: "ConfigReportRsp",
2: "ReadConfigReportReq",
130: "ReadConfigReportRsp",
3: "SetAlarmThresholdReq",
131: "SetAlarmThresholdRsp",
4: "GetAlarmThresholdReq",
132: "GetAlarmThresholdRsp"
130: "ReadConfigReportRsp"
};
return cfgcmdlist[cfgcmd];
}
Expand All @@ -21,28 +17,18 @@ function getCmdToID(cmdtype){
return 2;
else if (cmdtype == "ReadConfigReportRsp")
return 130;
else if (cmdtype == "SetAlarmThresholdReq")
return 3;
else if (cmdtype == "SetAlarmThresholdRsp")
return 131;
else if (cmdtype == "GetAlarmThresholdReq")
return 4;
else if (cmdtype == "GetAlarmThresholdRsp")
return 132;
}

function getDeviceName(dev){
var deviceName = {
10: "RA02A",
17: "RA02C"
10: "RA02A"
};
return deviceName[dev];
}

function getDeviceID(devName){
var deviceName = {
"RA02A": 10,
"RA02C": 17
"RA02A": 10
};

return deviceName[devName];
Expand Down Expand Up @@ -94,17 +80,12 @@ function decodeUplink(input) {
else
data.Temp = (input.bytes[6]<<8 | input.bytes[7])/10;
}
else if (input.bytes[1] === 0x11)
{
data.COAlarm = (input.bytes[4] == 0x00) ? 'No Alarm' : 'Alarm';
data.HighTempAlarm = (input.bytes[5] == 0x00) ? 'No Alarm' : 'Alarm';
}
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("SetAlarmThresholdRsp")))
if (input.bytes[0] === getCmdToID("ConfigReportRsp"))
{
data.Status = (input.bytes[2] === 0x00) ? 'Success' : 'Failure';
}
Expand All @@ -114,10 +95,6 @@ function decodeUplink(input) {
data.MaxTime = (input.bytes[4]<<8 | input.bytes[5]);
data.BatteryChange = input.bytes[6]/10;
}
else if (input.bytes[0] === getCmdToID("GetAlarmThresholdRsp"))
{
data.AlarmThreshold = input.bytes[2];
}

break;

Expand Down Expand Up @@ -149,15 +126,10 @@ function encodeDownlink(input) {

ret = ret.concat(getCmdID, devid, (mint >> 8), (mint & 0xFF), (maxt >> 8), (maxt & 0xFF), batteryChg, 0x00, 0x00, 0x00, 0x00);
}
else if ((input.data.Cmd == "ReadConfigReportReq") || (input.data.Cmd == "GetAlarmThresholdReq"))
else if (input.data.Cmd == "ReadConfigReportReq")
{
ret = ret.concat(getCmdID, devid, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
}
else if (input.data.Cmd == "SetAlarmThresholdReq")
{
var threshold = input.data.AlarmThreshold;
ret = ret.concat(getCmdID, devid, threshold, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
}

return {
fPort: 7,
Expand All @@ -177,10 +149,6 @@ function decodeDownlink(input) {
data.MaxTime = (input.bytes[4]<<8 | input.bytes[5]);
data.BatteryChange = input.bytes[6]/10;
}
else if (input.bytes[0] === getCmdToID("SetAlarmThresholdReq"))
{
data.AlarmThreshold = input.bytes[2];
}

break;

Expand Down
181 changes: 181 additions & 0 deletions vendor/netvox/payload/ra02c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
function getCfgCmd(cfgcmd){
var cfgcmdlist = {
1: "ConfigReportReq",
129: "ConfigReportRsp",
2: "ReadConfigReportReq",
130: "ReadConfigReportRsp",
3: "SetAlarmThresholdReq",
131: "SetAlarmThresholdRsp",
4: "GetAlarmThresholdReq",
132: "GetAlarmThresholdRsp"
};
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 == "SetAlarmThresholdReq")
return 3;
else if (cmdtype == "SetAlarmThresholdRsp")
return 131;
else if (cmdtype == "GetAlarmThresholdReq")
return 4;
else if (cmdtype == "GetAlarmThresholdRsp")
return 132;
}

function getDeviceName(dev){
var deviceName = {
17: "RA02C"
};
return deviceName[dev];
}

function getDeviceID(devName){
var deviceName = {
"RA02C": 17
};

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;
if (input.bytes[1] === 0x11)
{
data.COAlarm = (input.bytes[4] == 0x00) ? 'No Alarm' : 'Alarm';
data.HighTempAlarm = (input.bytes[5] == 0x00) ? 'No Alarm' : 'Alarm';
}
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("SetAlarmThresholdRsp")))
{
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;
}
else if (input.bytes[0] === getCmdToID("GetAlarmThresholdRsp"))
{
data.AlarmThreshold = input.bytes[2];
}

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 batteryChg = input.data.BatteryChange * 10;

ret = ret.concat(getCmdID, devid, (mint >> 8), (mint & 0xFF), (maxt >> 8), (maxt & 0xFF), batteryChg, 0x00, 0x00, 0x00, 0x00);
}
else if ((input.data.Cmd == "ReadConfigReportReq") || (input.data.Cmd == "GetAlarmThresholdReq"))
{
ret = ret.concat(getCmdID, devid, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
}
else if (input.data.Cmd == "SetAlarmThresholdReq")
{
var threshold = input.data.AlarmThreshold;
ret = ret.concat(getCmdID, devid, threshold, 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;
}
else if (input.bytes[0] === getCmdToID("SetAlarmThresholdReq"))
{
data.AlarmThreshold = input.bytes[2];
}

break;

default:
return {
errors: ['invalid FPort'],
};
}

return {
data: data,
};
}
2 changes: 1 addition & 1 deletion vendor/netvox/r315la-codec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ downlinkEncoder:
OnDistanceThreshold: 221
output:
fPort: 7
bytes: [0x03, 0xDD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
bytes: [0x03, 0xDD, 0x00, 0xDD, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]

- description: Read configure report request
input:
Expand Down
6 changes: 3 additions & 3 deletions vendor/netvox/ra02c-codec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
uplinkDecoder:
fileName: payload/ra02a.js
fileName: payload/ra02c.js
examples:
- description: Startup version report
input:
Expand Down Expand Up @@ -66,7 +66,7 @@ uplinkDecoder:
AlarmThreshold: 100

downlinkDecoder:
fileName: payload/ra02a.js
fileName: payload/ra02c.js
examples:
- description: Configure report request
input:
Expand Down Expand Up @@ -109,7 +109,7 @@ downlinkDecoder:
Device: 'RA02C'

downlinkEncoder:
fileName: payload/ra02a.js
fileName: payload/ra02c.js
examples:
- description: Configure report request
input:
Expand Down