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
};
}
bytes
- int[] - UL payload byte array, each byte represented by integer in range 0-255fPort
- int - LoRaWAN fPortrecvTime
- 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)
data
- JavaScript object representing the decoded payloaderrors
- string[] - a list of error messages while decoding the provided payloadwarnings
- string[] - a list of warning messages that do not prevent decoding the payload
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
}
]
}
applicationId
- UUID - Application Identifier on Tektelic NSapplicationName
- String - Application Name (specified by User)
deviceEui
- String - Device EUIdeviceName
- String - Device Name (specified by User)deviceClass
- String - Device LoRaWAN Class (A, B or C)deviceModelId
- UUID - Device Model Identifier on Tektelic NSdeviceModelName
- String - Device Model Name (specified by User)
ackBit
- Boolean - ACK bit of FCtl sent by device in the UL
These fields are described in the LoRaWAN Backend Interfaces specification.
fPort
- Integer - Uplink frame portadrBit
- Boolean - ADR bit sent by device in the ULfCntUp
- Integer - UL frame counterfCntDown
- Integer - DL frame counterrecvTime
- GPS Seconds - The moment NS received the ULdevAddr
- 4 bytes HEX String - Activation Device Addressconfirmed
- Boolean - Set to True if MType is Confirmed Data Up, False otherwisedataRate
- Integer - Data Rate represented as integer, (e.g. 7)uLFreq
- Floating point, MHz - Transmission frequency of the UL packetmargin
- Integer, negative - Margin value fromDevStatusAns
MAC commandbattery
- Integer - Battery value fromDevStatusAns
MAC commanddevStatusTimeMillis
- UNIX epoch Milliseconds - Timestamp of the lastDevStatusAns
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
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 signalrssi
- Integer, negative - Received signal strength indicationsnr
- Double - Signal-to-noise ratiolat
- Double, nullable - Latitude of the GW/antennalon
- Double, nullable - Longitude of the GW/antennaalt
- Double, nullable - Altitude of the GW/antenna
gatewayName
- String - Gateway name (specified by User)channel
- Integer - Channel numbercodeRate
- 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 kHzgwTimeUtcMillis
- Integer, nullable - A moment message is received by GW in UTC Epoch millisgwTimeGpsMillis
- Integer, nullable - A moment message is received by GW in GPS Epoch millisrsig
- Array, nullable. Contains an array of objects with such fields: antenna, channel, snr, rssi.
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-255errors
- string[] - list of error messages while encoding the provided payloadwarnings
- string[] - list of warning messages that do not prevent encoding the payload