LORIOT is a leading global IoT company, already present in more than 150 countries on 5 continents. Due to a unique positioning in the LoRaWAN ecosystem as both software provider and network operator, LORIOT is able to provide one of the most powerful, complete, and secure solutions in the market as well as tailor-made end-to-end solutions for IoT applications.
LORIOT’s LoRaWAN Network Server offers the solution to build and operate private LoRaWAN networks. Manage and monitor your remote devices and gateways with an elaborate toolset, and route telemetry data securely to your Ubidots powered IoT cloud application.
A downlink message comprehends the last mile in the IoT communication cycle, it enables devices, connected to the application layer through protocols requiring intermediary platforms, to be controlled or setup-modified from afar. Such an example is devices using LoRaWAN communication protocol and LORIOT as a network server. LORIOT provides an API triggered by POST requests to forward messages from the cloud down to devices, that is, downlink messages.
Following this guide, you will be able to send messages from the Ubidots platform to a LORIOT-connected device using the events module and LORIOT downlink API.
Requirements
Ubidots trial or licensed account
LoRaWAN Gateway & Devices already transmitting data to LORIOT and Ubidots (see the simple setup of LORIOT uplink to Ubidots)
A Control variable within your device in Ubidots to trigger the downlink event.
1. Setup a downlink event in Ubidots to LORIOT
The below steps indicate how to create an event in Ubidots to perform a downlink message to LORIOT’s back-end, and hence control devices from Ubidots UI.
Step 1: Open Events module located under the Data dropdown.
Step 2: Create a new event and setup the condition to be triggered based on the control variable’s values.
Step 3: Next, in the Actions section, create a "Trigger webhook" action.
Step 4: Head to your LORIOT console and select the application hosting the device you want to make a downlink to.
Step 5: Extract the below information from your application console panel:
– Region: located in the URL of the browser
– Application ID: found in the Details section
Step 6: Head over to the Access Tokens and copy the Authentication Token
Step 7: Enter the required information in the webhook options panel of the event action. This information corresponds to the information sent in the POST request to LORIOT API:
– HTTP Method And URL:
POST
https://<region>.loriot.io/1/rest
=> you'll need to replace <region> with your deployment region.
– Headers: you'll 2, one for the Content-Type and for the Authorization. It follows the structure “key: value”
Content-Type : application/json
Authorization : Bearer <Access-Token>
=> You'll need to replace <Access-Token> with the token of the application
– Active Trigger Body: this is the JSON expected by Loriot's API. You'll need to replace <device-label> with the Device label bookmark, <port> with the listening port of your device, <app-id> with the respective Loriot app id, and <data> with the hex-encoded data to send to the device.
{"cmd": "tx","EUI":"<device-label-bookmark>","port": <port>,"confirmed": false,"data":"<data>","appid":"<app-id>"}
– Back to Normal Body: same applies with this JSON as in the Active Trigger Body
{"cmd": "tx","EUI":"<device-label>","port": <port>,"confirmed": false,"data":"030111","appid":"<app-id>"}
Step 8: Follow to the last section of event creation and name the event
2. Result
After setting up your downlink event to be triggered once condition es met, you should see something similar to the below GIF in the downlink section of your Device at LORIOT.
We set up this event example to be triggered when a control variable is 1, sending the following hex-encoded data frame:
030011
And then, when the control variable is switched off and the value is 0, performs a second downlink message sending a payload:
030111