Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
iconfalse
titleIntroduction

This page explains how to use TMQTTBroker the included MQTT Broker in a FactoryStudio project. 


Info
iconfalse

Quick video tutorial: MQTT Broker Without Sparkplug TMQTT Broker And SparkplugMQTT With Mosquitto Broker

Introduction

There is an executable file called TMQTTBroker.exe inside the product installation folder. To run it you need to double-click over the file. After running, you can see a blue icon in the Windows tray bar. MQTT Broker will run following the specification configured in the file TMQTTBroker.exe.config, you can find more information about it in the next section.

...

Also, it is possible to connect the TMQTTBroker with a runtime project where it can make available all namespaces and properties from the specific projects. In this case the project information will be available following the SparkplugB specification.


...

TMQQTBroker.exe.config

Before running the TMQTTBroker.exe the file TMQTTBroker.exe.config must be configured with the desire configuration.  It can be found in the product installation folder and you can open it  in any Text Editor. However, it is very important that the file name and extension (.exe.config) remains the same.

...

Code Block
<add  key="TagProperties"  value="Minl;Max;AlarmState;Acked"  />


...

Topologies

There are two ways the TMQTTBroker can be implemented. It can be used as simple gateway to exchange data between any MQTT Clients or through a direct connection with runtime projects and publishing project data for MQTT Clients using SparkplugB specification.

Simple Gateway

 In this scenario the TMQTTBroker only will exchange data between MQTT Clients following the SparkplugB specification or not. Then, the Clients are responsible to subscribe and publish topics to the Broker. Any topic format is supported in this scenario.

Connected to Runtime project

 In this scenario the TMQTTBroker will connect with one or several runtime projects through the TServer. It will publish the project data only for topics following SparkplugB specification.

...

Warning

The Topics are case sensitive.


Gateway + Connected to Project

In this scenario the TMQTTBroker will work as the last two scenarios together. As simple gateway exchange any data between the MQTT Clients and publishing data projects to the topics that match the project configuration in the TMQTTBroker.exe.config.



...

Examples of Communication

MQTT driver (without SparkPugB)

To set up a communication between the TMQTTBroker and the MQTTdriver, the first step is to create a Channel using this protocol.

...

In Points tab you need to configure the Topic in which your variable may publish or subscribe to messages (according to its AccessType). More information on each item is available in the MQTT driver documentation.


Points configuration


Mosquitto Client (without SparkPlugB)

The TMQTT Broker can have other clients connect to it in the same way as others Brokers available (e.g: mosquitto).

...

Code Block
mosquitto_sub -p 1883 -t Furnace/Temperature/Value
mosquitto_pub -p 1883 -t Furnace/Temperature/Value -m 22


MQTTSpB driver (SparkPlugB)

To set up a communication between MQTT + SparkPlug Driver and the TMQTT Broker, the first step is to create a Channel using this protocol.

...

Code Block
<GroupId>;<EdgeNodeId>;<DeviceId>;<QoS>


Point configuration


Using Third Party MQTT Clients – MQTT fx (SparkplugB)

It is possible to set up a communication between TMQTT Broker with Third Parties MQTT Clients. In this example we will use MQTT.fx.

...

Code Block
{
"timestamp": 1580152490182, "metrics": [
{
"name":  "Integer1", "timestamp": 1580152489659, "dataType": "Int32", 
"value": 30
}
],
"seq": 1
}


...

Appendix

MQTT

As defined in http://mqtt.org/:

”MQTT is a machine-to-machine (M2M)/”Internet of Things” connectivity protocol. It was de- signed as an extremely lightweight publish/subscribe messaging transport. It is useful for connec- tions with remote locations where a small code footprint is required and/or network bandwidth is at a premium. For example, it has been used in sensors communicating to a broker via satellite link, over occasional dial-up connections with healthcare providers, and in a range of home automation and small device scenarios. It is also ideal for mobile applications because of its small size, low power usage, minimised data packets, and efficient distribution of information to one or many receivers (more...)”.


Sparkplug B

As defined in https://www.bevywise.com/blog/sparkplug-b-mqtt-simulation/.

...