nRF5 IoT SDK  v0.9.0
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
MQTT

Message Queue Telemetry Transport (MQTT) is a lightweight connectivity protocol for machine-to-machine. The protocol uses a subscribe publish model for message exchange between the machines. All messaging takes place through a messaging broker, referred to from now on as the MQTT Broker. When referring to publishers and subscribers that use the broker for messaging, they are referred to as MQTT clients.

MQTT 3.1 is an OASIS standard and uses TCP as the transport protocol. IANA reserves port number 1883 and 8883 for MQTT and MQTT over SSL respectively.

For more details, visit http://mqtt.org.


MQTT_Overall.svg
Figure 2: Setup of MQTT examples.


MQTT brokers can be hosted by cloud services like Xively or can be run locally using broker implementations. Nordic devices, being resource constrained, will be the MQTT clients.

The MQTT examples in the IoT SDK include a Publisher and a Subscriber. The topic that is published and subscribed to is a LED state. A button on the publisher is used to control the LED state which also is published to the broker. The subscriber changes its own LED state based on the published message from the publisher.

This set of examples cannot work with each other without a broker. Mosquitto is described in the examples to be the broker.

Also, the examples use MQTT version 3.1.0. This is the version Mosquitto supports.

Certain brokers support MQTT version 3.1.1. It is possible to enable support for 3.1.1 by defining the MQTT_3_1_1 at compile time.

Note
The MQTT examples included in this version of the IoT SDK do not support the Will and QoS features of MQTT.

The sequence diagram in Figure 1 illustrates how two MQTT clients connects to a MQTT broker, one as a publisher and one as a subscriber. The data source, publishes data on a relevant topic to the broker as the figure depicts. The data sink can subscribe to this topic to get updates from the publisher through the broker.

msc_mqtt
Figure 1: MQTT Messaging Overview.

A detailed description of the MQTT client examples playing the Publisher and Subscriber Role is found here:

MQTT Client - Publisher

MQTT Client - Subscriber