Documentation (Beta)
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

Decoder v2

Custom v2 Decoder comply with LoRaWAN Codec API + provide user with control over the payload format sent to the Application Server.

To decode uplinks, user must implement the JavaScript function decodeUplink that is described below.

Example:

    function decodeUplink(input) {

        if (input.recvTime instanceof Date) {
            // date operations
            ...
        }
        
        ... 
        
        return {
            "data": {},
            "errors": [],
            "warnings": [],
            "tektelicMetadata": input.tektelicMetadata
        };
    }

Input object

  • bytes - int[] - UL payload byte array, each byte represented by integer in range 0-255
  • fPort - int - LoRaWAN fPort
  • recvTime - Date - UL message timestamp recorded by the LoRaWAN NS as a JavaScript Date object. Before using in the converter, a type check is needed.
  • tektelicMetadata - Object - proprietary Tektelic field containing UL metadata (example below)

Output object

  • data - JavaScript object representing the decoded payload
  • errors - string[] - a list of error messages while decoding the provided payload
  • warnings - string[] - a list of warning messages that do not prevent decoding the payload

Tektelic Metadata object

tektelicMetadata contains metadata in the following format:

{
    // Application Data
    "applicationId": "f8c1b0e0-da68-11ec-9f49-f7efa75f53dd",
    "applicationName": "Application Name",

    // Device Data
    "deviceEui": "647FDA0300004AAB",
    "deviceName": "Device Name"
    "deviceClass": "A",
    "deviceModelId": "f8c1b0e0-da68-11ec-9f49-f7efa75f53dd",
    "deviceModelName": "Tektelic Home Sensor",
    
    // Device Payload
    "ackBit": true,

    // Application Server API UL Metadata
    "fPort": 10,
    "adrBit": true,
    "fCntUp": 142,
    "fCntDown": 42,
    "recvTime": 1345291148,
    "devAddr": "076d51cf",
    "confirmed": true,
    "dataRate": 7,
    "uLFreq": 866100000,
    "margin": -32,
    "battery": 20,
    "devStatusTimeMillis": 1662382555000,
    "rfRegion": "US902",
    "gatewayCount": 1,
    
    // Gateway data:
    "gatewayRxInfo": [
        {
             // Application Server API GW Metadata
            "gwEui": "647FDAFFFE00CCCB",
            "antennaId": 0,
            "rssi": -100,  
            "snr": 9.5,
            "lat": 123.0,
            "lon": 123.0,
            "alt": 10.0,
            
            // Gateway Metadata
            "gatewayName": "Gateway Name",
            "channel": 0,
            "codeRate": "4/5",
            "crcStatus": 1,
            "dataRate": {
                "modulation": "LORA",
                "spreadFactor": 10,
                "bandwidth": 125
            },
            "gwTimeUtcMillis": 1558015672000,
            "gwTimeGpsMillis": 1242050890000,
            "rsig": null
        }
    ]
}
Application Data
  • applicationId - UUID - Application Identifier on Tektelic NS
  • applicationName - String - Application Name (specified by User)
Device Data
  • deviceEui - String - Device EUI
  • deviceName - String - Device Name (specified by User)
  • deviceClass - String - Device LoRaWAN Class (A, B or C)
  • deviceModelId - UUID - Device Model Identifier on Tektelic NS
  • deviceModelName - String - Device Model Name (specified by User)
Device Payload
  • ackBit - Boolean - ACK bit of FCtl sent by device in the UL
Application Server API UL Metadata

These fields are described in the LoRaWAN Backend Interfaces specification.

  • fPort - Integer - Uplink frame port
  • adrBit - Boolean - ADR bit sent by device in the UL
  • fCntUp - Integer - UL frame counter
  • fCntDown - Integer - DL frame counter
  • recvTime - GPS Seconds - The moment NS received the UL
  • devAddr - 4 bytes HEX String - Activation Device Address
  • confirmed - Boolean - Set to True if MType is Confirmed Data Up, False otherwise
  • dataRate - Integer - Data Rate represented as integer, (e.g. 7)
  • uLFreq - Floating point, MHz - Transmission frequency of the UL packet
  • margin - Integer, negative - Margin value from DevStatusAns MAC command
  • battery - Integer - Battery value from DevStatusAns MAC command
  • devStatusTimeMillis - UNIX epoch Milliseconds - Timestamp of the last DevStatusAns
  • rfRegion - String - RfRegion of the GW with highest signal, (e.g. US902)
  • gatewayCount - Integer - Number of Gateways that received the same UL packet within a pre-configured timeout period
Application Server API GW Metadata

These fields are described in the LoRaWAN Backend Interfaces specification.

  • gwEui - String - GW identifier (also known as GW EUI or MAC)
  • antennaId - Integer - Identifier of antenna which received the signal
  • rssi - Integer, negative - Received signal strength indication
  • snr - Double - Signal-to-noise ratio
  • lat - Double, nullable - Latitude of the GW/antenna
  • lon - Double, nullable - Longitude of the GW/antenna
  • alt - Double, nullable - Altitude of the GW/antenna
Gateway Metadata
  • gatewayName - String - Gateway name (specified by User)
  • channel - Integer - Channel number
  • codeRate - String - Describes the ratio of actual data to error-correcting data added (e.g. “4/5”)
  • crcStatus - Interger, 0/1 - Cyclic redundancy check (message integrity validation)
  • dataRate.modulation - String - Always “LORA”
  • dataRate.spreadFactor - Integer - Spreading Factor (7-12)
  • dataRate.bandwidth - Integer, 125/250/500 - Bandwidth in kHz
  • gwTimeUtcMillis - Integer, nullable - A moment message is received by GW in UTC Epoch millis
  • gwTimeGpsMillis - Integer, nullable - A moment message is received by GW in GPS Epoch millis
  • rsig - Array, nullable. Contains an array of objects with such fields: antenna, channel, snr, rssi.

Final UL payload

The final UL payload received by the Application Server is a JSON containing merged output.data and output.tektelicMetadata contents:

{
    // output.data:
    "humidity": 10,
    "temperature": 24,
    "motion": false,
    
    // output.tektelicMetadata:
    "applicationId": "f8c1b0e0-da68-11ec-9f49-f7efa75f53dd",
    "applicationName": "Application Name",
    "deviceEui": "647FDA0300004AAB",
    "deviceName": "Device Name"
}

User defines message format received by Application Server by customizing the payload output.data and output.tektelicMetadata fields (e.g. leaving only necessary data, creating nested structure, etc.)

  • bytes - int[] - DL payload byte array, each byte represented by integer in range 0-255
  • errors - string[] - list of error messages while encoding the provided payload
  • warnings - string[] - list of warning messages that do not prevent encoding the payload