Adeunis Dry Contacts Decoder/Encoder function

Hey there,

we’re having trouble with integrating the Adeunis Dry Contact sensors in our LoRaWAN plattform, because we can’t find a solution for decoding and encoding the payload of the device.

I’ve now tried for several days to implement the Codec library Adeunis provides (http://codec-adeunis.com/decoder), but i’m not into javascript development and had no success.

We’re using ThingsBoard for Data handling and visualization, but I also didn’t find a way to get the Decoding done.

If anyone has a Decoder and/or Encoder function for this device type the help would be highly appreciated.

Kind Regards,
Jonathan Maier

try to use Cayenne LPP codec in the device profile

Hey eugenev,

sadly that throws an error (error:“invalid data type: 160”) and just gives me the data as BASE64 Code:

  • data:“QKAAAAABAAAAAAQ=”
  • objectJSON:""

Any other suggestions ?

also try this http://codec-adeunis.com/download

Yes I tried to download the JavaScript library, but i couldn’t extract a JavaScript Decoder function, which I can copy in the Chirpstack Codec.
Sadly the library is very big and cmplex and i’m not that into programming that i could extract a single function out of it.

Hi,

Sorry to raise an old thread, but did you get this working?

Thanks

decoder codec for all adeunis

// v3 to v4 compatibility wrapper
function decodeUplink(input) {
	return {
		data: Decode(input.fPort, input.bytes, input.variables)
	};
}

function encodeDownlink(input) {
	return {
		bytes: Encode(input.fPort, input.data, input.variables)
	};
}

insert the contents of the "adeunis-codecs-lib-1.7.1\dist\lib.public.js" file between this 2 pieces of javascript code. this file can be retrieved from the archive of this link https://www.download.codec-adeunis.com/adeunis-codecs-lib-1.7.1.tgz

function base64tohex(bytes) {
    return bytes.map(function (byte) {
        return ("00" + (byte & 0xFF).toString(16)).slice(-2)
    }).join('')
}

function Decode(fPort, bytes) {
    var decoder = new codec.Decoder();

    // Select the wanted decoder:
    // * `analog` => 'Analog device'
    // * `breath` => 'Breath device'
    // * `comfort` => 'Comfort device'
    // * `comfort2` => 'Comfort 2 device'
    // * `comfortCo2` => 'Comfort CO2 device'
    // * `drycontacts` => 'Dry Contacts device'
    // * `drycontacts2` => 'Dry Contacts 2 device'
    // * `deltap` => 'Delta P device'
    // * `motion` => 'Motion device'
    // * `pulse` => 'Pulse device'
    // * `pulse3` => 'Pulse 3 device'
    // * `pulse4` => 'Pulse 4 device'
    // * `pulse4nbiot` => 'Pulse 4 NB-IoT device'
    // * `repeater` => 'Repeater device'
    // * `temp` => 'Temp device'
    // * `temp3` => 'Temp 3 device'
    // * `temp4` => 'Temp 4 device'
    // * `ticCbeLinkyMono` => 'TIC CBE/LINKY MONO device'
    // * `ticCbeLinkyTri` => 'TIC CBE/LINKY TRI device'
    // * `ticPmePmi` => 'TIC PME-PMI device'
    decoder.setDeviceType("drycontacts");

    return decoder.decode(base64tohex(bytes));
}