Downlinks

Datacake does not only allow you to write your own payload decoders but also has a very nice interface for writing and using custom Downlink Encoder.

  • On your LoRaWAN Device, navigate into the Downlinks Section using the Tab-Bar

  • Click on the "Add Downlink" Button

  • This will bring up the following Dialog:

Fill in the information:

Name

Provide a Name for your Downlink Encoder.

Description

Optionally provide a description that gives users some information about what the Downlink does.

Port

This is the Port (or F-Port) that the encoded data is send to on the LNS and forwarded to the device.

Payload Encoder

Here you can define the custom Payload Encoder for your Downlink. We will show you how this works in the next section:

An Encoder can be simple as this:

function Encoder(measurements, port) {
    
    // Return a byte array here
    return [0x23, 0x01, 0x23, 0x45];
}

Return Bytes as an Array

The Datacake Downlink Encoder expects your function to return data in form of a Byte-Array which is then translated into the data-format required for the selected LoRaWAN Server.

return [0x23, 0x01, 0x23, 0x45];

Access Measurement Fields

Datacake Downlink Encoders have access to fields from the Database of your Device. Simply chose the desired Field from a list in the Downlink Encoder Setup Dialog:

Configuration Variables

One use-case for Database Access could be using a Database Field to store device configuration variables, like:

  • Measurement Send Interval

In this case you can define a dynamic value before sending the downlink.

Access Field Data

The following code-snippet shows you how you access the database field from within your downlink encoders:

function Encoder(measurements, port) {
    var interval = measurements["CONFIG_SEND_INTERVAL"].value;
    return ...
}

To send a Downlink (or queue it on your LNS) navigate into the Downlink section of your Device using the Tab-Bar on the Device-View:

When your Downlink Encoder does not access measurement fields or require any configuration, it will be send out to your LoRaWAN Network Server immediately.

  • Click on the Button "Send Downlink" to queue the Downlink on your LNS

  • A confirmation notification will appear

When your Downlink Encoder has access to Database Fields you need to confirm before it will be send to your LoRaWAN Network server.

  • If you click on the button a dialog will appear

  • In this you find a text-input for every database field the Encoder has access to

  • This field is pre-set to the current value of the corresponding database field

  • You can overwrite this value and overwriting will result in storing the new value in the database

Please note that the database fields used in the Downlink Encoder are normal Database Fields. This means that overwriting them will result in triggering the actions linked to such a field, like:

  • Triggering a Message send out over MQTT

  • Triggering the Rule-Engine (you could create an E-Mail or SMS Alert if someone sets the wrong configuration value, etc.)

Debugging

Sending a Downlink will create an entry in the Debug-Console of your Device. To access the Debug-Console navigate to "Debug" using the Tab-Bar on the device-view:

  • If the Downlink was sent successfully, the following entry will appear in the Debug-Overview:

Last updated