Skip to content

Commit 0509f5e

Browse files
authored
Add Dragino, Milesight and Seeed devices. (#7)
1 parent e5fe9a2 commit 0509f5e

File tree

96 files changed

+5528
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+5528
-0
lines changed

vendors/dragino/codecs/ldds75.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
function decodeUplink(input) {
2+
let decoded = {};
3+
let len = input.bytes.length;
4+
let value = (input.bytes[0]<<8 | input.bytes[1]) & 0x3FFF;
5+
6+
switch (input.fPort) {
7+
case 2:
8+
decoded.Bat=value/1000;
9+
value=input.bytes[2]<<8 | input.bytes[3];
10+
decoded.Distance=(value); //+" mm"; distance in mm
11+
12+
if(value === 0)
13+
decoded.Distance = "No Sensor";
14+
else if (value === 20)
15+
decoded.Distance = "Invalid Reading";
16+
decoded.Interrupt_flag = input.bytes[4];
17+
18+
value = input.bytes[5]<<8 | input.bytes[6];
19+
if (input.bytes[5] & 0x80)
20+
{value |= 0xFFFF0000;}
21+
decoded.TempC_DS18B20=(value/10).toFixed(2); //DS18B20,temperature
22+
decoded.Sensor_flag = input.bytes[7];
23+
24+
return {data: decoded};
25+
26+
default:
27+
return {
28+
errors: ["unknown FPort"]
29+
}
30+
}
31+
}

vendors/dragino/codecs/lds02.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
function decodeUplink(input) {
2+
return {
3+
data: Decode(input.fPort, input.bytes, input.variables)
4+
};
5+
}
6+
7+
function Decode(fPort, bytes, variables) {
8+
// Decode an uplink message from a buffer
9+
// (array) of bytes to an object of fields.
10+
var value=(bytes[0]<<8 | bytes[1])&0x3FFF;
11+
var bat=value/1000;//Battery,units:V
12+
13+
var door_open_status=bytes[0]&0x80?1:0;//1:open,0:close
14+
var water_leak_status=bytes[0]&0x40?1:0;
15+
16+
var mod=bytes[2];
17+
var alarm=bytes[9]&0x01;
18+
19+
if(mod==1){
20+
var open_times=bytes[3]<<16 | bytes[4]<<8 | bytes[5];
21+
var open_duration=bytes[6]<<16 | bytes[7]<<8 | bytes[8];//units:min
22+
if(bytes.length==10 && 0x07>bytes[0]< 0x0f)
23+
return {
24+
Node_type:"LDS02",
25+
BAT_V:bat,
26+
MOD:mod,
27+
DOOR_OPEN_STATUS:door_open_status,
28+
DOOR_OPEN_TIMES:open_times,
29+
LAST_DOOR_OPEN_DURATION:open_duration,
30+
ALARM:alarm
31+
};
32+
}
33+
else if(mod==2)
34+
{
35+
var leak_times=bytes[3]<<16 | bytes[4]<<8 | bytes[5];
36+
var leak_duration=bytes[6]<<16 | bytes[7]<<8 | bytes[8];//units:min
37+
if(bytes.length==10 && 0x07>bytes[0]< 0x0f)
38+
return {
39+
Node_type:"LWL02",
40+
BAT_V:bat,
41+
MOD:mod,
42+
WATER_LEAK_STATUS:water_leak_status,
43+
WATER_LEAK_TIMES:leak_times,
44+
LAST_WATER_LEAK_DURATION:leak_duration
45+
};
46+
}
47+
else if(mod==3)
48+
if(bytes.length==10 && 0x07>bytes[0]< 0x0f)
49+
{
50+
return {
51+
Node_type:"LWL02",
52+
BAT_V:bat,
53+
MOD:mod,
54+
DOOR_OPEN_STATUS:door_open_status,
55+
WATER_LEAK_STATUS:water_leak_status,
56+
ALARM:alarm
57+
};
58+
}
59+
else{
60+
return {
61+
Node_type:"LWL02",
62+
BAT_V:bat,
63+
MOD:mod,
64+
};
65+
}
66+
}

0 commit comments

Comments
 (0)