With software version 0.48 The Linortek WFMN supports MQTT protocol. At this time, the WFMN only publishes under the topic: lt1000/xx:xx:xx:xx:xx:xx/tele – where xx:xx:xx:xx:xx:xx is the device’s MAC address. It currently sends a single payload in JSON format to the configured broker on a 1-minute interval at QoS0.
This guide shows how to configure and implement a broker and to configure the WFMN to publish data to the broker. Below we is an example of how to get up and running with a Mosquitto broker running on a Windows 10 PC. To see the published messages, will use mqtt-spy on Windows, and MQTT Client on Android to confirm functionality. Note that the configuration demonstrated in this document is intended only to validate communication between the WFMN and a broker. This environment is not meant to represent a full production environment since no access control or security are detailed below. Please consult a qualified MQTT consultant for best practices regarding setting up a production MQTT environment.
Configuring the Broker
Please refer to the internet for instruction as to how to install mosquito broker. After installing and running Mosquitto, open a Command Prompt window and navigate to the folder where Mosquitto is installed (ex: cd c:\Program Files\mosquitto). Next, enter the command: mosquito_sub -t lt1000.
Your broker is now subscribed to the lt1000 topic
Setting WFMN to Publish to the Broker
After setting up your broker, you will need to configure the WFMN to connect to the broker. In this example, the WFMN is on the same local network as the broker. The broker’s address will be the IP address of the PC it is running on. Using telnet, log in to your WFMN and enter the command: mqtthost=brokeraddress. In this case the command is: mqtthost=172.16.1.41. Then set the port by entering the command: mqttport=xxxx which is defaults to 1883. Refer to your broker installation instructions and procedure for details regarding the broker’s port number. In this case the command is: mqttport=1883. The WFMN will now publish its payload at a 1-minute interval.
Configuring a Client
As there are many clients that may now subscribe to your WFMN, this example will use mqtt-spy on Windows and MQTT Client on Android.
Mqtt-spy
Mqtt-spy is an open source java application for monitoring MQTT topics. After downloading it, open the application and then open the Connections dropdown menu and select New Connection. A window will open allowing you to configure your connection to the MQTT broker.
From here, you can set a Connection Name, Server URI, and Client ID. Server URI is the address of the server. If you are running MQTT Spy on the same PC running the Mosquitto broker, you may leave the URI set to 127.0.0.1 (the local pc’s loopback address). If using the client on a different PC, you will need
to enter the IP address or web address as well as the port number which the broker is running. If you set your broker to require a username and password, this can be entered in the Security tab. Once you are finished, click Open Connection.
A new tab will open on the main window with your new connection. Click New under Subscriptions and received messages and enter the topic you wish to subscribe to. In this case there are two WFMN’s connected to the broker so to receive data from both the topic lt1000/# will be used.
Click Subscribe and it will begin receiving data from all WFMN’s connected to the broker.
Mqtt-spy is free to download at https://www.eclipse.org/paho/components/mqtt-spy/
MQTT Client
MQTT Client is a free client available for Android from Google Play. Upon first opening the app, you will be presented with a blank screen with a “+” sign in the bottom right. Tap to add your broker. On the next screen, tap Enabled, assign a Nick Name, enter your Host’s IP or web address and Port number. You may enter a Username and Password if you have set your broker to require credentials, and enter a Client ID. Once complete, tap the Save icon in the upper-right and your configured broker will be added to the main screen.
Tap your broker and you will come to a new screen where you can add topics to subscribe to. Tap Subscribe to a Topic on the bottom of the screen and enter the topic. In this case, there are two WFMN’s connected to the broker, so to receive data from both the topic lt1000/# will be used. Once entered, tap SUBSCRIBE.
The topic will display on the screen with a preview of the payload contents. Tap the topic to view.
It is now verified that the WFMN is connected to and communicating with the broker. The WFMN can be integrated into your system.
Payload Structure and Details
The MQTT payload at the time this document was published is as follows:
Planned Updates
While the WFMN’s MQTT functionality is currently limited, the following updates are planned:
- User settable topic and payload
- Capability to connect to a secured broker (using UserID and password)
- TLS Encryption
- Organization ID (to set your company’s name or divisions)
- Add accelerometer telemetry to the payload
- Configuration save and restore
The timeline for these updates are currently TBD