VM Development - IoT
Scope AR provides IoT capabilities for those interested in using near real-time data in WorkLink Create. This article will not delve into the specifics of IoT devices, data schema, etc; instead, we will provide instructions on how to enable the service. To begin, below are the ports/protocols/services needed for IoT:
Source | Destination | Port/Protocol | Description |
IoT Device | IP Address of VM | TCP: 30883 | Mosquitto (MQTT) broker endpoint |
What Is MQTT?
MQTT (Message Queuing Telemetry Transport) is a lightweight, publish-subscribe messaging protocol designed for efficient communication between devices, especially in IoT environments.
It enables low-bandwidth, low-latency messaging over unreliable networks by allowing devices (clients) to publish messages to topics, and other devices to subscribe to those topics. A central MQTT broker manages the message distribution.
Why We Use MQTT
In our application, MQTT powers the IoT feature by enabling reliable, real-time communication between devices (e.g., headsets and services), even over constrained networks or intermittent connections.
Enabling IoT
Login to Cockpit
Click the Advanced Configuration tab
Click Enable IoT Services near the top of the page
Check that the services are running by selecting the WorkLink Services in the left menu and ensure the scopear_iot_server and scopear_mosquitto services are running, Note that this may take a few minutes
Click back to Advanced Configuration page
Click the IoT tab
Edit the IoT Hostname, inserting the desired IoT hostname that is included in the SSL certificate
Click Save
Click Restart Services
Simulate the data for the data source
There are two different ways that you can simulate data for IoT. You can use MQTTX or our custom test app. MQTTX provides more control over the messages while our test app is much easier to use. First, we’ll need to download certificates from the CMS.
Download certificates from the CMS
MQTT is configured to ONLY accept connections from clients that are using a client side certificate. To download the certificates:
Login to CMS
In the sidebar, under Scope Admin, click on Client Certificates
If the existing certificates are expired, click Add Client Certificate and choose a starting and expiration date for a new certificate
Click the download icon below the three certificates:
Using MQTTX to simulate data
Install MQTTX - MQTTX: Your All-in-one MQTT Client Toolbox
Configure the connection to the local instance. When complete, your MQTTX configuration should look like this:
Note: For the Host, please insert the IP address of the VM
Ensure that you have uploaded the certificates under the Certificates section in MQTTX
Try to publish a message by copying the block below and pasting it into the message area in the bottom right corner.
{
"deviceName": "TorqueWrench",
"tagName": "torque",
"deviceID": "12345",
"success": true,
"datatype": "number",
"timestamp": 1662289718762,
"value": 90,
"metadata": {},
"registerId": "12345",
"description": "The Current Torque"
}
Replace the timestamp with a timestamp in milliseconds (you can use a site like this one to get that value: https://www.epochconverter.com/ ).
Replace the tagName value with the name of the variable you want to see in Create.
The topic field (above the message field) must start with the company id from the Company Info page by the device name that you want to identify your device in Create (e.g. “1/device1”). The deviceName field in the message needs to match the deviceName in the topic. You can find the company ID on the CMS under the Company Info tab in the sidebar in the data field named Database ID.
Press the green arrow on the bottom right corner to send the message. You should see in the top right window the message sent (in green) and the message received (in white). If you don’t see the message received then it was not received correctly. Check that you have your message topic correct.
For further information on how to view this data in WorkLink Create, please follow this article: https://help.scopear.com/hc/en-us/articles/18933922059917-Connected-Services-and-Step-Conditions-Windows