Datacake Docs
  • Welcome
  • Get Started
  • Changelog
  • Best practices
    • Best practices: Getting started
    • Best practices: Resolution (Timeframe)
    • Best practices: Dashboards
    • Best practices: Reports
    • Best practices: Grouping Devices
  • Datacake LNS
    • Getting Started
    • Gateways
      • Milesight LoRaWAN Gateway - UG6x
      • RAKwireless WisGate Edge Light 2
    • Devices
    • Add Devices without Gateway
  • Device
    • Product
    • Configuration
    • Claiming
    • Historical Data
    • Database
      • Configuration Fields
      • Fields
        • Manual input
        • Field Roles
        • Formulas
        • Mapping Fields
      • Data retention & Datapoints
      • Examples
        • Mapping 4-20mA Signals
        • Converting Units
  • Dashboards
    • Global Dashboards
      • Setting Homepage
    • Device Dashboards
    • Multi-Device Dashboards
    • Widgets
      • Value Widget
      • Chart Widget
      • Image Map
      • Map Widget
      • Text Widget
      • SOS Widget
      • Boolean Widget
      • iFrame Widget
      • Downlink Widget
      • Set Value Widget
      • Measurement List Widget
      • Heatmap Widget
      • Table Widget
      • Image Widget
  • Portal
    • Multi-Tenancy (Workspaces)
    • Reports
      • Energy Report
    • Administrators
    • Members
      • API Users
    • Security & Privacy
    • Billing
      • Support Packages
      • VAT Exemption / Tax ID
      • SMS Credits
      • Access Invoices
      • Unused time and Remaining time in Invoices (Prorations)
      • Codes
    • White Label
    • Rules
      • Legacy Rule Engine
        • Sending notifications via Telegram
      • New Rule Engine
        • Rule Engine Table Overview
        • Copy/Paste and Template Functionality
        • Advanced Rule Engine E-Mail and Webhook Templates
        • Time Restrictions
    • Zones
  • Cake Red
    • Get Started
    • Overview
  • LoRaWAN
    • Get Started
      • CSV Import
      • Custom LoRaWAN Device
    • Configuring LNS
      • The Things Stack (TTN / TTI) Automated Setup
      • The Things Stack (TTN / TTI) Manual Setup
      • Loriot
      • Kerlink Wanesy
      • Helium
      • ChirpStack
      • Tektelic
      • Actility ThingPark
      • Senet
      • Milesight Gateway
      • KPN
    • Downlinks (LoRaWAN)
      • Set Time Frame
    • Securing Webhooks
    • Payload Decoders
      • Location and GPS
      • Access Gateway Metadata
      • Access Measurements
      • Global Variables
    • Using Cayenne LPP
    • Converting Payload
  • Generic API Devices
    • HTTP Downlinks
  • Integrations
    • MQTT
    • Particle
      • Get Started
      • Adding Integrations
      • Decoding Payloads
      • Calling Functions
      • Templates
        • Particle Tracker One
    • Incoming Webhooks
    • Outgoing Webhooks
      • Securing Outgoing Webhooks in Datacake
    • Golioth
    • Blues Wireless Notecard
    • Sigfox
    • Swarm Asset Tracker
    • Grandcentrix Modbus Cloud Connect
    • YuDash LYNX IoT Gateway
    • Dragino NB-IoT
      • Changing NB-IoT Bands
    • Hardwario CHESTER
    • 1NCE OS
  • API
    • Exporting Data
    • Record Measurements via API
    • Node RED to Datacake
    • Generate Access Token
    • Internal MQTT
      • Get Started
      • MQTT Documentation
      • MQTT over WebSocket
      • Example Code
    • GraphQL API
      • Using GraphQL
      • Device Creation
      • Tutorials
        • Read Group via Tags
  • Guides
    • Python
    • Send Slack Notifications
    • Forward Data to Cake Red
    • Multiple Data Feeds
    • Automated Dynamic Downlinks
    • Ingesting JSON Data into Datacake API Devices
    • Working with Default HTTP Decoder on API Devices and Code Examples
    • Accessing Measurements in Decoders
    • Connecting Datacake to Notion Using Zapier
    • How to set up and use location on non-GPS devices
    • How to integrate with AWS IoT Core
    • How to Schedule Mass-Downlinks (Multicast) using Datacake Rule Engine
    • How to Map Sensor Values to Ranges or Booleans, Strings using Mapping Fields
    • Understanding Internal vs. External MQTT Brokers on Datacake
    • Sending UDP Messages between 1NCE OS and Datacake
    • Concepts of LoRaWAN Payload Decoders on Datacake
    • How to check if a value stays above or below limits for given time
Powered by GitBook
On this page
  • Your First Downlink
  • Writing a Downlink Encoder
  • Return Bytes as an Array
  • Access Measurement Fields
  • Configuration Variables
  • Access Field Data
  • Sending Downlinks
  • Send Downlink
  • Send and Configure Downlink
  • Debugging

Was this helpful?

  1. LoRaWAN

Downlinks (LoRaWAN)

How to set up Downlinks for LoRaWAN

Last updated 11 months ago

Was this helpful?

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.

Your First Downlink

  • 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:

Writing a Downlink Encoder

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 ...
}

Sending Downlinks

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:

Send Downlink

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

Send and Configure Downlink

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: