(Optional) Add a LoRaWAN Interface for SmartConnect (Release 4.2)

(Optional) Add a LoRaWAN Interface for SmartConnect (Release 4.2)

SmartConnect is available with SmartServer 4.2 and higher.

You can use SmartConnect to integrate and manage LoRaWAN (Long Range Wide Area Network) devices.  LoRaWAN is a low power, wide area (LPWA) networking protocol designed to wirelessly connect battery (class A) and line-powered (class C) devices to a network providing bi-directional communication, end-to-end security, mobility, and localization services. The SmartServer LoRaWAN driver sends and receives data to and from LoRaWAN devices via a LoRa Network Server (LNS), which in the case of SmartServer 4.2 and higher is ChirpStack 4.2.

This section describes how to get started using LoRaWAN devices and consists of the following:

LoRaWAN Architecture

A typical LoRaWAN architecture is shown below:

 

Setting up LoRaWAN

To set up and use LoRaWAN with SmartConnect, follow these steps:

  1. Acquire and configure a LoRaWAN Gateway as described on this page.

  2. Enable LoRaWAN and ChirpStack on your SmartConnect as described on this page. With SmartServer 4.2 and higher, the LoRaWAN driver is disabled by default. 

  3.  Add LoRaWAN Device Profiles in ChirpStack as described on this page.

  4. Optionally, change the LoRaWAN frequency settings, which default to European frequencies, to the region that matches your LoRa gateway and actual LoRa devices as described on this page.

  5. Import, or create a LoRaWAN device interface (XIF) and device type definition as described on this page.

  6. Discover devices as described in Site Provisioning.

  7. Optionally, provide a BACnet interface for your LoRaWAN device; see Setting up the BACnet Server. This capability allows you to use a BACnet workstation with your LoRaWAN device.

Receiving Uplink Data from Edge Devices

LoRaWAN devices will send unconfirmed uplink data regularly, along with alarm data as necessary. Regular uplink data may consist of one or more packets, separated by a few seconds. The regular update interval is configurable either using an NFC app or via downlink data and determines battery life for class A devices. Devices send an encrypted base64-encoded hex string over the air that represents all the sensor data, the LNS decrypts the data, converts from base64-encoded to a hex string and the relevant device profile codec converts the hex string to a JSON object which is passed to IAP using MQTT. The entire hex string prior to JSON encoding is available in IAP if required.

Sending Downlink Data to Edge Devices

The LoRaWAN driver sends downlink data to the LNS using MQTT. The LNS forwards the data to edge devices. The LoRaWAN driver uses an LNS-specific MQTT topic, base64-encoded data, and the fport number configured in the XIF for the device type and the datapoint in question.  For non binary applications, external encoders can be used to generate the downlink data.  The data is sent to the LoRaWAN device using a confirmed message. Downlink data may relate to a specific datapoint, or may be a hex string that can be used to configure the regular uplink period, alarm thresholds or form part of a request response mechanism in conjunction with the subsequent uplink data.

Defining the IAP Device UNID

The LoRaWAN device DevEUI is used as the IAP unid. It is either acquired when using automatic discovery for LoRaWAN (the preferred mechanism) or added when manually creating devices.

Acquiring the LoRaWAN Gateway

Purchase an external LoRaWAN gateway such as a RAK 7268 or Multitech MTCAP for the relevant local frequency band. 

Configuring the LoRaWAN Gateway

Ensure that the LoRaWAN gateway is set for Semtech Packet Forwarding on UDP port 1700 for both uplink and downlink connections and that the LNS server IP address is set to the IP address of SmartConnect.  

An example RAK gateway configuration is shown below. Make a note of the Gateway EUI, which is needed to configure ChirpStack.

Using Redundant LoRaWAN Gateways

ChirpStack supports redundant gateways, either for enhanced coverage or for true redundancy.

Enabling the LoRaWAN Driver and ChirpStack

With SmartServer 4.2 and higher, the LoRaWAN driver and ChirpStack are disabled by default for SmartConnect. Do not use the SmartConnect Configuration page to enable LoRaWAN and ChirpStack –– follow these steps:

  1. Open a SmartConnect terminal connection.



  2. Ensure that the SmartConnect can access the internet by using the following command in an SSH session:

    ping google.com

    You should see a response similar to the following:

    apollo@smartserver-hsbcw69:~$ ping google.com PING google.com (192.168.4.146) 56(84) bytes of data. 64 bytes from 192.168.4.146 (192.168.4.146): icmp_seq=1 ttl=114 time=47.9 ms 64 bytes from 192.168.4.146 (192.168.4.146): icmp_seq=2 ttl=114 time=45.1 ms 64 bytes from 192.168.4.146 (192.168.4.146): icmp_seq=3 ttl=114 time=41.5 ms 64 bytes from 192.168.4.146 (192.168.4.146): icmp_seq=4 ttl=114 time=54.7 ms

    Use CTRL-C to stop pinging. You should then see a summary similar to the following:

    --- google.com ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 7054ms rtt min/avg/max/mdev = 41.503/47.285/54.658/4.825 ms

    If there is an issue with internet access, then correct the problem as needed.

  3. Enter the following command to enable LoRaWAN and ChirpStack:

    $ ssctl enable chirpstack lorawan
  4. Enter the following command to reboot SmartConnect:

    $ sudo reboot
  5. Once SmartConnect has finished rebooting, open a terminal connection again.

     

  6. Enter the following command to verify that LoraWAN and ChirpStack are running:

    $ ssctl status chirpstack lorawan

    You should see a result similar to the following:

    pi@smartserver-hsbcw69:~ $ ssctl status chirpstack lorawan chirpstack-bridge active since Tue 2023-11-21 15:46:10 EST; 3min 39s ago chirpstack-gateway active since Tue 2023-11-21 15:46:10 EST; 3min 39s ago chirpstack-postgresql active since Tue 2023-11-21 15:46:09 EST; 3min 40s ago chirpstack-redis active since Tue 2023-11-21 15:46:09 EST; 3min 40s ago lorawan active since Tue 2023-11-21 15:46:40 EST; 3min 9s ago pi@smartserver-hsbcw69:~ $

    The  SmartConnect Configuration page will also show the LoRaWAN interface is enabled. Disregard the Install ChirpStack button; ChirpStack is installed by default in SmartConnect.



  7. Once ChirpStack is running, you can log into the ChirpStack administration page by entering http://<SmartConnect IP address>:8080 in a web browser URL.Example

    http://192.168.4.146:8080

    The ChirpStack administration login page appears.



  8. Enter the login username / email and password (default is admin admin), and click Submit.

    The ChirpStack Dashboard appears.



  9. Add LoRaWAN Device Profiles in ChirpStack. See the Adding LoRaWAN Device Profiles in ChirpStack section below

  10. Optionally, change the LoRaWAN frequency settings. See the Changing the LoRaWAN Frequency Settings section below