Skip to main content

MQTT - Unity interface

[!WARNING] This documentation is set to be partialy merged with the API documentation for Unity.

[!WARNING] This package does not allow for certificate validation.

Project owner: Yann van Eijk

Project description

This repository contains the scripts needed within Unity to create an interface between MQTT and Unity. Its main functionality is to receive and sent real-time messages from topics on the MQTT Broker. These messages are processed within Unity as strings, for other types use TryParse.

Installation

The MQTT package is part of the 'DT lab Unity interface package'. For a full installation guide, please refer to...

MQTT broker connections

A connection to the MQTT broker can be established using the MQTT editor window. This window can be found under the header Tools -> EAISI Digital Twin Lab -> MQTT editor. A new window should pop up next to the Inspector window.

In this window, the following parameters need to be set:

VariableTypeDescriptionOptional/ Required
TCP serverStringHostname or IP adress of MQTT Broker.Required
PortStringPort number of MQTT on broker.Required
Use CredentialsBooleanSome MQTT brokers require user credentials for connections. If this is the case for the broker you want to connect to, tick this box.Optional (Check broker)
Use EncryptionBooleanSome MQTT brokers require an encrypted connection. If this is the case for the broker you want to connect to, tick this box.Optional (Check broker)
UsernameStringUsername of account set at MQTT broker.Optional (see Use Credentials)
PasswordStringPassword of account set at MQTT broker.Optional (see Use Credentials)
TopicsList<String>List of topics to subscribe to. All subscription topics used in the Unity project should be declared here.Optional (Required for subscription functionality)
Connect to MQTT broker at runtimeBooleanDisables editor time connection and enables connection upon entering runtime. Only enable this setting after testing the connection in editor time.Optional

Upon the initial opening of the editor window, the TCP server and Port variables are already set. This allows the user to quickly check if a connection to test.mosquitto.org can be established. To test this, click the gray connect button on the bottom the MQTT editor window. In the console, a debugging message should pop up stating Connected to: test.mosquitto.org:1883. This indicates that the package is working as intended.

Workflow