How to Remotely Control Devices via MQTT on Linovision Gateway

How to Remotely Control Devices via MQTT on Linovision Gateway

Tom Yao

Description

When working as embedded network server, Linovision LoRaWAN gateways support both sending data packets to third party MQTT/HTTP/HTTPS server or receiving the downlink commands to transfer to LoRaWAN end devices.

 

Requirement

  • Linovision LoRaWAN Gateway: IOT-G56, IOT-G63 V1, IOT-G65, IOT-G67, IOT-G8x (Firmware version 80.0.0.64 or later)
  • MQTT Server/Broker
  • MQTT Client tool: take MQTT Explorer as example

 

Configuration

Step1Connect gateway to MQTT broker.

Refer article How to Connect LoRaWAN Gateway to MQTT Broker?to connect gateway to MQTT broker and ensure the broker and MQTT client can receive uplinks from devices.

 

Step2Send Downlink Command from Gateway

Set the gateway to send downlink commands to device directly to check if the device can receive the downlink commands and take actions.

Device EUI: the device EUI to send downlink commands

Type: downlink command type. For Linovision devices, please select hex type.

Payload: downlink command content (get from device manufacturer). For Linovision devices, please refer to downlink command contents on corresponding user guides

Port: application port of device. It is 85 by default for Linovision devices.

Confirmed: after enabled, the device will send confirmed packet back to gateway if it receives the command. If not receive, the gateway will resend the downlink command 3 times at most.

Note: for class A type devices, the gateway will add the command to queue and send it when the class A device send uplinks.

 

 

 

Step3. Publish Topic on MQTT Explorer to send downlink data to device. 

Set a Downlink Data topic. If you need to send MQTT downlink to specific device, please add “$deveui” on the topic.

Example: /linovision/downlink/$deveui

  

 

Publish Topic Format :

/linovision/downlink/[devEUI]

Example :

From the gateway, we can get the device EUI about the device we want to control:

 

 

So we can publish a topic on the MQTT Explorer like below:

Topic: /linovision/downlink/24e124126a148401

Format: json

Content: 

send as below format and replace the data content as downlink command

{"confirmed": true, "fport": 85, "data": "CQEA/w=="}
JavaScript

 

After click Publish, we can go to Network Server > Packets to check. If the gateway have subscribe corresponding downlink topic data successfully, there will be at least one grayed message packet record.

 

 

Linovision Device Command Examples

The MQTT downlink command format is fixed as below:

{
"confirmed": true,       //Set as true or false
"fport": 85,            //application port of device
"data": "BwAA/w=="    //base64 format downlink command
}
JavaScript

For Linovision devices, click here to convert hex format command to base64 format. Here are Linovision controller common commands:

Model

Command

Command (Hex)

Command (base64)

IOT-C50x

Set GPIO1 low

Set GPIO1 high

Set GPIO2 low

Set GPIO2 high

030000ff

030100ff

040000ff

040100ff

AwAA/w==
AwEA/w==
BAAA/w==
BAEA/w==

IOT-C300

Set DO1 low

Set DO1 high

Set DO2 low

Set DO2 high

070000ff

070100ff

080000ff

080100ff

BwAA/w==
BwEA/w==
CAAA/w==
CAEA/w==

IOT-C11xx

Set DO1 low

Set DO1 high

Set DO2 low

Set DO2 high

090000ff

090100ff

0a0000ff

0a0100ff

CQAA/w==
CQEA/w==
CgAA/w==
CgEA/w==

 

----END---