MQTT: Communication between MELARECON and SolidBlue

MQTT: Communication between MELARECON and SolidBlue

mqtt-logo

The network protocol MQTT (Message Queuing Telemetry Transport) is used for communication between the customer’s device (MELARECON) and the cloud (SolidBlue).

Functional principle of MQTT
Functional principle of MQTT

What is MQTT?

Mqtt is an open protocol intended for communication between machines (M2M) and plays an important role in the Internet of Things (IoT, Internet of Things). It is a very lean message protocol that offers an easy way to transmit messages and information. This makes it ideal for embedded development.

Mqtt is based on a publish-subscribe communication pattern, with a message broker serving as the central distributor of these messages, and the clients (devices) sending (publishing) or receiving (subscribing) messages. If a client now wants to send information, it can publish it on so-called topics. The message to the broker then contains the topic and the corresponding information. Other clients can then subscribe to these topics. the clients are now notified by the broker when new messages arrive on the subscribed topics, so that very efficient communication is ensured.

Topics

MQTT topics allow clients to address and share information. Topics are similar to a folder structure and use e.g. the slash (/) as a separator. Topics are case sensitive, use UTF-8 and must consist of at least one character.

All topics are only created when you subscribe or publish and are not permanent. By setting a so-called retained flag in the message to be sent, the broker saves the message and also makes it available to clients who only subscribe to this topic later.

A client can subscribe to an individual topic or many different ones at the same time. When subscribing, two “wildcard” characters can be used. # as a multi-level wildcard and + as a single-level wildcard. Wildcards cannot be used in the name of a topic.

Examples for topics

  • /Home
  • /Home/Room1/Alert
  • /Home/Room2/Light
  • /Home/Room2/Temperature
  • /Home/Room3/Light

Using of wildcards

Subscribing to the topic /Home/Room2/# includes e.g. here /Home/Room2/Light and /Home/Room2/Temperature. And subscribing to /Home/+/Light covers the topics /Home/Room2/Light and /Home/Room3/Light.

A client can only address one individual topic when publishing. The use of wildcards is not allowed here.

Quality control (Quality of Service)

There are 3 Quality of Service (QoS) levels in MQTT. The three levels are 0, 1, and 2. At level 0, no transmission is guaranteed, at level 1, the message is guaranteed to arrive at least once, and at level 2, it is guaranteed to arrive exactly once. The difference between 1 and 2 is that at level 1 it can happen that the message arrives at the client more often. The higher the level, the higher the bandwidth required.

Security

Communication via an MQTT broker is only as secure as the operator has configured the broker. In principle, a completely open broker can be provided without encryption and authentication. There are three ways to ensure a very high level of security for communication. On the one hand, the client can request authentication with a user name and password, and on the other hand, communication can be encrypted with TLS/SSL. Furthermore, the broker can be configured in such a way that clients are only allowed to publish and/or subscribe to certain topics. This means that not all registered clients can also subscribe to all topics, only the topics that are assigned to them.