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

add prs,aqm to aquascope #858

Merged
merged 2 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
68 changes: 68 additions & 0 deletions vendor/aquascope/aqm-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
uplinkDecoder:
fileName: aqm.js
examples:
- description: Valve On
input:
fPort: 1
bytes: [07, 0xff]
output:
data:
valve: 255
- description: Valve Off
input:
fPort: 1
bytes: [07, 00]
output:
data:
valve: 0
- description: Hardware version
input:
fPort: 1
bytes: [03, 01, 0x12, 0x34]
output:
data:
hw_version: 01
capabilities: 0x1234
- description: Unknown FPort
input:
fPort: 42
bytes: [1, 42]
output:
errors:
- invalid FPort

downlinkEncoder:
fileName: aqs.js
examples:
- description: Turn Valve on
input:
data:
cmd: set valve on
output:
bytes: [7, 255]
fPort: 1
- description: Turn Valve off
input:
data:
cmd: set valve off
output:
bytes: [7, 0]
fPort: 1

downlinkDecoder:
fileName: aqs.js
examples:
- description: Turn Valve on
input:
fPort: 1
bytes: [7, 255]
output:
data:
cmd: set valve on
- description: Turn Valve off
input:
fPort: 1
bytes: [7, 0]
output:
data:
cmd: set valve off
21 changes: 21 additions & 0 deletions vendor/aquascope/aqm-profile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Whether the end device supports class B
supportsClassB: false
# Whether the end device supports class C
supportsClassC: true
classCTimeout: 60
# LoRaWAN MAC version: 1.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4 or 1.1
macVersion: 1.0.3
# LoRaWAN Regional Parameters version. Values depend on the LoRaWAN version:
# 1.0: TS001-1.0
# 1.0.1: TS001-1.0.1
# 1.0.2: RP001-1.0.2 or RP001-1.0.2-RevB
# 1.0.3: RP001-1.0.3-RevA
# 1.0.4: RP002-1.0.0 or RP002-1.0.1
# 1.1: RP001-1.1-RevA or RP001-1.1-RevB
regionalParametersVersion: RP001-1.0.3-RevA
# Whether the end device supports join (OTAA) or not (ABP)
supportsJoin: true
# Maximum EIRP
maxEIRP: 16
# Whether the end device supports 32-bit frame counters
supports32bitFCnt: true
252 changes: 252 additions & 0 deletions vendor/aquascope/aqm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
function decodeUplink(input) {
switch (input.fPort) {
case 1:
bytes = input.bytes;
var data = {};
for (i=0 ; i<bytes.length; i++) {
switch (bytes[i]) {
case 0x03:
data.hw_version = bytes[++i];
data.capabilities = (bytes[++i] << 8)+ bytes[++i];
break;
case 0x04:
p = bytes[++i];
v = (bytes[++i] << 8)+ bytes[++i];
switch (p) {
case 0x01:
data.c_system=v;
break;
case 0x03:
data.c_lora=v;
break;
case 0x04:
data.c_valveaction=v;
break;
case 0x05:
data.c_uss_signal_strength=v;
break;
case 0x06:
data.c_uss_rx_delay=v;
break;
case 0x07:
data.c_uss_tof=v;
break;
case 0x08:
data.c_litertranslation=v;
break;
case 0x09:
data.c_jamming=v;
break;
case 0x0a:
data.c_flow_th=v;
break;
case 0x0b:
data.c_frost_th=v;
break;
case 0x0d:
data.c_pc_duration=v;
break;
case 0x0e:
data.c_pc_abort_th=v;
break;
case 0x0f:
data.c_pc_alarm_th_th=v;
break;
case 19:
data.c_alarm=v;
break;
case 29:
data.c_report_interval=v;
break;
case 30:
data.c_heartbeat_interval=v;
break;
default:
data.error = "config parameter? "+bytes[i];
}
break;
case 0x06:
sensor = bytes[++i];
sensorvalue = (bytes[++i] << 8)+ bytes[++i];
switch(sensor) {
case 0x01:
data.temperature = sensorvalue;
break;
case 0x03:
data.uptime = sensorvalue;
break;
case 0x10:
data.pressure = sensorvalue;
break;
case 0x11:
data.consumption = sensorvalue;
break;
case 0x13:
data.batterylevel = sensorvalue;
break;
default:
data.error = "sensor type? "+bytes[i];
}
break;
case 0x07:
state = bytes[++i];
if(state == 0) data.valve=0;
else if (state == 1) {
data.flow=0;
data.conumption_time = (bytes[++i] << 8)+ bytes[++i];
data.conumption_liter = (bytes[++i] << 8)+ bytes[++i];
}
else if (state == 2) data.pc = "ok";
else if (state == 3) {
data.pc = "alarm";
data.diff = (bytes[++i] << 8)+ bytes[++i] ;
data.elevation = (bytes[++i] << 8)+ bytes[++i];
}
else if (state == 4 || state==7) data.pc = "abort/flow";
else if (state == 5) data.pc = "abort/heat";
else if (state == 6) data.pc = "abort/valve";
else if (state == 8) data.pc = "pending";
else if (state == 0x0f) data.flow = 1;
else data.valve = 255;
break;
case 0x08:
data.loglevel = bytes[++i];
data.log = bytes;
break;
case 0x0a:
data.fw_version = (bytes[++i] << 24) +(bytes[++i] << 16) + (bytes[++i] << 8) + bytes[++i];
break;
case 0x0b:
data.alarm_status = bytes[++i];
data.alarm_type = bytes[++i];
data.alarm_value = (bytes[++i] << 8)+ bytes[++i];
break;
default:
data.error = "command? "+bytes[i];
}
}
return {data:data}
default:
return {
errors: ['invalid FPort'],
};
}
}


function encodeDownlink(input) {
cmd = input.data.cmd;
switch (String(cmd)) {
case "reset":
return {
fPort: 1,
bytes: [0x01, 0x01],
};
case "factory default":
return {
fPort: 1,
bytes: [0x01, 0x02],
};
case "pipecheck start":
return {
fPort: 1,
bytes: [0x01, 0x03],
};
case "get sensor":
return {
fPort: 1,
bytes: [0x06, input.data.sensor],
};
case "set valve on":
return {
fPort: 1,
bytes: [0x07, 0xff],
};
case "set valve off":
return {
fPort: 1,
bytes: [0x07, 0x00],
};
case "clear alarm":
return {
fPort: 1,
bytes: [0x0b, 0x00],
};
case "get valve":
return {
fPort: 1,
bytes: [0x17],
};
case "get hw":
return {
fPort: 1,
bytes: [0x03],
};
case "get fw":
return {
fPort: 1,
bytes: [0x1a],
};
case "get config":
return {
fPort: 1,
bytes: [0x14, input.data.parameter],
};
case "set config":
return {
fPort: 1,
bytes: [0x04, input.data.parameter, (input.data.value>>8) & 0xff, input.data.value & 0xff],
};
}
}

function decodeDownlink(input) {
bytes = input.bytes;
data = {};
if (input.fPort != 1)
return {
errors: ['invalid FPort'],
};

switch (bytes[0]) {
case 0x01:
if (bytes[1]==0x01) data.cmd ="reset";
else if (bytes[1]==0x02) data.cmd ="factory default";
else if (bytes[1]==0x03) data.cmd ="pipecheck start";
break;
case 0x06:
data.cmd = "get sensor";
data.sensor = bytes[1];
break;
case 0x03:
data.cmd = "get hw";
break;
case 0x1a:
data.cmd = "get fw";
break;
case 0x17:
data.cmd = "get valve";
break;
case 0x07:
if (bytes[1]==0xff) data.cmd = "set valve on";
else data.cmd = "set valve off";
break;
case 0x0b:
if (bytes[1]== 0x00) data.cmd = "clear alarm";
break;
case 0x17:
data.cmd = "get valve";
break;
case 0x14:
data.cmd = "get config";
data.parameter = bytes[1];
break;
case 0x04:
data.cmd = "set config";
data.parameter = bytes[1];
data.value = (bytes[2] << 8)+ bytes[3];
break;
}
return {data:data}
}

Binary file added vendor/aquascope/aqm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading