Manage Data through MQTT
MQTT is the standard messaging protocol for the Internet of Things based on publish/subscribe information. It allows for messaging between device to cloud and cloud to device. Connections are always handled by an MQTT broker, which is responsible for receiving and filtering the messages using topics.
Establishing a Connection
- Host: tcp://mqtt.swx.altairone.com
- Port: 1883
Messaging
MQTT Topics are crucial in the MQTT ecosystem as the broker relies on them to determine which clients receive specific messages. Topics consist of one or more levels separated by a forward slash (topic level separator).
- single-level: Represented by a symbol (+) and allows the replacement of a single topic level. By subscribing to a topic with a single-level wildcard, the client receives all messages from any topic that contains an arbitrary string in place of the wildcard.
- multi-level: Represented by a hash symbol (#) and must be placed as the last character in the topic, preceded by a forward slash. By subscribing to a topic with a multi-level wildcard the client receives all messages of any topic that begins with the pattern before the #. If the topic is specified as “#” alone, the client receives all messages sent to the MQTT broker.
To handle the communication publisher/subscriber properly, an agreement regarding the guarantees of the message delivery is established. This is called the Quality of Service (QoS), and there are three levels of agreement:
- Level 0
- “At most once”. The message sent will not be stored nor redelivered by the sender and will not be acknowledged by the receiver.
- Level 1
- “At least once”. The message will be delivered at least once to the subscriber, but it can be delivered more than once.
- Level 2
- “Exactly once”. The message will be delivered strictly one time accompanied by multiple acknowledgment messages confirming the delivery of the message.
Using the MQTT Inspector
The MQTT Inspector allows you to see MQTT incoming topics and messages and the format of the data payload. A list of the messages and topics is shown so you will know what topics are available.