Description
When operating as an integrated network server, Milesight LoRaWAN gateways support both sending data packets to a third-party MQTT/HTTP/HTTPS server or receiving downlink commands to forward to LoRaWAN endpoints.
Requirement
- Milesight LoRaWAN Gateway: UG56, UG63 V1, UG65, UG67, UG8x (firmware version 80.0.0.64 or later)
- MQTT server/broker
- MQTT client tool: take MQTT Explorer as an example
Configuration
Step 1. Connect the gateway to the MQTT broker .
See the article How to connect LoRaWAN gateway to MQTT broker? to connect the gateway to the MQTT broker and ensure that the MQTT broker and client can receive uplinks from the devices.
Step 2. Send a downlink command from the gateway
Configure the gateway to send downlink commands directly to the device to check whether the device can receive the downlink commands and perform actions.
Device EUI: The device EUI for sending downlink commands
Type: Downlink command type. For Milesight devices, please select hexadecimal type .
Payload: Contents of the downlink command (obtained from the device manufacturer). For Milesight devices, please refer to the contents of downlink commands in the corresponding user guides
Port: Application port of the device. It is 85 by default for Milesight devices.
Confirmed: Once enabled, the device will send the confirmed packet back to the gateway if it receives the command. If not received, the gateway will resend the downlink command a maximum of 3 times.
Note: For Class A devices, the gateway will add the command to the queue and send it when the Class A device sends uplinks.
Step 3. Post the topic to MQTT Explorer to send downlink data to the device.
Define a downlink data subject. If you need to send an MQTT downlink to a specific device, please add "$deveui" to the subject.
Example : /milesight/downlink/$deveui
Post topic format:
/milesight/downlink/[devEUI]
Example :
From the gateway we can obtain the EUI of the device we want to control:
We can therefore publish a topic on MQTT Explorer as below:
Subject: /milesight/downlink/24e124126a148401
Format: json
Content:
send as below format and replace data content with downlink command
After clicking Publish , we can go to Network Server > Packets to check. If the gateway has successfully subscribed the corresponding downlink subject data, there will be at least one grayed out message packet record.
Milesight Device Command Examples
The MQTT downlink command format is fixed as below:
For Milesight devices, click here to convert the command from hexadecimal to base64 format. Here are common Milesight controller commands:
Model |
Order |
Command (hexadecimal) |
Command (base64) |
UC50x |
Set GPIO1 low Set GPIO1 to high Set GPIO2 low Set GPIO2 to a high level |
030000ff 030100ff 040000ff 040100 and following |
AwAA/w== |
UC300 |
Set DO1 low Set DO1 high Set DO2 low Set DO2 high |
070000ff 070100ff 080000ff 080100 and following |
BwAA/w== |
UC11xx |
Set DO1 low Set DO1 high Set DO2 low Set DO2 high |
090000ff 090100 and following 0a0000ff 0a0100ff |
CQAA/w== |