Skip to content

Commit

Permalink
Update Dragino Decoder (#614)
Browse files Browse the repository at this point in the history
* Fix negative temperature error

* Add new devices from Dragino

* revert back abp frequency

* Update lgt92.yaml

* fixes

* Fix validate issue

* fix git merge issue

* fix validate

* validate fmt

* Update Dragino Sensors Decoder

* fix decoder format for LSN50-v2

* fix format issue

* Fix typo

* fix lsn50v2 codec

* Fix Codec

* update

* create

* Create sdi12、ps-lb、lse121、gro、lmds120 change trackerd and ltc2

* fix the lse01 file

* change file case

* Re-upload with lowercase filename

* Add lowercase name file

* Update lse01.yaml

* Update lse01.yaml

* Update lse01.yaml

* fix the error of  lse01-121-codec.yaml

* fixed codec files

some codec files were fixed

---------

Co-authored-by: Jaime Trinidad <[email protected]>
Co-authored-by: jinggengbei <[email protected]>
Co-authored-by: jinggengbei <[email protected]>
Co-authored-by: Jaime Trinidad <[email protected]>
  • Loading branch information
5 people authored Feb 28, 2024
1 parent 320d768 commit 1988801
Show file tree
Hide file tree
Showing 34 changed files with 2,297 additions and 76 deletions.
17 changes: 17 additions & 0 deletions vendor/dragino/d2x-lb-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uplinkDecoder:
fileName: d2x-lb.js
examples:
- description: Temperature
input:
fPort: 2
bytes: [0x0C, 0xF6, 0x01, 0x01, 0x03, 0x00, 0x0C, 0x01, 0xDD, 0x01, 0xFF]
output:
data: { 'BatV': 3.062, 'Bat_status': 3, 'Ext_sensor': 'Temperature Sensor', 'Hum_SHT': 88.6, 'TempC_DS': 27.81, 'TempC_SHT': 28.29 }

- description: Unknown FPort
input:
fPort: 2
bytes: [0xCB, 0xF6, 0x0B, 0x0D, 0x03, 0x76, 0x01, 0x0A, 0xDD, 0x7F, 0xFF]
output:
errors:
- unknown FPort
110 changes: 110 additions & 0 deletions vendor/dragino/d2x-lb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
function decodeUplink(input) {
var port = input.fPort;
var bytes = input.bytes;
var mode=(bytes[6] & 0x7C)>>2;
var data = {};
switch (input.fPort) {
case 2:
if(mode=='3')
{
data.Work_mode="DS18B20";
data.BatV=(bytes[0]<<8 | bytes[1])/1000;
data.ALARM_status=(bytes[6] & 0x01)? "TRUE":"FALSE";

if((bytes[2]==0xff)&& (bytes[3]==0xff))
{
data.Temp_C1="NULL";
}
else
{
data.Temp_C1= parseFloat(((bytes[2]<<24>>16 | bytes[3])/10).toFixed(1));
}

if((bytes[7]==0xff)&& (bytes[8]==0xff))
{
data.Temp_C2="NULL";
}
else
{
data.Temp_C2=parseFloat(((bytes[7]<<24>>16 | bytes[8])/10).toFixed(1));
}

if((bytes[9]==0xff)&& (bytes[10]==0xff))
{
data.Temp_C3="NULL";
}
else
{
data.Temp_C3=parseFloat(((bytes[9]<<8 | bytes[10])/10) .toFixed(1));
}
}
else if(mode=='31')
{
data.Work_mode="ALARM";
data.Temp_Red_MIN= bytes[4]<<24>>24;
data.Temp_Red_MAX= bytes[5]<<24>>24;
data.Temp_White_MIN= bytes[7]<<24>>24;
data.Temp_White_MAX= bytes[8]<<24>>24;
data.Temp_Black_MIN= bytes[9]<<24>>24;
data.Temp_Black_MAX= bytes[10]<<24>>24;
}

if(bytes.length==11)
return {
data: data,
}
break;

case 5:
{
if(bytes[0]==0x19)
data.SENSOR_MODEL= "D20-LB";

if(bytes[4]==0xff)
data.SUB_BAND="NULL";
else
data.SUB_BAND=bytes[4];

if(bytes[3]==0x01)
data.FREQUENCY_BAND="EU868";
else if(bytes[3]==0x02)
data.FREQUENCY_BAND="US915";
else if(bytes[3]==0x03)
data.FREQUENCY_BAND="IN865";
else if(bytes[3]==0x04)
data.FREQUENCY_BAND="AU915";
else if(bytes[3]==0x05)
data.FREQUENCY_BAND="KZ865";
else if(bytes[3]==0x06)
data.FREQUENCY_BAND="RU864";
else if(bytes[3]==0x07)
data.FREQUENCY_BAND="AS923";
else if(bytes[3]==0x08)
data.FREQUENCY_BAND="AS923_1";
else if(bytes[3]==0x09)
data.FREQUENCY_BAND="AS923_2";
else if(bytes[3]==0x0A)
data.FREQUENCY_BAND="AS923_3";
else if(bytes[3]==0x0B)
data.FREQUENCY_BAND="CN470";
else if(bytes[3]==0x0C)
data.FREQUENCY_BAND="EU433";
else if(bytes[3]==0x0D)
data.FREQUENCY_BAND="KR920";
else if(bytes[3]==0x0E)
data.FREQUENCY_BAND="MA869";

data.FIRMWARE_VERSION= (bytes[1]&0x0f)+'.'+(bytes[2]>>4&0x0f)+'.'+(bytes[2]&0x0f);
data.BAT= (bytes[5]<<8 | bytes[6])/1000;
}
return {
data: data,
}
break;

default:
return {
errors: ["unknown FPort"]
}
}
}
112 changes: 112 additions & 0 deletions vendor/dragino/d2x-lb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: d2x-lb
description: The Dragino d2x-lb consists of detects the temperature status and sends it to the LoRaWAN® network. Suitable for wireless alarm and security systems, home and building automation, industrial monitoring and control, and much more.

# Firmware versions (at least one is mandatory)
firmwareVersions:
- # Firmware version
version: '1.8.0'
numeric: 1

# LoRaWAN Device Profiles per region
# Supported regions are EU863-870, US902-928, AU915-928, AS923, CN779-787, EU433, CN470-510, KR920-923, IN865-867, RU864-870
profiles:
EU863-870:
# Unique identifier of the profile (lowercase, alphanumeric with dashes, max 36 characters)
id: eu868-profile
lorawanCertified: true
codec: d2x-lb-codec
EU433:
id: eu433-profile
lorawanCertified: true
codec: d2x-lb-codec
US902-928:
id: us915-profile
lorawanCertified: true
codec: d2x-lb-codec
KR920-923:
id: kr920-profile
lorawanCertified: true
codec: d2x-lb-codec
AU915-928:
id: au915-profile
lorawanCertified: true
codec: d2x-lb-codec
RU864-870:
id: ru864-profile
lorawanCertified: true
codec: d2x-lb-codec
IN865-867:
id: in865-profile
lorawanCertified: true
codec: d2x-lb-codec
CN470-510:
id: cn470-profile
lorawanCertified: true
codec: d2x-lb-codec
AS923:
id: as923-profile
lorawanCertified: true
codec: d2x-lb-codec

- version: 'd2x-lb abp'
numeric: 2
profiles:
EU863-870:
id: eu868-a-abp-profile
lorawanCertified: true
codec: d2x-lb-codec
EU433:
id: eu433-a-abp-profile
lorawanCertified: true
codec: d2x-lb-codec
US902-928:
id: us915-a-abp-profile
lorawanCertified: true
codec: d2x-lb-codec
AU915-928:
id: au915-a-abp-profile
lorawanCertified: true
codec: d2x-lb-codec
AS923:
id: as923-a-abp-profile
lorawanCertified: true
codec: d2x-lb-codec
CN470-510:
id: cn470-a-abp-profile
lorawanCertified: true
codec: d2x-lb-codec
IN865-867:
id: in865-a-abp-profile
lorawanCertified: true
codec: d2x-lb-codec
KR920-923:
id: kr920-a-abp-profile
lorawanCertified: true
codec: d2x-lb-codec
RU864-870:
id: ru864-a-abp-profile
lorawanCertified: true
codec: d2x-lb-codec
# Sensors that this device features (optional)
# Valid values are:
# 4-20 ma, accelerometer, altitude, analog input, auxiliary, barometer, battery, button, bvoc, co, co2, conductivity,
# current, digital input, dissolved oxygen, distance, dust, energy, gps, gyroscope, h2s, humidity, iaq, level, light,
# lightning, link, magnetometer, moisture, motion, no, no2, o3, particulate matter, ph, pir, pm2.5, pm10, potentiometer,
# power, precipitation, pressure, proximity, pulse count, pulse frequency, radar, rainfall, rssi, snr, solar radiation,
# sound, strain, surface temperature, temperature, tilt, time, tvoc, uv, vapor pressure, velocity, vibration, voltage,
# water potential, water, weight, wifi ssid, wind direction, wind speed.
sensors:
- water

# Product and data sheet URLs (optional)
productURL: https://www.dragino.com/products/temperature-humidity-sensor/item/168-lsn50v2-D2x.html
dataSheetURL: https://www.dropbox.com/sh/g99v0fxcltn9r1y/AAC38MvKyWPlmhaaJifcC2l9a/LHT65N%20Temperature%20%26%20Humidity%20Sensor?dl=0&subfolder_nav_tracking=1
sellerURLs:
- name: 'Dragino'
region:
- China
url: http://www.dragino.com/

# Photos
photos:
main: d2x-lb.jpg
17 changes: 17 additions & 0 deletions vendor/dragino/gro_point_air-codec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
uplinkDecoder:
fileName: gro_point_air.js
examples:
- description: soil moisture
input:
fPort: 2
bytes: [0xCE, 0x29, 0x00, 0xF1, 0x07, 0xA5, 0x09, 0x9B, 0x6E, 0x28, 0x90]
output:
data: { 'Bat': 3.625, 'TempC_DS18B20': '24.1', 'conduct_SOIL': 28200, 'temp_SOIL': '24.59', 'water_SOIL': '19.57' }

- description: Unknown FPort
input:
fPort: 42
bytes: [0xCE, 0x29, 0x00, 0xF1, 0x07, 0xA5, 0x09, 0x9B, 0x6E, 0x28, 0x90]
output:
errors:
- unknown FPort
85 changes: 85 additions & 0 deletions vendor/dragino/gro_point_air.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
function decodeUplink(input) {
var port = input.fPort;
var bytes = input.bytes;
var dic = {};

var tem =["tem1","tem2","tem3","tem4","tem5","tem6","tem7",

"tem8","tem9","tem10","tem11","tem12","tem13"];

var hum =["soil_moisture1","soil_moisture2","soil_moisture3","soil_moisture4","soil_moisture5","soil_moisture6","soil_moisture7","soil_moisture8"];

var tem_len =[0,0,4,6,7,9,11,12,13];

var hum_len =[0,0,2,3,4,5,6,7,8];



var value=(bytes[0]<<8 | bytes[1]) & 0x0FFF;

dic.bat = value/1000;//Battery,units:V
var sen_type = bytes[2]-0x30;

dic.sen = sen_type;

var is_tem_flag = false;
if((bytes[3+tem_len[sen_type]*2]==0x7F) && (bytes[4+tem_len[sen_type]*2]==0xFF))
{
hum_len[sen_type]=1;
}
if((bytes.length-3-(hum_len[sen_type]*2))===(tem_len[sen_type]*2))

{
is_tem_flag = true;
}

var start_bytes=3;

if(is_tem_flag === true)

{
for(i=0;i<tem_len[sen_type];i++)

{

if(bytes[start_bytes] & 0x80)

dic[tem[i]]= (((bytes[start_bytes]<<8)|bytes[start_bytes+1])-0xFFFF)/(10.0); //<0

else

dic[tem[i]]= ((bytes[start_bytes]<<8)|bytes[start_bytes+1])/(10.0);



start_bytes+=2;

}
}


for(i=0;i<hum_len[sen_type];i++)

{
if(bytes[start_bytes]==0x7F && bytes[start_bytes+1]==0xFF)
{
if(is_tem_flag === true)
dic[hum[1]]="Invalid data";
else
{
dic[tem[0]]="Invalid data";
dic[hum[0]]="Invalid data";
}
}
else{
dic[hum[i]]=((bytes[start_bytes]<<8)|bytes[start_bytes+1])/(10.0);

start_bytes+=2;
}
}


return {
data:dic
}
}
Loading

0 comments on commit 1988801

Please sign in to comment.