EasyLoRaWAN/Codec
IoTThinks.com c503bd1e0c
Create Dragino-RS485-BL-PM.js
Codec for Dragino RS485-BL and RS485 PM 1.0/2.5/10 sensor
2023-12-02 12:22:22 +07:00
..
Dragino-LAQ4.js Rename Dragino-LAQ4.txt to Dragino-LAQ4.js 2023-06-07 16:38:00 +07:00
Dragino-LGT92.js Rename Dragino-LGT92.txt to Dragino-LGT92.js 2023-06-07 16:39:43 +07:00
Dragino-LSN50v2-S31.js Update Dragino-LSN50v2-S31.js 2023-12-02 12:13:35 +07:00
Dragino-LSN50v2.js Rename Dragino-LSN50v2.txt to Dragino-LSN50v2.js 2023-06-07 16:39:55 +07:00
Dragino-LT-22222-L.js Rename Dragino-LT-22222-L.txt to Dragino-LT-22222-L.js 2023-06-07 16:40:58 +07:00
Dragino-RS485-BL-7in1-Soil-Sensor.js Rename Dragino-RS485-BL-7in1-Soil-Sensor.txt to Dragino-RS485-BL-7in1-Soil-Sensor.js 2023-06-07 16:41:10 +07:00
Dragino-RS485-BL-PM.js Create Dragino-RS485-BL-PM.js 2023-12-02 12:22:22 +07:00
Dragino-RS485-BL.js Rename Dragino-RS485-BL.txt to Dragino-RS485-BL.js 2023-06-07 16:41:22 +07:00
Dragino-RS485-LN.js Rename Dragino-RS485-LN.txt to Dragino-RS485-LN.js 2023-06-07 16:41:36 +07:00
Dragino-TrackerD.js Removed GPS(0,0) 2023-06-29 11:45:47 +07:00
RAK2171-TrackIt.js Support Easy LoRaWAN Cloud 2023-06-07 17:00:45 +07:00
README.md Update README.md 2023-06-07 19:18:38 +07:00

README.md

Compatible codecs for Easy LoRaWAN Cloud

The codecs will be used in this guide: https://iotthinks.com/add-a-lorawan-device-in-to-easy-lorawan-cloud/

  • The codecs in this folder is COMFIRMED to work with Easy LoRaWAN Cloud

The below sample codecs are COMPATIBLE with Easy LoRaWAN Cloud.

Codec Format

A valid codec for Easy LoRaWAN Cloud is below:

// 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) {
  var bytes = input.bytes;
  
  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 Temp = (bytes[3] << 8 | bytes[4]) / 10;
  var Humid = (bytes[5] << 8 | bytes[6]) / 10;
  
  return {"data": {"BatV":BatV, "PayVER":PayVER, "Temp":Temp, "Humid":Humid}};
}

// 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: []};
}

Conversion of Codec Formats

If you have a codec for ChirpStack v3, you need to put the below wrapper function to convert a codec to ChirpStack v4. Easy LoRaWAN uses ChirpStack v4

// V3
function Decode(fPort, bytes, variables) {
   ...
}

// Converter from ChirpStack v3 to ChirpStack v4 / Easy LoRaWAN Cloud
function decodeUplink(input) {
   // Wrapper function for ChirpStack v4
   return {
      data: Decode(input.fPort, input.bytes, input.variables)
   };
}