MQTT: MQTT communication

Top  Previous  Next

The MQTT functions implement the Message Queue Telemetry Transport (MQTT) protocol.

MQTT is a open message protocol for M2M communications that enables transfer of telemetry-style data in the form of messages.

 

The MQTT protocol is based on the principle of publishing messages and subscribing to topics, or "pub/sub". Multiple clients connect to a server and subscribe to topics that they are interested in. Clients also connect to the server and publish messages to topics. Many clients may subscribe to the same topics and do with the information as they please. The server and MQTT act as a simple, common interface for everything to connect to.
 
MQTT has been characterized as the protocol realizing the Internet of Things the same was as HTTP was the enabler for the Internet of People.
 

Please visit www.mqtt.org detailed information on the MQTT protocol.

 

 


mqttOpen

Opens a connection to a MQTT server.


mqttClose

Closes a connection to a MQTT server.


mqttConnected

Queries if a connection to a MQTT server is active.


mqttConnectionLoss

Queries if a connection to a MQTT server has been interrupted.


mqttStatus

Get the status of a connection to a MQTT server.


mqttPublish

Sends a message to a MQTT server.


mqttPendingCount

Returns the number of messages, waiting to be sent.


mqttPendingClear

Clears the list of pending messages.


mqttSubscribe

Subscribe to a topic on a MQSS server.


mqttUnsubscribe

Unsubscribe to a topic on a MQTT server.


mqttWaiEvent

Wait for a received message or an optional timeout.


mqttReceive

Read a received message.


mqttCredentialsSet

Change the credentials used to connect to a MQTT server.

 

 

Unicode

Support for Unicode strings are included in the MQTT API, which means that text (topics, username, etc.) can be in the local language rather than in English. For more information, please refer to mqttOpen.

Unicode strings uses UTF-8 encoding.

 

Topic

Topics are treated as a hierarchy, using slash (/) as a separator. This allows sensible arrangement of common themes to be created, much in the same way as a file system.

For example, multiple RTCU devices may publish their temperature information on the following topic:

 

RTCU/222135115/temperature

 

where 222135115 is the serial number of the RTCU device.

 

 

Quality of Service (QoS)

The MQTT protocol supports 3 levels of QoS:

 

qos

name

description

0

Fire and forget

The message may not be delivered.

1

At least once

The message will be delivered, but may be delivered more than once in some circumstances.

2

Once and only

The message will be delivered exactly once.

 

Last Will and Testament (LWT)

When the RTCU connects to a server, it may inform the server that it has a will.

This is a message that it wishes the server to send when it disconnects unexpectedly.

 

 

Limitations

Up to 10 received messages are buffered for removal by the application.

Maximum of 3 messages inflight from the server.This is the maximum number of QoS 2 messages that are not fully acknowledged.

Maximum size of message:

oX32 architecture: 1024 bytes,

oNX32 architecture: 4096 bytes.

oNX32L architecture: 16384 bytes.