Last updated
Last updated
Uplink decoders are used to decode or "translate" a device-specific payload into a human-readable JSON object (e.g. HEX -> JSON object).
An uplink decoder script has to implement the function consume(object)
which takes an event
object as argument. An error will be returned if the script doesn't implement a consume(event)
function.
The consume(event)
function is the entry point for the script and will be invoked upon execution. Each execution loads the script again, resetting any variable values which were set in previous runs.
The uplink event object differs slightly based on connectivity but share the same base structure. Every event contains the following structure:
The data
object contains everything which was sent in the request body of the uplink request.
The contents of the uplinkMetrics
object differs depending on the network provider.
When processing an array uplink, the structure is slighly different to other events. The data
object contains a single property values
which contains the original array sent in the uplink.
A raw LoRaWAN uplink that invokes an uplink decoder script (Custom Device Type), looks as follows:
A raw MQTT uplink that invokes an uplink decoder script (Custom Device Type), looks as follows: