User Tools

Site Tools


Sidebar

WMC v3.x wiki


Introduction


Quick Start


System Management


Network Management


SNMP


Push


LoRa features


GMS API


Troubleshooting


Gateway software resources

WMC 3.2:

Previous version

Server software resources

WMC 3.2:

Previous version


FAQ

WMC 3.x:

WMC 3.0:

WMC 3.1:

>= WMC 3.2:

>= WMC 3.1:

wiki:wiki3:faq_mqtt

FAQ: MQTT



What is MQTT ?

MQTT stands for MQ Telemetry Transport. MQTT is an open OASIS and ISO standard (ISO/IEC 20922) lightweight, publish-subscribe network protocol that transports messages between devices. The MQTT protocol defines two types of network entities: a message broker and a number of clients. An MQTT broker is a server that receives all messages from the clients and then routes the messages to the appropriate destination clients. An MQTT client is any device (from a micro controller up to a full-fledged server) that runs an MQTT library and connects to an MQTT broker over a network.


What is a MQTT broker ?

The MQTT broker is software running on a computer (running on-premises or in the cloud), and could be self-built or hosted by a third party. It is available in both open source and proprietary implementations.

The broker acts as a post office, MQTT doesn’t use the address of the intended recipient but uses the subject line called “Topic”, and anyone who wants a copy of that message will subscribe to that topic. Multiple clients can receive the message from a single broker (one to many capability). Similarly, multiple publishers can publish topics to a single subscriber (many to one).

Each client can both produce and receive data by both publishing and subscribing, i.e. the devices can publish sensor data and still be able to receive the configuration information or control commands (MQTT is a bi-directional communication protocol). This helps in both sharing data, managing and controlling devices.

What is a MQTT Topic?

Information is organized in a hierarchy of topics. When a publisher has a new item of data to distribute, it sends a control message with the data to the connected broker. The broker then distributes the information to any clients that have subscribed to that topic. The publisher does not need to have any data on the number or locations of subscribers, and subscribers, in turn, do not have to be configured with any data about the publishers.

If a broker receives a message on a topic for which there are no current subscribers, the broker discards the message unless the publisher of the message designated the message as a retained message. A retained message is a normal MQTT message with the retained flag set to true. The broker stores the last retained message and the corresponding QoS for the selected topic. Each client that subscribes to a topic pattern that matches the topic of the retained message receives the retained message immediately after they subscribe. The broker stores only one retained message per topic.[15] This allows new subscribers to a topic to receive the most current value rather than waiting for the next update from a publisher.

What Port does MQTT Normally Use?

The standard port is 1883.

Can you use MQTT without a broker?

No.

What Protocol does MQTT use?

The standard version uses TCP/IP.

Can multiple clients publish to the same topic?

Yes.

Which broker can be chosen to use with the WMC ?

Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1.
Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.

Refer to https://mosquitto.org/ to install the broker for your platform.

Is the Retain flag is set by default in the WMC Push configuration ?

This option is currently not supported in the current Server Software release. This improvement will be delivered in a future release.

Most of information in this page has been retrieved from Wikipedia https://en.wikipedia.org/wiki/MQTT.

How can I filter messages from a particular device with MQTT ?

Filtering on devEUI

You can use the following filter on devEUI in your push configuration to enable filtering on a particular device :

The MQTT client can subscribe to a particular device over its devEUI to get messages from this device:

UBUNTU:~$ mosquitto_sub -t "/DataUp/474ABD9100220034"

{"id":"615d7043c7169a0001c5859c","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":257,"fCntUp":254,"adr":true,"confirmed":true,"encrypted":false,"payload":"30","encodingType":"HEXA","recvTime":1633513539007,"gwRecvTime":1633513539007,"classB":false,"delayed":false}
{"id":"615d7050c7169a0001c5859e","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":258,"fCntUp":255,"adr":true,"confirmed":true,"encrypted":false,"payload":"31","encodingType":"HEXA","recvTime":1633513552397,"gwRecvTime":1633513552397,"classB":false,"delayed":false}
{"id":"615d705ec7169a0001c585a4","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":259,"fCntUp":256,"adr":true,"confirmed":true,"encrypted":false,"payload":"32","encodingType":"HEXA","recvTime":1633513566050,"gwRecvTime":1633513566050,"classB":false,"delayed":false}

Filtering on devAddr

You can use the following filter on devAddr in your push configuration to enable filtering on a particular device :

The MQTT client can subscribe to a particular device over its devAddr to get messages from this device:

UBUNTU:~$ mosquitto_sub -t "/DataUp/24001199"

{"id":"615d783ec7169a0001c58785","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":358,"fCntUp":355,"adr":true,"confirmed":true,"encrypted":false,"payload":"30","encodingType":"HEXA","recvTime":1633515581916,"gwRecvTime":1633515581916,"classB":false,"delayed":false}
{"id":"615d784bc7169a0001c58787","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":359,"fCntUp":356,"adr":true,"confirmed":true,"encrypted":false,"payload":"31","encodingType":"HEXA","recvTime":1633515595223,"gwRecvTime":1633515595223,"classB":false,"delayed":false}
{"id":"615d7859c7169a0001c5878c","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":360,"fCntUp":357,"adr":true,"confirmed":true,"encrypted":false,"payload":"32","encodingType":"HEXA","recvTime":1633515608824,"gwRecvTime":1633515608824,"classB":false,"delayed":false}
{"id":"615d7866c7169a0001c5878e","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":361,"fCntUp":358,"adr":true,"confirmed":true,"encrypted":false,"payload":"33","encodingType":"HEXA","recvTime":1633515622329,"gwRecvTime":1633515622329,"classB":false,"delayed":false}

How can I filter messages from a particular cluster with MQTT ?

You can use the following filter in your push configuration to enable filtering on all devices that belong to a particular cluster:

The MQTT client can subscribe to a particular cluster to get messages from all devices that belong to this cluster:

UBUNTU:~$ mosquitto_sub -t "/DataUp/46"

{"id":"615d7266c7169a0001c58627","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":298,"fCntUp":295,"adr":true,"confirmed":true,"encrypted":false,"payload":"3431","encodingType":"HEXA","recvTime":1633514086611,"gwRecvTime":1633514086611,"classB":false,"delayed":false}
{"id":"615d7274c7169a0001c5862a","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":299,"fCntUp":296,"adr":true,"confirmed":true,"encrypted":false,"payload":"3432","encodingType":"HEXA","recvTime":1633514100126,"gwRecvTime":1633514100126,"classB":false,"delayed":false}
{"id":"615d7282c7169a0001c5862d","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":300,"fCntUp":297,"adr":true,"confirmed":true,"encrypted":false,"payload":"3433","encodingType":"HEXA","recvTime":1633514113643,"gwRecvTime":1633514113643,"classB":false,"delayed":false}

How can I filter messages from a particular fPort with MQTT ?

You can use the following filter in your push configuration to enable filtering from a particular fPort:

The MQTT client can subscribe to a particular fPort to get all messages transmitted over this port number:

UBUNTU:~$ mosquitto_sub -t "/DataUp/8"

{"id":"615d7951c7169a0001c587cd","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":380,"fCntUp":375,"adr":true,"confirmed":true,"encrypted":false,"payload":"3230","encodingType":"HEXA","recvTime":1633515856723,"gwRecvTime":1633515856723,"classB":false,"delayed":false}
{"id":"615d795ec7169a0001c587d4","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":381,"fCntUp":376,"adr":true,"confirmed":true,"encrypted":false,"payload":"3231","encodingType":"HEXA","recvTime":1633515870282,"gwRecvTime":1633515870282,"classB":false,"delayed":false}
{"id":"615d796cc7169a0001c587d7","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":382,"fCntUp":377,"adr":true,"confirmed":true,"encrypted":false,"payload":"3232","encodingType":"HEXA","recvTime":1633515883806,"gwRecvTime":1633515883806,"classB":false,"delayed":false}
{"id":"615d79a1c7169a0001c587e6","endDevice":{"devEui":"474ABD9100220034","devAddr":"24001199","cluster":{"id":46}},"fPort":8,"fCntDown":386,"fCntUp":381,"adr":true,"confirmed":true,"encrypted":false,"payload":"3236","encodingType":"HEXA","recvTime":1633515937582,"gwRecvTime":1633515937582,"classB":false,"delayed":false}

wiki/wiki3/faq_mqtt.txt · Last modified: 2021/10/07 09:08 by tda