Giter VIP home page Giter VIP logo

dragino-end-node-decoder's People

Contributors

dragino avatar jinggengbei avatar kazike99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dragino-end-node-decoder's Issues

Decoders for Chirpstack v4

Current decode payloads for Chirpstack only work for v3, changes in Chirpstack v4 cause examples to fail due to new func signature changes referenced here. For example a quick fix to LDS02 was to prepend the following:

function decodeUplink(input) {
    var sensor_data = Decode(input.fPort, input.bytes);
    return {data: sensor_data};
  }

// Existing Chirpstack v3 decoder example below...
function Decode(fPort, bytes) {
    ...

GPS values when not establish connections with GPS providers

Valid values for Longitude is +/- 180, Latitude range is +/-90.
The payload decoder delivers a "0" for Longitude and Latitude , when there is no connection with GPS providers.
But: this is a valid location in the near of Libreville (Africa). The decoder has to deliver a value out of range, e.g. 255 for Longitude and 128 for Latitude.
So can detected that the GPS-values are invalid data.

LT-22222-L Chirpstack V4 decoder

function decodeUplink(input) {
    //LT33222-L or LT22222-L Decode
        if(input.fPort==0x02)
      {  
        var hardware= (input.bytes[10] & 0xC0)>>6;
        var mode0= input.bytes[10] & 0xff;
        var mode= input.bytes[10] & 0x3f;
        var decode = {};
        
        if(hardware=='0')
        {
          decode.Hardware_mode="LT33222";
          decode.DO3_status=(input.bytes[8] &0x04)? "L":"H";
          if(mode0=='1')
          {
              decode.DI3_status= (input.bytes[8] &0x20)?"H":"L"; 
          }
        }
        else if(hardware=='1')
        {
          decode.Hardware_mode= "LT22222";
        }
        
        if(mode!=6)
        {
          decode.DO1_status= (input.bytes[8] &0x01)? "L":"H";
          decode.DO2_status= (input.bytes[8] &0x02)? "L":"H";
          decode.RO1_status= (input.bytes[8] &0x80)? "ON":"OFF";
          decode.RO2_status= (input.bytes[8] &0x40)? "ON":"OFF";
          if(mode!=1)
          {
            if(mode!=5)
            {
             decode.Count1_times= (input.bytes[0]<<24 | input.bytes[1]<<16 | input.bytes[2]<<8 | input.bytes[3])>>>0;
            }
            decode.First_status= (input.bytes[8] &0x20)? "Yes":"No";
          }
        }
        
        if(mode=='1')
        {
          
          decode.Work_mode= "2ACI+2AVI";
          decode.AVI1_V= parseFloat(((input.bytes[0]<<24>>16 | input.bytes[1])/1000).toFixed(3));
          decode.AVI2_V= parseFloat(((input.bytes[2]<<24>>16 | input.bytes[3])/1000).toFixed(3));
          decode.ACI1_mA= parseFloat(((input.bytes[4]<<24>>16 | input.bytes[5])/1000).toFixed(3));
          decode.ACI2_mA= parseFloat(((input.bytes[6]<<24>>16 | input.bytes[7])/1000).toFixed(3));
          decode.DI1_status= (input.bytes[8] &0x08)? "H":"L";
          decode.DI2_status= (input.bytes[8] &0x10)? "H":"L";
   
        }
        else if(mode=='2')
        {
          decode.Work_mode= "Count mode 1";
          decode.Count2_times= (input.bytes[4]<<24 | input.bytes[5]<<16 | input.bytes[6]<<8 | input.bytes[7]) >>>0;
        }
        else if(mode=='3')
        {
          decode.Work_mode= "2ACI+1Count";
          decode.ACI1_mA= parseFloat(((input.bytes[4]<<24>>16 | input.bytes[5])/1000).toFixed(3));
          decode.ACI2_mA= parseFloat(((input.bytes[6]<<24>>16 | input.bytes[7])/1000).toFixed(3));
        }
        else if(mode=='4')
        {
          decode.Work_mode= "Count mode 2";
          decode.Acount_times= (input.bytes[4]<<24 | input.bytes[5]<<16 | input.bytes[6]<<8 | input.bytes[7]) >>>0;
        }
        else if(mode=='5')
        {
          decode.Work_mode= " 1ACI+2AVI+1Count";
          decode.AVI1_V= parseFloat(((input.bytes[0]<<24>>16 | input.bytes[1])/1000).toFixed(3));
          decode.AVI2_V= parseFloat(((input.bytes[2]<<24>>16 | input.bytes[3])/1000).toFixed(3));
          decode.ACI1_mA= parseFloat(((input.bytes[4]<<24>>16 | input.bytes[5])/1000).toFixed(3));
          decode.Count1_times= bytes[6]<<8 | bytes[7];
        }
        else if(mode=='6')
        {
          decode.Work_mode= "Exit mode"; 
          decode.Mode_status= input.bytes[9] ? "True":"False";
          decode.AV1L_flag= (input.bytes[0] &0x80)? "True":"False";
          decode.AV1H_flag= (input.bytes[0] &0x40)? "True":"False";
          decode.AV2L_flag= (input.bytes[0] &0x20)? "True":"False";
          decode.AV2H_flag= (input.bytes[0] &0x10)? "True":"False";   
          decode.AC1L_flag= (input.bytes[0] &0x08)? "True":"False";
          decode.AC1H_flag= (input.bytes[0] &0x04)? "True":"False";
          decode.AC2L_flag= (input.bytes[0] &0x02)? "True":"False";
          decode.AC2H_flag= (input.bytes[0] &0x01)? "True":"False";   
          decode.AV1L_status= (input.bytes[1] &0x80)? "True":"False";
          decode.AV1H_status= (input.bytes[1] &0x40)? "True":"False";
          decode.AV2L_status= (input.bytes[1] &0x20)? "True":"False";
          decode.AV2H_status= (input.bytes[1] &0x10)? "True":"False";   
          decode.AC1L_status= (input.bytes[1] &0x08)? "True":"False";
          decode.AC1H_status= (input.bytes[1] &0x04)? "True":"False";
          decode.AC2L_status= (input.bytes[1] &0x02)? "True":"False";
          decode.AC2H_status= (input.bytes[1] &0x01)? "True":"False";   
          decode.DI2_status= (input.bytes[2] &0x08)? "True":"False";
          decode.DI2_flag= (input.bytes[2] &0x04)? "True":"False";
          decode.DI1_status= (input.bytes[2] &0x02)? "True":"False";
          decode.DI1_flag= (input.bytes[2] &0x01)? "True":"False";   
        }
        
        if(input.bytes.length!=1)
          return {
            data: decode
          };
      }
      
      else if(input.fPort==5)
      {
          var freq_band;
          var sub_band;
          
        if(input.bytes[0]==0x01)
            freq_band="EU868";
          else if(input.bytes[0]==0x02)
            freq_band="US915";
          else if(input.bytes[0]==0x03)
            freq_band="IN865";
          else if(input.bytes[0]==0x04)
            freq_band="AU915";
          else if(input.bytes[0]==0x05)
            freq_band="KZ865";
          else if(input.bytes[0]==0x06)
            freq_band="RU864";
          else if(input.bytes[0]==0x07)
            freq_band="AS923";
          else if(input.bytes[0]==0x08)
            freq_band="AS923_1";
          else if(input.bytes[0]==0x09)
            freq_band="AS923_2";
          else if(input.bytes[0]==0x0A)
            freq_band="AS923_3";
          else if(input.bytes[0]==0x0F)
            freq_band="AS923_4";
          else if(input.bytes[0]==0x0B)
            freq_band="CN470";
          else if(input.bytes[0]==0x0C)
            freq_band="EU433";
          else if(input.bytes[0]==0x0D)
            freq_band="KR920";
          else if(input.bytes[0]==0x0E)
            freq_band="MA869";
          
        if(input.bytes[1]==0xff)
          sub_band="NULL";
          else
          sub_band=input.bytes[1];
    
          var firm_ver= (input.bytes[2]&0x0f)+'.'+(input.bytes[3]>>4&0x0f)+'.'+(input.bytes[3]&0x0f);
          
          var tdc_time= input.bytes[4]<<16 | input.bytes[5]<<8 | input.bytes[6];
          
          decode.FIRMWARE_VERSION = firm_ver;
          decode.FREQUENCY_BAND = freq_band;
          decode.SUB_BAND = sub_band;
          decode.TDC_sec = tdc_time;
        return{
          data: decode
          };
      }
    }

Chripstack decoder V4

Copy and past the decoder in my chirpstack decoder for two Dragino sensor and I received error messaged.
applicationID:"28"
applicationName:"Dragino_Sensor"
deviceName:"TPM117"
devEUI:"a84041e83188144e"
type:"UPLINK_CODEC"
error:"execute js error: js vm error: (anonymous): Line 105:28 Unexpected token ) (and 238 more errors)"
fCnt:45

LHT65N External Sensor Data not Uploading (Chirpstack v4)

LHT65N Internal (Built-in) Temperature/Humidity Readings Upload to Datacake and post properly, but no data is detected when using the external probe (Sensor reading EXT-TempC_SHT).

External Temp Probe readings do post to
See below:
drag_0

Could you please check the Dragino End Decoder for Chirpstack V4 to ensure that the External Sensor settings is passed to the decoder?

Thanks\

PS LB Decoder water depth wrong calculation

On PS LB water level sensor, this formula causes all depts to be a 0 cm.
decode.Water_deep_cm= parseFloat(((decode.IDC_intput_mA-4.0)*(bytes[3]*100/16)).toFixed(3));
bytes[3] alwasy return as 0 and. I think during water level calculation this formula can be static value.

//5000 mm is the max distance the sensor can measure
maxSensorRange = 5000;
//Density of water is 1 ton/m3 (1000 kg/m3)
liquidDensity = 0.997;
//The "Current to Voltage" module can only move between 4mA to 20mA which gives it a resolution of 16mA.
maxSensorResolution = 16;
depthChangeStep = ((maxSensorRange / liquidDensity) / maxSensorResolution);
// dept can be measured as mm sensivity
decode.Water_deep_mm= parseFloat(((decode.IDC_intput_mA-4.0)*(depthChangeStep)).toFixed(3));

What is the expected value for bytes[3] ? Am I rigth to calculate like this _

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.