Table of Contents

MQTT Communication: Broadcasting Messages

The Message Queuing Telemetry Transport (MQTT) protocol is available within Nominal Studio. It allows for the communication of information both in and out of the program to selected events. MQTT works by connecting to a broker and subscribing to a particular topic, designated by a string. When information is published on that topic, a client can receive the data. MQTT is asynchronous; simulations will not pause as they wait for messages to be received. This document will demonstrate how to set up MQTT in Studio and how to publish log data and messages.


Connecting a Client

The first step for a working MQTT system is to connect to a broker. An MQTT Broker acts as a server for the MQTT messages. Nominal Studio can only act as a client, so the broker must be initialized somewhere. To configure the MQTT client, press the MQTT Client button in the top-right corner.

Untitled

Selecting the MQTT client will open up a new window. This window can be opened and closed with the toolbar buttons and the data will save between windows.

Untitled

Under the Connection tab, this is where the client is configured. There are three key parameters required for this.

  • Host: This is the broker that the client will connect to. By default, the broker is set to a public broker, broker.mqttdashboard.com, which is hosted by HiveMQ. This is configurable and IP addresses can be used if required.
  • Port: By default, all MQTT communication is done over port 1883. Avoid adjusting this value as MQTT may not work if this is changed.
  • Client ID: This needs to be a unique client ID, as multiple clients with the same ID may have communication issues. By default, Studio will define a random Client ID that is specific to the session. If Studio is reopened, the Client ID will be different.
Warning

HiveMQ is a public broker. It is free to access and use. Anyone who knows the topic that data is published on can view the data. Ensure that no important or secure data is published to publish brokers.

Once configured, pressing Connect will connect the client to the broker. If successful, additional information will appear in the tab below.

Untitled

The Communication section displays configurations on the topics available. The Output Topic is the specified topic that all simulation data, including logs and events, are published. This topic is defaulted to include the Client ID, but is completely configurable and can be set as something more specific. The verbosity defines what is published over MQTT. The Events option will enable the automated publication of all configured events.

Untitled


Publishing Messages

The MQTT window can subscribe to and publish data. Multiple topics can be subscribed to, provided they are unique. This will automatically receive all messages that come over that topic from the broker that is defined. When data is received, it will be displayed on the Activity tab below.

Note

When using a public broker, by configuring the topic, any information published on that topic over the Internet can be accessed within Studio.

Once a topic is subscribed to, it will receive all data on that topic. By unsubscribing to the topic, the client will no longer attempt to read the data on that topic. To test whether the system is working, subscribe to some topic with a defined name and publish a message on that topic using the Send button. The data will be sent over the topic that is defined in the topic above.

Untitled

Note

If no new messages come through the activity, double-check that the topic has been subscribed to and the broker is valid. A public broker will require an Internet connection and availability to the 1883 port to access MQTT protocols.


Viewing the Data

As mentioned, the default host uses HiveMQ. This broker has a public interface that enables both the subscribing and publishing of topic data. The link to this interface can be found below:

MQTT Websocket Client

Note

This interface is not affiliated with or developed by Nominal. It is an external tool. The interface may change or be unavailable during certain times.

To connect to the broker, on the site, leave the default values as they are and click Connect. If HiveMQ is available, this will open up a topic publishing and subscribe functionality.

Untitled

To subscribe to a particular topic, under the Subscriptions tab, press the button to add a new subscription. To test the functionality with the output topic from Studio, copy and paste the output topic from Studio to the subscriber. The QoS (quality of service) level can be kept as 2, which is the default for ensuring the message is transported correctly.

Untitled

Running Studio and allowing a spacecraft to trigger some events will result in data being published over the broker. This feature will be explained in more detail in the following tutorial.

Untitled