LoRaWAN devices are supported with SmartServer 4.0 and higher.
You can use the SmartServer 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.0 and higher is ChirpStack 4.2. ChirpStack is not included with the factory SmartServer image and is added during the SmartServer LoRaWAN setup.
To set up and use LoRaWAN with the SmartServer, follow these steps:
- Add a LoRaWAN network interface as described on this page.
- Import, import and modify, or create a LoRaWAN device interface (XIF) and device type definition as described on this page.
- Define datapoint properties for any datapoints to be monitored or logged as described in Setting Datapoint Properties.
- Define or discover, and provision devices as described in Site Provisioning.
- To optionally provide a BACnet interface for your LoRaWAN device see Setting up the BACnet Server. This enables you to use a BACnet workstation with your LoRaWAN device.
This page includes the following sections:
A typical LoRaWAN architecture is shown below:
Adding a LoRaWAN Network Interface
To set up the LoRaWAN driver (beta), contact the EnOcean Customer Success team at firstname.lastname@example.org.
Once your system is set up for LoRaWAN, you can start adding your devices into ChirpStack and then provisioning them in the CMS once they are discovered. See the Adding LoRaWAN Devices in ChirpStack section in Discovering, Defining, or Importing Devices.
- For the beta release, once you have configured your SmartServer with the LoRaWAN image, do not upgrade or re-image the SmartServer as this operation breaks the LoRaWAN configuration.
- For the beta release, do not change the static IP address of the SmartServer as this operation may break ChirpStack.
Enabling / Disabling the LoRaWAN Driver
By default, support for the LoRaWAN driver is disabled. However, once the beta configuration has been set up, the LoRaWAN driver will be running. The information that follows regarding enabling/disabling the LoRaWAN driver is for your reference only.
Enabling the LoRaWAN Driver
To enable the LoRaWAN driver, first enter the following command:
sudo smartserverctl enable lorawan
sudo smartserverctl enable smartserver-lwd
Then, start the LoRaWAN driver by rebooting the SmartServer or by issuing the following command:
sudo smartserverctl start lorawan
sudo smartserverctl start lwd
Disabling the LoRaWAN Driver
To disable the LoRaWAN driver, you first need to stop the driver. Issuing only the disable service command does not stop the service from running. The service will continue to run and will only be stopped after a reboot or by issuing the stop command as well. To stop and disable the LoRaWAN driver, enter the following commands:
sudo smartserverctl stop lorawan
sudo smartserverctl disable lorawan
sudo smartserverctl stop lwd
sudo smartserverctl disable lwd
Importing and Creating LoRaWAN Device Interface (XIF) and Device Type Definitions
You can import and optionally modify LoRaWAN device interface (XIF) and device type definitions. You can also manually create custom LoRaWAN XIF and device type definitions. To import and modify LoRaWAN device interface (XIF) and device type definitions, follow these steps:
- To import LoRaWAN XIF definitions, download the LoRaWAN device type package (.dtp) files from the SmartServer GitHub Repository You can optionally modify the LoRaWAN XIF files to hide selected datapoints.
- To create a custom LoRaWAN XIF definition (.LoRaWAN), see Creating a LoRaWAN Device Interface (XIF) Definition (Beta).
- To create a custom LoRaWAN device type definition (.dtd), see Defining Device Types.
- Import the LoRaWAN device interface (XIF) and device type definitions using the Import / Export button () on the SmartServer app bar.
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 JSON which is passed to IAP using MQTT. The entire hex string prior to JSON encoding is available in IAP.
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. 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.
Using Redundant LoRaWAN Gateways
ChirpStack supports redundant gateways, either for enhanced coverage or for true redundancy.
Configuring the LoRaWAN Gateway
ChirpStack requires an external LoRaWAN gateway that must be configured for Semtech Packet Forwarding on UDP port 1700 (Up and Down) and the LNS IPV4 address set to that of the SmartServer.
An example RAK gateway configuration is shown below. Make a note of the Gateway EUI for subsequent use.