Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
172 changes: 172 additions & 0 deletions vendor/decentlab/dl-atm41g2-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
uplinkDecoder:
fileName: dl-atm41g2.js
examples:
- description: Example 1
input:
fPort: 1
bytes:
[
0x02,
0x5e,
0xf8,
0x00,
0x03,
0x80,
0x5c,
0x00,
0x00,
0x80,
0x00,
0x80,
0x00,
0x80,
0x34,
0x84,
0xb3,
0x80,
0x36,
0x80,
0xe7,
0x80,
0x86,
0xa6,
0x01,
0x81,
0xd6,
0x80,
0xed,
0x81,
0xc9,
0x80,
0x9f,
0x80,
0x00,
0x11,
0x70,
0x00,
0x01,
0x0a,
0xdc,
]
output:
data:
air_temperature:
displayName: Air temperature
unit: "\xB0C"
value: 23.1
barometric_pressure:
displayName: Barometric pressure
unit: kPa
value: 97.29
battery_voltage:
displayName: Battery voltage
unit: V
value: 2.78
cumulative_precipitation:
displayName: Cumulative precipitation
unit: mm
value: 70
device_id: 24312
internal_temperature:
displayName: Internal temperature
unit: "\xB0C"
value: 23.7
lightning_average_distance:
displayName: Lightning average distance
unit: km
value: 0
lightning_strike_count:
displayName: Lightning strike count
unit: None
value: 0
maximum_wind_speed:
displayName: Maximum wind speed
unit: "m\u22C5s\u207B\xB9"
value: 0.54
precipitation:
displayName: Precipitation
unit: mm
value: 0
precipitation_electrical_conductivity:
displayName: Precipitation electrical conductivity
unit: "\xB5S\u22C5cm\u207B\xB9"
value: 0
protocol_version: 2
relative_humidity:
displayName: Relative humidity
unit: '%'
value: 47
solar_radiation:
displayName: Solar radiation
unit: "W\u22C5m\u207B\xB2"
value: 9.2
tilt_angle_x_orientation:
displayName: Tilt angle, X orientation
unit: "\xB0"
value: 45.7
tilt_angle_y_orientation:
displayName: Tilt angle, Y orientation
unit: "\xB0"
value: 15.9
vapor_pressure:
displayName: Vapor pressure
unit: kPa
value: 1.34
wind_direction:
displayName: Wind direction
unit: "\xB0"
value: 120.3
wind_speed:
displayName: Wind speed
unit: "m\u22C5s\u207B\xB9"
value: 0.52
- description: Example 2
input:
fPort: 1
bytes: [0x02, 0x5e, 0xf8, 0x00, 0x02, 0x0a, 0xdc]
output:
data:
battery_voltage:
displayName: Battery voltage
unit: V
value: 2.78
device_id: 24312
protocol_version: 2

downlinkEncoder:
fileName: dl-downlink-codec.js
examples:
- description: Set period 3600 seconds and save
input:
data:
command: set period + save
parameter: 3600
output:
bytes: [0, 2, 14, 16, 72, 164]
fPort: 1
- description: Set ADR off
input:
data:
command: set adr off
output:
bytes: [0, 7, 0, 0, 229, 177]
fPort: 1

downlinkDecoder:
fileName: dl-downlink-codec.js
examples:
- description: Set period 600 seconds
input:
fPort: 1
bytes: [0x00, 0x01, 0x02, 0x58, 0x7E, 0x51]
output:
data:
command: set period
parameter: 600
- description: Reset
input:
fPort: 1
bytes: [0xFE, 0xFE, 0x00, 0x00, 0x3C, 0x50]
output:
data:
command: reset
140 changes: 140 additions & 0 deletions vendor/decentlab/dl-atm41g2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@

/* https://www.decentlab.com/products/eleven-parameter-weather-station-for-lorawan */

var decentlab_decoder = {
PROTOCOL_VERSION: 2,
SENSORS: [
{length: 17,
values: [{name: 'solar_radiation',
displayName: 'Solar radiation',
convert: function (x) { return (x[0] - 32768) / 10; },
unit: 'W⋅m⁻²'},
{name: 'precipitation',
displayName: 'Precipitation',
convert: function (x) { return x[1] / 1000; },
unit: 'mm'},
{name: 'lightning_strike_count',
displayName: 'Lightning strike count',
convert: function (x) { return x[2] - 32768; },
unit: 'None'},
{name: 'lightning_average_distance',
displayName: 'Lightning average distance',
convert: function (x) { return x[3] - 32768; },
unit: 'km'},
{name: 'wind_speed',
displayName: 'Wind speed',
convert: function (x) { return (x[4] - 32768) / 100; },
unit: 'm⋅s⁻¹'},
{name: 'wind_direction',
displayName: 'Wind direction',
convert: function (x) { return (x[5] - 32768) / 10; },
unit: '°'},
{name: 'maximum_wind_speed',
displayName: 'Maximum wind speed',
convert: function (x) { return (x[6] - 32768) / 100; },
unit: 'm⋅s⁻¹'},
{name: 'air_temperature',
displayName: 'Air temperature',
convert: function (x) { return (x[7] - 32768) / 10; },
unit: '°C'},
{name: 'vapor_pressure',
displayName: 'Vapor pressure',
convert: function (x) { return (x[8] - 32768) / 100; },
unit: 'kPa'},
{name: 'barometric_pressure',
displayName: 'Barometric pressure',
convert: function (x) { return (x[9] - 32768) / 100; },
unit: 'kPa'},
{name: 'relative_humidity',
displayName: 'Relative humidity',
convert: function (x) { return (x[10] - 32768) / 10; },
unit: '%'},
{name: 'internal_temperature',
displayName: 'Internal temperature',
convert: function (x) { return (x[11] - 32768) / 10; },
unit: '°C'},
{name: 'tilt_angle_x_orientation',
displayName: 'Tilt angle, X orientation',
convert: function (x) { return (x[12] - 32768) / 10; },
unit: '°'},
{name: 'tilt_angle_y_orientation',
displayName: 'Tilt angle, Y orientation',
convert: function (x) { return (x[13] - 32768) / 10; },
unit: '°'},
{name: 'precipitation_electrical_conductivity',
displayName: 'Precipitation electrical conductivity',
convert: function (x) { return x[14] - 32768; },
unit: 'µS⋅cm⁻¹'},
{name: 'cumulative_precipitation',
displayName: 'Cumulative precipitation',
convert: function (x) { return (x[15] + x[16] * 65536) / 1000; },
unit: 'mm'}]},
{length: 1,
values: [{name: 'battery_voltage',
displayName: 'Battery voltage',
convert: function (x) { return x[0] / 1000; },
unit: 'V'}]}
],

read_int: function (bytes, pos) {
return (bytes[pos] << 8) + bytes[pos + 1];
},

decode: function (msg) {
var bytes = msg;
var i, j;
if (typeof msg === 'string') {
bytes = [];
for (i = 0; i < msg.length; i += 2) {
bytes.push(parseInt(msg.substring(i, i + 2), 16));
}
}

var version = bytes[0];
if (version != this.PROTOCOL_VERSION) {
return {error: "protocol version " + version + " doesn't match v2"};
}

var deviceId = this.read_int(bytes, 1);
var flags = this.read_int(bytes, 3);
var result = {'protocol_version': version, 'device_id': deviceId};
// decode payload
var pos = 5;
for (i = 0; i < this.SENSORS.length; i++, flags >>= 1) {
if ((flags & 1) !== 1)
continue;

var sensor = this.SENSORS[i];
var x = [];
// convert data to 16-bit integer array
for (j = 0; j < sensor.length; j++) {
x.push(this.read_int(bytes, pos));
pos += 2;
}

// decode sensor values
for (j = 0; j < sensor.values.length; j++) {
var value = sensor.values[j];
if ('convert' in value) {
result[value.name] = {displayName: value.displayName,
value: value.convert.bind(this)(x)};
if ('unit' in value)
result[value.name]['unit'] = value.unit;
}
}
}
return result;
}
};

function decodeUplink(input) {
var res = decentlab_decoder.decode(input.bytes);
if (res.error) {
return {
errors: [res.error],
};
}
return {
data: res,
};
}
Binary file added vendor/decentlab/dl-atm41g2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading