Compare commits
No commits in common. "0c999bdfeda2ade1aa58dc8321b53f935a2faa84" and "2e84855948c4be470b0598b0353527c8cf23485b" have entirely different histories.
0c999bdfed
...
2e84855948
|
@ -1,156 +0,0 @@
|
||||||
// Decode uplink function.
|
|
||||||
//
|
|
||||||
// Input is an object with the following fields:
|
|
||||||
// - bytes = Byte array containing the uplink payload, e.g. [255, 230, 255, 0]
|
|
||||||
// - fPort = Uplink fPort.
|
|
||||||
// - variables = Object containing the configured device variables.
|
|
||||||
//
|
|
||||||
// Output must be an object with the following fields:
|
|
||||||
// - data = Object representing the decoded payload.
|
|
||||||
function decodeUplink(input) {
|
|
||||||
return {
|
|
||||||
data: Decoder(input.bytes, input.fPort)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function datalog(i,bytes){
|
|
||||||
var aa= parseFloat(((bytes[3+i]<<24>>16 | bytes[4+i])/10).toFixed(1));
|
|
||||||
var bb= parseFloat(((bytes[5+i]<<8 | bytes[6+i])/10).toFixed(1));
|
|
||||||
var cc= getMyDate((bytes[7+i]<<24 | bytes[8+i]<<16 | bytes[9+i]<<8 | bytes[10+i]).toString(10));
|
|
||||||
var string='['+aa+','+bb+','+cc+']'+',';
|
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getzf(c_num){
|
|
||||||
if(parseInt(c_num) < 10)
|
|
||||||
c_num = '0' + c_num;
|
|
||||||
|
|
||||||
return c_num;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getMyDate(str){
|
|
||||||
var c_Date;
|
|
||||||
if(str > 9999999999)
|
|
||||||
c_Date = new Date(parseInt(str));
|
|
||||||
else
|
|
||||||
c_Date = new Date(parseInt(str) * 1000);
|
|
||||||
|
|
||||||
var c_Year = c_Date.getFullYear(),
|
|
||||||
c_Month = c_Date.getMonth()+1,
|
|
||||||
c_Day = c_Date.getDate(),
|
|
||||||
c_Hour = c_Date.getHours(),
|
|
||||||
c_Min = c_Date.getMinutes(),
|
|
||||||
c_Sen = c_Date.getSeconds();
|
|
||||||
var c_Time = c_Year +'-'+ getzf(c_Month) +'-'+ getzf(c_Day) +' '+ getzf(c_Hour) +':'+ getzf(c_Min) +':'+getzf(c_Sen);
|
|
||||||
|
|
||||||
return c_Time;
|
|
||||||
}
|
|
||||||
|
|
||||||
function Decoder(bytes, port) {
|
|
||||||
//LSN50_v2_S31_S31B Decode
|
|
||||||
if(port==0x02)
|
|
||||||
{
|
|
||||||
var decode = {};
|
|
||||||
var mode=(bytes[6] & 0x7C)>>2;
|
|
||||||
if(mode==0)
|
|
||||||
{
|
|
||||||
decode.BatV=(bytes[0]<<8 | bytes[1])/1000;
|
|
||||||
decode.EXTI_Trigger=(bytes[6] & 0x01)? "TRUE":"FALSE";
|
|
||||||
// decode.Door_status=(bytes[6] & 0x80)? "CLOSE":"OPEN";
|
|
||||||
decode.TempC_SHT31= parseFloat(((bytes[7]<<24>>16 | bytes[8])/10).toFixed(1));
|
|
||||||
decode.Hum_SHT31=parseFloat(((bytes[9]<<8 | bytes[10])/10).toFixed(1));
|
|
||||||
// decode.Data_time= getMyDate((bytes[2]<<24 | bytes[3]<<16 | bytes[4]<<8 | bytes[5]).toString(10));
|
|
||||||
}
|
|
||||||
else if(mode==31)
|
|
||||||
{
|
|
||||||
decode.SHTEMP_MIN= bytes[7]<<24>>24;
|
|
||||||
decode.SHTEMP_MAX= bytes[8]<<24>>24;
|
|
||||||
decode.SHHUM_MIN= bytes[9];
|
|
||||||
decode.SHHUM_MAX= bytes[10];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(bytes.length==11)
|
|
||||||
return decode;
|
|
||||||
}
|
|
||||||
else if(port==3)
|
|
||||||
{
|
|
||||||
for(var i=0;i<bytes.length;i=i+11)
|
|
||||||
{
|
|
||||||
var data= datalog(i,bytes);
|
|
||||||
if(i=='0')
|
|
||||||
data_sum=data;
|
|
||||||
else
|
|
||||||
data_sum+=data;
|
|
||||||
}
|
|
||||||
return{
|
|
||||||
DATALOG:data_sum
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else if(port==5)
|
|
||||||
{
|
|
||||||
var freq_band;
|
|
||||||
var sub_band;
|
|
||||||
|
|
||||||
if(bytes[0]==0x01)
|
|
||||||
freq_band="EU868";
|
|
||||||
else if(bytes[0]==0x02)
|
|
||||||
freq_band="US915";
|
|
||||||
else if(bytes[0]==0x03)
|
|
||||||
freq_band="IN865";
|
|
||||||
else if(bytes[0]==0x04)
|
|
||||||
freq_band="AU915";
|
|
||||||
else if(bytes[0]==0x05)
|
|
||||||
freq_band="KZ865";
|
|
||||||
else if(bytes[0]==0x06)
|
|
||||||
freq_band="RU864";
|
|
||||||
else if(bytes[0]==0x07)
|
|
||||||
freq_band="AS923";
|
|
||||||
else if(bytes[0]==0x08)
|
|
||||||
freq_band="AS923_1";
|
|
||||||
else if(bytes[0]==0x09)
|
|
||||||
freq_band="AS923_2";
|
|
||||||
else if(bytes[0]==0x0A)
|
|
||||||
freq_band="AS923_3";
|
|
||||||
else if(bytes[0]==0x0F)
|
|
||||||
freq_band="AS923_4";
|
|
||||||
else if(bytes[0]==0x0B)
|
|
||||||
freq_band="CN470";
|
|
||||||
else if(bytes[0]==0x0C)
|
|
||||||
freq_band="EU433";
|
|
||||||
else if(bytes[0]==0x0D)
|
|
||||||
freq_band="KR920";
|
|
||||||
else if(bytes[0]==0x0E)
|
|
||||||
freq_band="MA869";
|
|
||||||
|
|
||||||
if(bytes[1]==0xff)
|
|
||||||
sub_band="NULL";
|
|
||||||
else
|
|
||||||
sub_band=bytes[1];
|
|
||||||
|
|
||||||
var firm_ver= (bytes[2]&0x0f)+'.'+(bytes[3]>>4&0x0f)+'.'+(bytes[3]&0x0f);
|
|
||||||
|
|
||||||
var tdc_time= bytes[4]<<16 | bytes[5]<<8 | bytes[6];
|
|
||||||
|
|
||||||
return {
|
|
||||||
FIRMWARE_VERSION:firm_ver,
|
|
||||||
FREQUENCY_BAND:freq_band,
|
|
||||||
SUB_BAND:sub_band,
|
|
||||||
TDC_sec:tdc_time,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode downlink function.
|
|
||||||
//
|
|
||||||
// Input is an object with the following fields:
|
|
||||||
// - data = Object representing the payload that must be encoded.
|
|
||||||
// - variables = Object containing the configured device variables.
|
|
||||||
//
|
|
||||||
// Output must be an object with the following fields:
|
|
||||||
// - bytes = Byte array containing the downlink payload.
|
|
||||||
function encodeDownlink(input) {
|
|
||||||
return {
|
|
||||||
bytes: [225, 230, 255, 0]
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,47 +0,0 @@
|
||||||
// Decode uplink function.
|
|
||||||
//
|
|
||||||
// Input is an object with the following fields:
|
|
||||||
// - bytes = Byte array containing the uplink payload, e.g. [255, 230, 255, 0]
|
|
||||||
// - fPort = Uplink fPort.
|
|
||||||
// - variables = Object containing the configured device variables.
|
|
||||||
//
|
|
||||||
// Output must be an object with the following fields:
|
|
||||||
// - data = Object representing the decoded payload.
|
|
||||||
// AT configuration for Dragino RS485-BL and RS485 PM 1.0/2.5/10 sensor
|
|
||||||
// AT+5VT=3000
|
|
||||||
// AT+MBFUN=1
|
|
||||||
// AT+BAUDR=9600
|
|
||||||
// AT+STOPBIT=1
|
|
||||||
// AT+COMMAND1=01 03 00 00 00 03 ,1 AT+SEARCH1=0,0 AT+DATACUT1=0,0,0 AT+CMDDL1=2000
|
|
||||||
// AT+CFGDEV does not work. Must have AT+CMDDL1
|
|
||||||
function decodeUplink(input) {
|
|
||||||
var bytes = input.bytes;
|
|
||||||
|
|
||||||
// Only accept fPort=2. Ignore fPort=4
|
|
||||||
if(input.fPort != 2) {
|
|
||||||
return {"data": {}};
|
|
||||||
}
|
|
||||||
|
|
||||||
var BatV = (bytes[0] << 8 | bytes[1]) / 1000 + 0.277;
|
|
||||||
var PayVER = bytes[2];
|
|
||||||
// If AT+DATAUP=1, PayloadCount=1 byte, payload#=1 byte
|
|
||||||
var Humidity = bytes[3] == 0xff && bytes[4] == 0xff? -1: (bytes[3] << 8 | bytes[4])/10;
|
|
||||||
var Temperature = bytes[5] == 0xff && bytes[6] == 0xff? -1: (bytes[5] << 8 | bytes[6])/10;
|
|
||||||
return {
|
|
||||||
data: {
|
|
||||||
"BatV": BatV, "Humidity": Humidity, "Temperature": Temperature
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode downlink function.
|
|
||||||
//
|
|
||||||
// Input is an object with the following fields:
|
|
||||||
// - data = Object representing the payload that must be encoded.
|
|
||||||
// - variables = Object containing the configured device variables.
|
|
||||||
//
|
|
||||||
// Output must be an object with the following fields:
|
|
||||||
// - bytes = Byte array containing the downlink payload.
|
|
||||||
function encodeDownlink(input) {
|
|
||||||
return {bytes: []};
|
|
||||||
}
|
|
|
@ -1,46 +0,0 @@
|
||||||
// Decode uplink function.
|
|
||||||
//
|
|
||||||
// Input is an object with the following fields:
|
|
||||||
// - bytes = Byte array containing the uplink payload, e.g. [255, 230, 255, 0]
|
|
||||||
// - fPort = Uplink fPort.
|
|
||||||
// - variables = Object containing the configured device variables.
|
|
||||||
//
|
|
||||||
// Output must be an object with the following fields:
|
|
||||||
// - data = Object representing the decoded payload.
|
|
||||||
// AT configuration for Dragino RS485-BL and RS485 PM 1.0/2.5/10 sensor
|
|
||||||
// AT+5VT=3000
|
|
||||||
// AT+MBFUN=1
|
|
||||||
// AT+BAUDR=9600
|
|
||||||
// AT+COMMAND1=01 03 00 00 00 03 ,1 AT+SEARCH1=0,0 AT+DATACUT1=0,0,0 AT+CMDDL1=2000
|
|
||||||
function decodeUplink(input) {
|
|
||||||
var bytes = input.bytes;
|
|
||||||
|
|
||||||
// Only accept fPort=2. Ignore fPort=4
|
|
||||||
if(input.fPort != 2) {
|
|
||||||
return {"data": {}};
|
|
||||||
}
|
|
||||||
|
|
||||||
var BatV = (bytes[0] << 8 | bytes[1]) / 1000 + 0.277;
|
|
||||||
var PayVER = bytes[2];
|
|
||||||
// If AT+DATAUP=1, PayloadCount=1 byte, payload#=1 byte
|
|
||||||
var PM2_5 = bytes[3] == 0xff && bytes[4] == 0xff? -1: bytes[3] << 8 | bytes[4];
|
|
||||||
var PM10 = bytes[5] == 0xff && bytes[6] == 0xff? -1: bytes[5] << 8 | bytes[6];
|
|
||||||
var PM1_0 = bytes[7] == 0xff && bytes[8] == 0xff? -1: bytes[7] << 8 | bytes[8];
|
|
||||||
return {
|
|
||||||
data: {
|
|
||||||
"BatV": BatV, "PM2_5": PM2_5, "PM10": PM10, "PM1_0": PM1_0
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encode downlink function.
|
|
||||||
//
|
|
||||||
// Input is an object with the following fields:
|
|
||||||
// - data = Object representing the payload that must be encoded.
|
|
||||||
// - variables = Object containing the configured device variables.
|
|
||||||
//
|
|
||||||
// Output must be an object with the following fields:
|
|
||||||
// - bytes = Byte array containing the downlink payload.
|
|
||||||
function encodeDownlink(input) {
|
|
||||||
return {bytes: []};
|
|
||||||
}
|
|
|
@ -1,343 +0,0 @@
|
||||||
//The function is :
|
|
||||||
function decodeUplink(input) {
|
|
||||||
var port = input.fPort;
|
|
||||||
var bytes = input.bytes;
|
|
||||||
// Decode an uplink message from a buffer
|
|
||||||
// (array) of bytes to an object of fields.
|
|
||||||
var i;
|
|
||||||
var con;
|
|
||||||
var str = "";
|
|
||||||
var major = 1;
|
|
||||||
var minor = 1;
|
|
||||||
var rssi = 0;
|
|
||||||
var power = 0;
|
|
||||||
var device_information1 = 0;
|
|
||||||
var device_information2 = 0;
|
|
||||||
var device_information3 = 0;
|
|
||||||
var addr = "";
|
|
||||||
var alarm=0;//Alarm status
|
|
||||||
var batV=0;//Battery,units:V
|
|
||||||
var bat=0;//Battery,units:V
|
|
||||||
var mod = 0;
|
|
||||||
var led_updown="";//LED status for position,uplink and downlink
|
|
||||||
var Firmware = 0; // Firmware version; 5 bits
|
|
||||||
var hum=0;//hum,units: °
|
|
||||||
var tem=0; //tem,units: °
|
|
||||||
var latitude=0;//gps latitude,units: °
|
|
||||||
var longitude = 0;//gps longitude,units: °
|
|
||||||
var location=0;
|
|
||||||
var time =0;
|
|
||||||
var date =0;
|
|
||||||
var sub_band;
|
|
||||||
var freq_band;
|
|
||||||
var sensor;
|
|
||||||
var firm_ver;
|
|
||||||
var sensor_mod;
|
|
||||||
var gps_mod;
|
|
||||||
var ble_mod;
|
|
||||||
var pnackmd;
|
|
||||||
var lon;
|
|
||||||
var intwk;
|
|
||||||
switch (input.fPort) {
|
|
||||||
case 2:
|
|
||||||
var decode = {};
|
|
||||||
bat =(((bytes[8] & 0x3f) <<8) | bytes[9]);//Battery,units:V
|
|
||||||
|
|
||||||
latitude=(bytes[0]<<24 | bytes[1]<<16 | bytes[2]<<8 | bytes[3])/1000000;//gps latitude,units: °
|
|
||||||
longitude=(bytes[4]<<24 | bytes[5]<<16 | bytes[6]<<8 | bytes[7])/1000000;//gps longitude,units: °
|
|
||||||
|
|
||||||
|
|
||||||
if ((latitude < 190) && (latitude > -190)) {
|
|
||||||
if ((longitude < 190) && (longitude > -190)) {
|
|
||||||
if ((latitude !== 0) && (longitude !==0)) {
|
|
||||||
field: "location",
|
|
||||||
location= "" + latitude + "," + longitude + ""
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
alarm=(bytes[8] & 0x40)?"TRUE":"FALSE";//Alarm status
|
|
||||||
batV=(((bytes[8] & 0x3f) <<8) | bytes[9])/1000;//Battery,units:V
|
|
||||||
mod = bytes[10] & 0xC0;
|
|
||||||
|
|
||||||
if(mod !== 1)
|
|
||||||
{
|
|
||||||
hum=(bytes[11]<<8 | bytes[12])/10;//hum,units: °
|
|
||||||
tem=(bytes[13]<<8 | bytes[14])/10; //tem,units: °
|
|
||||||
}
|
|
||||||
led_updown=(bytes[10] & 0x20)?"ON":"OFF";//LED status for position,uplink and downlink
|
|
||||||
intwk = (bytes[10] & 0x10)?"MOVE":"STILL";
|
|
||||||
|
|
||||||
{
|
|
||||||
var decode = {};
|
|
||||||
|
|
||||||
if(latitude !== 0 && longitude !==0)
|
|
||||||
{
|
|
||||||
decode.Location=location
|
|
||||||
decode.Latitude=latitude
|
|
||||||
decode.Longitud=longitude
|
|
||||||
}
|
|
||||||
|
|
||||||
decode.Hum=hum
|
|
||||||
decode.Tem=tem
|
|
||||||
decode.ALARM_status=alarm
|
|
||||||
decode.MD=mod
|
|
||||||
decode.LON=led_updown
|
|
||||||
decode.Transport=intwk
|
|
||||||
return {
|
|
||||||
data:decode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
{
|
|
||||||
var decode = {};
|
|
||||||
bat =(((bytes[8] & 0x3f) <<8) | bytes[9]);//Battery,units:V
|
|
||||||
|
|
||||||
latitude=(bytes[0]<<24 | bytes[1]<<16 | bytes[2]<<8 | bytes[3])/1000000;//gps latitude,units: °
|
|
||||||
longitude=(bytes[4]<<24 | bytes[5]<<16 | bytes[6]<<8 | bytes[7])/1000000;//gps longitude,units: °
|
|
||||||
|
|
||||||
|
|
||||||
if ((latitude < 190) && (latitude > -190)) {
|
|
||||||
if ((longitude < 190) && (longitude > -190)) {
|
|
||||||
if ((latitude !== 0) && (longitude !==0)) {
|
|
||||||
field: "location",
|
|
||||||
location= "" + latitude + "," + longitude + ""
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
alarm=(bytes[8] & 0x40)?"TRUE":"FALSE";//Alarm status
|
|
||||||
batV=(((bytes[8] & 0x3f) <<8) | bytes[9])/1000;//Battery,units:V
|
|
||||||
mod = bytes[10] & 0xC0;
|
|
||||||
|
|
||||||
if(mod !== 1)
|
|
||||||
{
|
|
||||||
hum=(bytes[11]<<8 | bytes[12])/10;//hum,units: °
|
|
||||||
tem=(bytes[13]<<8 | bytes[14])/10; //tem,units: °
|
|
||||||
}
|
|
||||||
led_updown=(bytes[10] & 0x20)?"ON":"OFF";//LED status for position,uplink and downlink
|
|
||||||
intwk = (bytes[10] & 0x10)?"MOVE":"STILL";
|
|
||||||
{
|
|
||||||
var decode = {};
|
|
||||||
|
|
||||||
if(latitude !== 0 && longitude !==0)
|
|
||||||
{
|
|
||||||
decode.Location=location
|
|
||||||
decode.Latitude=latitude
|
|
||||||
decode.Longitud=longitude
|
|
||||||
}
|
|
||||||
|
|
||||||
decode.BatV=batV
|
|
||||||
decode.ALARM_status=alarm
|
|
||||||
decode.MD=mod
|
|
||||||
decode.LON=led_updown
|
|
||||||
decode.Transport=intwk
|
|
||||||
return {
|
|
||||||
data:decode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
{
|
|
||||||
var decode = {};
|
|
||||||
latitude=(bytes[0]<<24 | bytes[1]<<16 | bytes[2]<<8 | bytes[3])/1000000;//gps latitude,units: °
|
|
||||||
longitude=(bytes[4]<<24 | bytes[5]<<16 | bytes[6]<<8 | bytes[7])/1000000;//gps longitude,units: °
|
|
||||||
|
|
||||||
if ((latitude < 190) && (latitude > -190)) {
|
|
||||||
if ((longitude < 190) && (longitude > -190)) {
|
|
||||||
if ((latitude !== 0) && (longitude !==0)) {
|
|
||||||
field: "location",
|
|
||||||
location= "" + latitude + "," + longitude + ""
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var year = bytes[8]<<8 | bytes[9];
|
|
||||||
var Month = bytes[10];
|
|
||||||
var day = bytes[11];
|
|
||||||
var hour = bytes[12];
|
|
||||||
var min = bytes[13];
|
|
||||||
var sen = bytes[14];
|
|
||||||
|
|
||||||
date = year+':'+Month+":"+day;
|
|
||||||
time = hour+":"+min+":"+sen;
|
|
||||||
|
|
||||||
|
|
||||||
if(latitude !== 0 && longitude !==0)
|
|
||||||
{
|
|
||||||
decode.Location=location
|
|
||||||
decode.Latitude=latitude
|
|
||||||
decode.Longitud=longitude
|
|
||||||
}
|
|
||||||
|
|
||||||
decode.Date=date
|
|
||||||
decode.Time=time
|
|
||||||
return {
|
|
||||||
data:decode,
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 7:
|
|
||||||
{
|
|
||||||
var decode = {};
|
|
||||||
alarm=(bytes[0] & 0x40)?"TRUE":"FALSE";//Alarm status
|
|
||||||
batV=(((bytes[0] & 0x3f) <<8) | bytes[1])/1000;//Battery,units:V
|
|
||||||
mod = bytes[2] & 0xC0;
|
|
||||||
led_updown=(bytes[2] & 0x20)?"ON":"OFF";//LED status for position,uplink and downlink
|
|
||||||
|
|
||||||
decode.BatV=batV
|
|
||||||
decode.ALARM_status=alarm
|
|
||||||
decode.MD=mod
|
|
||||||
decode.LON=led_updown
|
|
||||||
return {
|
|
||||||
data:decode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 8:
|
|
||||||
{
|
|
||||||
var decode = {};
|
|
||||||
con = "";
|
|
||||||
for(i = 0 ; i < 6 ; i++) {
|
|
||||||
con = bytes[i].toString();
|
|
||||||
str += String.fromCharCode(con);
|
|
||||||
}
|
|
||||||
var wifissid = str,
|
|
||||||
rssi = bytes[6]<<24>>24;
|
|
||||||
alarm=(bytes[7] & 0x40)?"TRUE":"FALSE";//Alarm status
|
|
||||||
batV=(((bytes[7] & 0x3f) <<8) | bytes[8])/1000;//Battery,units:V
|
|
||||||
mod = (bytes[9] & 0xC0)>>6;
|
|
||||||
led_updown=(bytes[9] & 0x20)?"ON":"OFF";//LED status for position,uplink and downlink
|
|
||||||
|
|
||||||
decode.WIFISSID=wifissid
|
|
||||||
decode.RSSI=rssi
|
|
||||||
decode.BatV=batV
|
|
||||||
decode.ALARM_status=alarm
|
|
||||||
decode.MD=mod
|
|
||||||
decode.LON=led_updown
|
|
||||||
return {
|
|
||||||
data:decode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
{
|
|
||||||
var decode = {};
|
|
||||||
if(bytes[0]==0x13)
|
|
||||||
sensor_mode="TrackerD";
|
|
||||||
else
|
|
||||||
sensor_mode="NULL";
|
|
||||||
|
|
||||||
if(bytes[4]==0xff)
|
|
||||||
sub_band="NULL";
|
|
||||||
else
|
|
||||||
sub_band=bytes[4];
|
|
||||||
|
|
||||||
if(bytes[3]==0x01)
|
|
||||||
freq_band="EU868";
|
|
||||||
else if(bytes[3]==0x02)
|
|
||||||
freq_band="US915";
|
|
||||||
else if(bytes[3]==0x03)
|
|
||||||
freq_band="IN865";
|
|
||||||
else if(bytes[3]==0x04)
|
|
||||||
freq_band="AU915";
|
|
||||||
else if(bytes[3]==0x05)
|
|
||||||
freq_band="KZ865";
|
|
||||||
else if(bytes[3]==0x06)
|
|
||||||
freq_band="RU864";
|
|
||||||
else if(bytes[3]==0x07)
|
|
||||||
freq_band="AS923";
|
|
||||||
else if(bytes[3]==0x08)
|
|
||||||
freq_band="AS923_1";
|
|
||||||
else if(bytes[3]==0x09)
|
|
||||||
freq_band="AS923_2";
|
|
||||||
else if(bytes[3]==0x0A)
|
|
||||||
freq_band="AS923_3";
|
|
||||||
else if(bytes[3]==0x0B)
|
|
||||||
freq_band="CN470";
|
|
||||||
else if(bytes[3]==0x0C)
|
|
||||||
freq_band="EU433";
|
|
||||||
else if(bytes[3]==0x0D)
|
|
||||||
freq_band="KR920";
|
|
||||||
else if(bytes[3]==0x0E)
|
|
||||||
freq_band="MA869";
|
|
||||||
|
|
||||||
firm_ver= (bytes[1]&0x0f)+'.'+(bytes[2]>>4&0x0f)+'.'+(bytes[2]&0x0f);
|
|
||||||
batV= (bytes[5]<<8 | bytes[6])/1000;
|
|
||||||
semsor_mod = (bytes[7]>>6)&0x3f;
|
|
||||||
gps_mod = (bytes[7]>>4)&0x03;
|
|
||||||
ble_mod = bytes[7]&0x0f;
|
|
||||||
panackmd = bytes[8]&0x04;
|
|
||||||
lon = ((bytes[8]>>1)&0x01)?"ON":"OFF";;
|
|
||||||
intwk = bytes[8]&0x01;
|
|
||||||
|
|
||||||
if(semsor_mod == 1)
|
|
||||||
sensor= "GPS";
|
|
||||||
else if(semsor_mod == 2)
|
|
||||||
sensor= "BLE";
|
|
||||||
else if(intwk == 1)
|
|
||||||
sensor= "Spots";
|
|
||||||
else if(semsor_mod == 3)
|
|
||||||
sensor= "BLE+GPS Hybrid";
|
|
||||||
|
|
||||||
decode.BatV=batV
|
|
||||||
decode.SENSOR_MODEL=sensor_mode
|
|
||||||
decode.FIRMWARE_VERSION=firm_ver
|
|
||||||
decode.FREQUENCY_BAND=freq_band
|
|
||||||
decode.SUB_BAND=sub_band
|
|
||||||
decode.SMODE=sensor
|
|
||||||
decode.GPS_M0D=gps_mod
|
|
||||||
decode.BLE_MD=ble_mod
|
|
||||||
decode.PNACKMD=pnackmd
|
|
||||||
decode.LON=lon
|
|
||||||
decode.Intwk=intwk
|
|
||||||
return {
|
|
||||||
data:decode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
{
|
|
||||||
var decode = {};
|
|
||||||
major = bytes[16] << 8 | bytes[17];
|
|
||||||
|
|
||||||
minor = bytes[18] << 8 | bytes[19]
|
|
||||||
|
|
||||||
power = bytes[15];
|
|
||||||
|
|
||||||
rssi = bytes[23]<<24>>24;
|
|
||||||
|
|
||||||
con = "";
|
|
||||||
for(i = 0 ; i < 16 ; i++) {
|
|
||||||
con += bytes[i].toString(16);
|
|
||||||
}
|
|
||||||
value = con;
|
|
||||||
var uuid = value;
|
|
||||||
alarm=(bytes[24] & 0x40)?"TRUE":"FALSE";//Alarm status
|
|
||||||
batV=(((bytes[24] & 0x3f) <<8) | bytes[25])/1000;//Battery,units:V
|
|
||||||
mod = (bytes[26] & 0xC0)>>6;
|
|
||||||
led_updown=(bytes[26] & 0x20)?"ON":"OFF";//LED status for position,uplink and downlink
|
|
||||||
if(bytes[26] & 0xC0==0x40)
|
|
||||||
{
|
|
||||||
hum=(bytes[27]<<8 | bytes[28])/10;//hum,units: °
|
|
||||||
tem=(bytes[29]<<8 | bytes[30])/10; //tem,units: °
|
|
||||||
}
|
|
||||||
decode.BatV=batV
|
|
||||||
decode.ALARM_status=alarm
|
|
||||||
decode.MD=mod
|
|
||||||
decode.LON=led_updown
|
|
||||||
decode.UUID=uuid
|
|
||||||
decode.MAJOR=major
|
|
||||||
decode.MINOR=minor
|
|
||||||
decode.RSSI=rssi
|
|
||||||
decode.POWER=power
|
|
||||||
return {
|
|
||||||
data:decode,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,8 +4,7 @@ Easy LoRaWAN is an up-to-10km wireless platform to monitor and control smart far
|
||||||
* Wiki: https://github.com/IoTThinks/EasyLoRaWAN/wiki
|
* Wiki: https://github.com/IoTThinks/EasyLoRaWAN/wiki
|
||||||
* Facebook channel: https://www.facebook.com/groups/iotthinks
|
* Facebook channel: https://www.facebook.com/groups/iotthinks
|
||||||
|
|
||||||
## DIY Guides
|
## EU-433
|
||||||
### EU-433
|
|
||||||
To run in 1 channel at 433.175Mhz, SF9
|
To run in 1 channel at 433.175Mhz, SF9
|
||||||
* Instruction: https://iotthinks.com/tag/eu433
|
* Instruction: https://iotthinks.com/tag/eu433
|
||||||
* LoRaWAN Server: https://iotthinks.com/easylorawan-cloud
|
* LoRaWAN Server: https://iotthinks.com/easylorawan-cloud
|
||||||
|
@ -14,7 +13,7 @@ To run in 1 channel at 433.175Mhz, SF9
|
||||||
* Modified library from https://github.com/matthijskooijman/arduino-lmic: arduino-lmic-master.zip
|
* Modified library from https://github.com/matthijskooijman/arduino-lmic: arduino-lmic-master.zip
|
||||||
* Extra required libraries: lib.zip
|
* Extra required libraries: lib.zip
|
||||||
|
|
||||||
### AS-923-2 (Vietnam)
|
## AS-923-2 (Vietnam)
|
||||||
To run at 8 channels in 920-923Mhz
|
To run at 8 channels in 920-923Mhz
|
||||||
* Instruction: Coming soon on https://iotthinks.com/guides
|
* Instruction: Coming soon on https://iotthinks.com/guides
|
||||||
* LoRaWAN Server: https://iotthinks.com/easylorawan-cloud
|
* LoRaWAN Server: https://iotthinks.com/easylorawan-cloud
|
||||||
|
|
Loading…
Reference in New Issue