Decoding is the first phase in data processing in uplink communication. In this phase incoming data is normalized into SenML and additional (meta)data is enabled if applicable.
A regular data decoder transforms incoming payload into measurements in SenML, following the data protocol of the specific device.
ThingsML is a generic LoRa payload format, allowing you to send multiple measurements encoded in your payload in a compact way. Learn more about the ThingsML for Lora data protocol.
With additional data (decoders), metadata corresponding to the message received is enabled.
Add LoRa Geolocation data to messages where location could be calculated.
SenML record name
Content
locOrigin
vs: "KPNLORA"
Indicating that the location information in
the SenML record comes from the LoRa network.
latitude
v
The latitude of the location in decimal notation.
u: "lat"
longitude
v
The longitude of the location in decimal notation.
u: "lon"
radius
v
The theoretical inaccuracy of the calculated location. Can
be used to visualize a circle around the location on a map.
u: "m"
In meters.
To extend the reach of our LoRa network on your location, we offer LoRa On Premise Gateways. A LoRa On Premise Gateway is an extension of our regular LoRa network. They have a smaller reach than our regular outdoor gateways, but you can position it for example in your warehouse to guarantee coverage for your LoRa devices.
Additionally, in KPN Things we have integrated the LoRa On Premises Gateway with our localisation service. When you enable Location by LoRa On Premises Gateway reception, KPN Things will detect when data from your device is received by one of your On Premise Gateways. Then KPN Things will add the administrative location of that gateway to the message. That way, the application can use that data to locate the device at the moment the message was sent.
To get this to work, you need to register your On Premise Gateways in your KPN Things account through the KPN Things API's by giving the gateway ID and the coordinates of the location you have positioned the gateway.
With no-decoders incoming data is not interpreted, it is only put into SenML.
SenML record name
Content
payload
vs
The received payload in hexadecimal notation
(example: 010203
).
port
v
The application port the data was received on.
If your device uses the SenML data format to send data to KPN Things, the data will be accepted as is, without further decoding.
🔜 Coming soon
This feature is currently in active development. This page has been created to give you a sneak preview of this awesome feature. We expect to release it January 2025.
This page describes the current design of the DIY Decoder functionality. The final version of this feature could differ from what is described below.
With a DIY Decoder, you can provide your own code snippet used to decode messages from your LoRa devices on the KPN Things platform. The code snippet should be written in JavaScript. See DIY decoder scripts for the details.
Initially, DIY decoders are only supported for "Own LoRa" devices. Once you have linked your "Own LoRa" device to a Flow, you can add and edit DIY decoders on the Data Procession page for that Flow.
Initially we do not provide a rich code editor in the Things Portal. We suggest you write the code snippet in the editor of your choice and paste the content in the script field of the DIY decoder edit page in Things Portal.
After activating your DIY decoder in a flow, all messages from your "Own LoRa" devices that are part of that flow, are decoded by your own DIY Decoder and sent to all destinations configured for that flow.
A test routine for your DIY Decoder will be provided later.
Currently, we are working on improving our decoders. Some older decoders on our platform contain some bugs and output SenML that is not in line with the SenML RFC specification. Besides improving the output, we are also updating the decoders from a technical perspective. This will provide the basis for the 'DIY-decoder' feature that will be available in the future. This document will give you information on what will change and how it might affect you and how you can use these new decoders.
For all the relevant decoders, a new version is available in the KPN Things Portal. All these new versions have some common changes to improve the SenML output.
String values should not have a unit
Wherever the time origin was set as {"n": "TIME_ORIGIN", "vs": "THINGSENGINE"}
it is now set as { "n": "timeOrigin", "vs": "NETWORK" }
Time values (t
and bt
) are more precise and may contain decimal places.
Valueless 'base records' have been removed and base values are now correctly set on the first real record of the SenML pack.
LoRa Geolocation
and Location by LoRa On Premises Gateway
data decoding is included by all new LoRa decoders, thus you do not need to use specific extra decoders to receive this data.
With the previous decoder versions, you would typically see SenML as illustrated below:
Whereas the new version would output SenML like:
For more information on how to interpret and parse SenML data please visit this page.
Besides general changes, some decoders may have some specific changes as well, like bug fixes. To see what has changed for a specific decoder, you can head over to the device type page and choose your device type. Here you can find the documentation for its decoders and examples of their output.
When you head over to the decoder configuration of your flow, you will see that a new version is available. To use the new version, just press the toggle. Don't forget to disable the previous version, otherwise you might receive your data twice, since it will be decoder with both the old and the new version.
Note that if you use
+ LoRa Geolocation data
or+ Location by LoRa On Premises Gateway reception
decoders, this functionality is also a part of the new version of your LoRa decoder. To make sure you do not receive duplicate location data you should disable these as well.
If you want to test if you can process the improved payloads without impacting your current flow, you can configure a new flow, using the new version of the decoder.
Please ensure your solution is compatible with the updated decoder version, as the old versions will be retired from the 9th of December 2024.
DIY decoders scripts are responsible for converting the data sent by your device into the format required by KPN Things. The data sent by your device and some other metadata is provided as a stringified JSON structure to your script.
The provided JavaScript snippet that is being executed must have a main function that is called with a single string as input and it should return a single string or null
. The string should be a SenML pack as JSON. Returning null
signifies that the messages should not be processed further.
The input parameter string contains all the input data in JSON format. See for the structure of the JSON found in the input data.
Below a simple example is given for a script decoding LoRa / Actility messages.
The snippet below describes the structure of the ScriptInput
parameter provided to the DIY Decoder function.
See also:
In ThingsML there is a measurement index list, allowing you to send only the index for a measurement instead of the full name and unit which is required in SenML.
If you don't use ThingsML, it is still best practice to use the common measurement names and units in your solution. With this you achieve higher compatibility with current and future data processing features in KPN Things.
ThingsML measurement index
ID (unique)
SenML Name
SenML Unit
-24
TEMPERATURE
temperature
Cel
-23
HUMIDITY
humidity
%RH
-22
LATITUDE
latitude
lat
-21
LONGITUDE
longitude
lon
-20
ALTITUDE
altitude
m
-19
POWER
power
W
-18
PRESSURE
pressure
Pa
-17
ANGLE
angle
rad
-16
LENGTH
length
m
-15
BREADTH
breadth
m
-14
HEIGHT
height
m
-13
WEIGHT
weight
kg
-12
THICKNESS
thickness
m
-11
DISTANCE
distance
m
-10
AREA
area
m2
-9
VOLUME
volume
m3
-8
VELOCITY
velocity
m/s
-7
ELECTRIC_CURRENT
electricCurrent
A
-6
ELECTRIC_POTENTIAL
electricPotential
V
-5
ELECTRIC_RESISTANCE
electricResistance
Ohm
-4
ILLUMINANCE
illuminance
lx
-3
ACCELERATION_X
accelerationX
m/s2
-2
ACCELERATION_Y
accelerationY
m/s2
-1
ACCELERATION_Z
accelerationZ
m/s2
0
HEADING
heading
rad
1
CO_CONCENTRATION
COConcentration
ppm
2
CO2_CONCENTRATION
CO2Concentration
ppm
3
SOUND
sound
dB
4
FREQUENCY
frequency
Hz
5
BATTERY_LEVEL
batteryLevel
%EL
6
BATTERY_VOLTAGE
batteryVoltage
V
7
RADIUS
radius
m
8
BATTERY_LEVEL_LOW
batteryLevelLow
boolean
9
COMPASS_X
compassX
T
10
COMPASS_Y
compassY
T
11
COMPASS_Z
compassZ
T
12
READ_SWITCH
readSwitch
/
13
PRESENCE
presence
boolean
14
COUNTER
counter
/