Introduction

Milesight gateway is able to encode the commands from BMS system or BACnet devices and send commands to LoRaWAN devices to achieve the remote control. 

 

Requirement

  • Milesight Gateway: UG65/UG67 with firmware version 60.0.0.41-r3 and later
  • Any LoRaWAN device: take UC300 as example
  • BACnet Client tool: take Yabe as example

 

Configuration

  1. Go to Network Server > Payload Codec to add a custom encoder.Here is the encoder example of UC300 to define which command the gateway will send when a variable value changes:

    function Encode(fPort, obj) {
        var encoded = [];
    
        if ("gpio_out_1" in obj) {
          if (obj.gpio_out_1 == 1) {
            encoded = [0x07,0x01,0x00,0xff]    //DO1 open
          }
          if (obj.gpio_out_1 == 0) {
            encoded = [0x07,0x00,0x00,0xff]   //DO1 close
          }
    }
        if ("gpio_out_2" in obj) {
         if (obj.gpio_out_2 == 1) {
        encoded = [0x08,0x01,0x00,0xff]  //DO2 open
          }
         if (obj.gpio_out_2 == 0) {
        encoded = [0x08,0x00,0x00,0xff]  //DO2 close
          }
        }
        return encoded;
    }

    Note: 

    1) If you add both decoder and encoder to one payload codec, the same variable should use the same variable name. Take UC300 as example, if the DO1 should be added to both decoder and encoder, it must be used a unique name.

    2) For downlink command definition please refer to corresponding user guide.


  2. Connect LoRaWAN node to Milesight gateway referring to article How to Connect LoRaWAN Nodes to Milesight Gateway. Note that ensure the correct payload codec is selected and correct fPort is typed when adding this device. For Milesight devices, the default fPort is 85 and you can change the port number on the device.

  3. Go to Network Server > Packets to check if device has joined to network and you can also send downlink commands to check if the device responses it.

  1. Select the Application you use and add a BACnet/IP transmission.

image-20221223144348974

 

  1. Go to Protocol Integration > BACnet Server > Server to enable BACnet server and configure the settings. Note that the Device ID should be changed to an unique value to avoid conflict with other BACnet server devices, or the BACnet client may not find this device.

 

  1. Go to Protocol Integration > BACnet Server > BACnet Object page, click Add to add an object.
  • Device Name: select the device added on Network Server > Device page
  • LoRa Object: the variable on encoder
  • Object Name: a unique object name generated from the LoRa Object
  • Object Type: select Analog Output or Binary Output

 

  1. After adding, you can check if object values are updated regularly.Note: if you need to add decoder to monitor DO status here or use Yabe tool to change values, please find decoder here and change the DO output to binary type by modifying decoded[gpio_out_name] = bytes[i] === 0 ? "off" : "on"; to decoded[gpio_out_name] = bytes[i] === 0 ? 01; 

 

  1. Open Yabe BACnet client tool, click Add device to scan the devices, then you can find the BACnet server device according to the Device ID and check the object list.
  2. image-20221227144927758

 

  1. Click the object to check all the properties of this object, , then modify the Present Value to send downlink commands. Take UC300 encoder as example, when gpio_out_2 value is changed to 1, the gateway will send DO2 open command.After sending, go to Network Server > Packets to check if there is downlink command sent and the response.



---END---