LogoLogo
  • KPN THINGS USER GUIDE
    • Introduction
    • Getting started
      • Registration and setup
      • Device simulator app
      • Connect devices
        • SIM cards
        • Supported devices and KPN Devices
        • SODAQ R412M
        • Smartrak
        • Marvin development board
        • LoPy5
        • Arduino MKR WAN 1300/1310
        • Arduin MKR NB 1500
    • All videos
    • Tutorials
      • Configure a flow
      • Connect a HTTPs destination
      • Create a simple IoT web applicationPage
      • Send instruction to LoRa DevicePage
      • Send your data to Azure SQL
      • Technical overview
        • Management data model
        • Uplink communication
        • Downlink communication
        • Location data
      • Accounts and projects
        • Customer accounts and users
        • Projects
        • Customer management
        • Cost overview and contract
    • Frequently asked
      • Multi Factor Authentication
  • GENERAL FUNCTIONS
    • Quick reference videos
    • APIs
  • THE PORTAL EXPLAINED
    • Things Manager
      • Devices
        • Bulk operations
      • Data
        • Device data graph
      • Connectivity
        • LoRa connectivity configuration
      • Bulk reports
    • Things Creator
    • Support
      • News
      • Release notes
      • Real-time status
      • Service reports
      • Documents
      • Support tickets
      • Invoices
      • Contact info
    • Shop
  • BUILDING BLOCKS
    • Devices
      • Sensors
        • KPN Conditionsensor CO2 II
        • KPN Conditionsensor CO2 III
        • KPN Conditionsensor CO2 III motionPage 1
        • KPN FillTag I
        • KPN FillTag II
        • 1M2M ED1608
        • Elsys ERS
        • Device Simulator (Mobile Phone app)
        • Generic Device (Internet connected)
        • Generic LoRa device (preset connectivity)
        • Generic LoRa device (programmable)
        • Generic M2M device
        • Generic M2M device (with Internet connection)
      • Trackers
        • KPN Global Tracker Autonomous
        • KPN Global Tracker Wired
        • KPN LocationTag I
        • KPN LocationTag II
        • KPN LocationTag II v2
        • KPN LocationTag II v2 Expert Mode
        • KPN LocationTag II v3
        • KPN LocationTag III (with GPS)
        • KPN LocationTag III (without GPS)
        • KPN LocationTag III v2
        • KPN LocationTag III v2 Buffer
        • KPN LocationTag III v3
        • KPN LocationTag III v4
        • KPN LocationTag V
        • KPN LocationTag VI
        • KPN LocationTag WS
        • Streamline LoRa
        • Streamline M2M
        • Viloc
      • Routers
      • Gateways
        • KPN FSK Basestation
      • Device SDK
    • Connectivity
      • Connecting LoRa devices
        • LoRa connectivity configuration
      • Connecting M2M devices
      • Connecting Internet devices
      • Connecting MQTT Devices
    • Data Processing
      • ThingsML and SenML
        • ThingsML
        • SenML
          • Understanding and Interpreting SenML Data
          • Changes in KPN SenML
      • Device Twin
      • Decoders and encoders
        • Common measurements list
        • Decoder migrations
        • DIY Decoder
          • DIY decoder scripts
      • Merger
      • Device data
      • Devices
    • Destinations
      • HTTPS destination
      • MQTT broker
      • Cumulocity IoT Platform
      • Azure Event Hubs
      • Azure IoT Hub
      • Test Endpoint
      • ThingsBoard
      • Datacake
      • AWS Lambda
      • Google Cloud Run functions
  • IOT LINE UP
    • Freemium
      • Test SIM cards
    • Explorer
    • Modular
    • Tailored
    • Terms and Conditions
Powered by GitBook
On this page
  • How it works
  • Step by step guide

Was this helpful?

Export as PDF
  1. BUILDING BLOCKS
  2. Data Processing
  3. Decoders and encoders

DIY Decoder

PreviousDecoder migrationsNextDIY decoder scripts

Last updated 3 months ago

Was this helpful?

© 2024 KPN - All rights reserved.

DIY Decoders is a Things Creator feature that allows you to provide your own decoder script to decode messages from your devices on the KPN Things platform. To be able to create your own decoder, you'll first need to have access to Things Creator. If you don't see the Things Creator option in the top-level menu, please request Things Creator access from the administrator of your organisation.

DIY decoders are supported for your own device types that you've created in Things Creator. Once you've created a custom device type, you can create a new decoder for it and specify the decoding script that should be used to decode device messages. The decoding script should be written in JavaScript. See for a more detailed description and some example scripts.

How it works

To be able to create a DIY decoder, you will need a DIY decoder supported device type. This may be achieved by creating a custom device type for your device(s). See how to for more information.

A step by step walk-through is presented in the next section which guides through the creation of a DIY decoder.

Step by step guide

In this section a DIY decoder with a script is created step by step. Important sections on the images are indicated with either a red square or a red number.

Step 1. Overview page

The above image presents the overview page of the KPN Things portal. DIY decoders can be created in the Things Creator section of the portal.

Step 2. Creator page

On the Things Creator page, clicking the All Decoders menu item in the side bar will bring us to the page where we can initiate the creation of a new DIY decoder.

Step 3. Add decoder button

Clicking the Add new Decoder button brings us to the DIY decoder creation page.

Step 4. Add decoder form

The DIY decoder creation page expects a few details to be filled in:

  1. Name - the name of the decoder (required)

  2. Description - description describing the purpose of the decoder (optional)

  3. Device Type - the device type that this decoder will be linked to (required)

  4. Buttons - to either submit the new DIY decoder or to cancel the process.

Step 5. Created decoder details

The decoder overview screen will be presented when a DIY decoder has been created. A few things are visible here:

  1. The details of the decoder that we have just created.

  2. The button to create the script for the decoder.

  3. The edit button to edit the decoder details.

  4. The delete button that deletes this decoder. A pop-up asks for a confirmation first.

Step 6. New decoder script

When creating a script for a DIY decoder, the page with a script editor and tester is presented.

  1. Script Editor

Initially, we do not provide a rich code editor in the KPN 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 KPN Things portal.

  1. Script Tester

It is safe to trial-and-error within the tester as it does not touch or involve anything from outside of the isolated test environment.

The script tester provides a few options:

  • Payload data - the type of payload data that the device type supports. The drop-down list will contain every supported payload data to choose from.

  • Message detail - whether only the payload or the entire uplink message should be displayed in the text field below. The message data is editable.

  • Test button - executes the test with the script that is currently present in the editor and the message data. The tester always uses the full uplink message data, no matter which message detail is selected.

  • Output window - presents the result of the test execution.

Errors

Output window:

Script errors - when an error is thrown in the script itself. A warning toast will also pop-up at the top center of the page stating that the script did not execute successfully.

JavaScript errors (ReferenceError, SyntaxError, TypeError…) - when a JavaScript error occurs. The accompanying error message is also present for clarity what went wrong.

Log window:

Output is not valid SenML - when the output contains invalid SenML records. Output will still be displayed in the output window.

SenML processing errors - when a SenML specific error occurs.

Step 7. Decoder ready

Now the decoder creation process is finished. After activating your DIY decoder in a flow, all messages from your devices that are part of that flow and have a device type supported by the DIY decoder, are decoded by your own DIY Decoder and sent to all destinations configured for that flow.

Your custom device types will also appear in the drop-down list. See how to for more information.

The script editor automatically contains a working default script for the supported payload data, for LoRa - Hex in this case. The script may of course be customized or fully replaced, but it has to adhere to the .

For more default scripts for various payload types, please see .

The script tester tests the script from the editor in combination with the provided message data provided in the tester window. This is done in an isolated environment. The result of the test execution is shown in the Output window and script logs are displayed in the Log window. Errors that may occur, will be displayed in both .

Log window - custom script logs or various will appear in this window.Comment

add a new device type
script code rules
this page
Output and Log windows
error messages
DIY decoder scripts
add a new device type