...
The MQTT communication starts with the CONNECT message sent by client (D2000 KOM). Message contains (User Name), Password and other parameters, from which it is possible to set up Clean Session Flag and Client ID (parameter Will Flag is not used, as well as Will QoS and WillRetain, parameter Keep Alive is set to 0). Server replies with CONNACK message with a return code that contains the connection success information.
Then client sends SUBSCRIBE message with filter of topics (Topic Filter parameter), o ktoré má záujem a požadovanou maximálnou úrovňou potvrdzovanie which are of interest and with the required maximum level of confirmation (parameter Subscribe QoS). Server odpovedá návratovým kódom, ktorý obsahuje informáciu o úspešnosti a maximálny QoS, ktorý bol pre požadované témy pridelený.
Nasleduje bežná komunikácia, počas ktorej klient aj server posielajú PUBLISH správy (klient s ľubovolnou témou, server
The server responds with a return code that contains an information on the success and maximum QoS that was assigned to the requested topics.
That is followed by a common communication, during which both the client and the server send PUBLISH messages (the client with any topic, the server with topics relating to the filter of topics of the received SUBSCRIBE message) and confirm them according to the value of the QoS parameter of the received PUBLISH messages s témami zodpovedajúcimi filtru tém prijatej SUBSCRIBE správy) a podľa hodnoty parametra QoS prijatých správ PUBLISH ich potvrdzujú.
If the server does not send a message for longer than Ping Interval seconds, the client sends the PING request message, to which the server must respond with the PING response message (within the time specified by the Reply Timeout parameter).
If parameters change on the line, the connection is closed and re-created.
The communication has been tested towards the MQTT server www.TheThings.network.
...
Parameter | Description | Unit / size | Default value | ||||||
---|---|---|---|---|---|---|---|---|---|
| Enabling detailed statements about sending and receiving values. | YES/NO | NO | ||||||
| User name used in CONNECT message to connect to the MQTT server. | - | |||||||
| Password used in CONNECT message to connect to the MQTT server. | - | |||||||
| The name of one topic or a multiple topic filter sent within the SUBSCRIBE message. Using the filter the MQTT client specifies topics, within which it wants to receive messages. Note: topics are hierarchically sorted, a slash (/) is used as the separator, a plus (+) is used as a one-level mask, a hash (#) character is used a mask for multiple levels. Examples of filter: a/b , level1/+ , # , +/+/+/up | - | # | ||||||
| The desired maximum level of validation (QoS) sent within the SUBSCRIBE message. The MQTT server can then send PUBLISH messages with such or lower level of validation (but not higher). PUBLISH messages sent by the MQTT server will be validated by the D2000 KOM process according to the level of validation specified in them. The higher the level of validation, the more messages between the client and the server are exchanged (1 at QoS_0, 2 at QoS_1 and 4 at QoS_2). | QoS_0 QoS_1 QoS_2 | QoS_1 | ||||||
| Unique client identifier (Client Identifier) sent within the CONNECT message. je možné zadať aj prázdny reťazec - v tom prípade server môže klientovi prideliť unikátne meno (pokiaľ takúto funkcionalitu podporuje) alebo vráti chybu. Pokiaľ nie je zadaný Client ID, bude ale ignorované nastavenia parametra Clean Session Flag (keďže server pridelí zakaždým unikátne meno). | - | |||||||
| Parameter Clean Session Flag of the CONNECT message. The No value means that the server uses the current session state (connection) - e. g. after collapse and recovery of the TCP connection. This means that all unverified PUBLISH messages are sent with QoS_1 and QoS_2 (and optionally also QoS_0 depending on the implementation). The Yes value means that the session is re-created and any unverified PUBLISH messages are not repeated. | YES/NO | NO | ||||||
| Level of confirmation (QoS) used to send PUBLISH messages through the D2000 KOM process. Sending the PUBLISH message is the outcome of writing into the output tag with OUT_DATA address. The higher the confirmation level, the more messages between the client and server is sent (1 for QoS_0, 2 for QoS_1 and 4 for QoS_2). | QoS_0 QoS_1 QoS_2 | QoS_0 | ||||||
| If the MQTT server did not send a message during the specified time interval, the D2000 KOM process sends a PING request and waits for a PING response response (until time Reply Timeout). A value of 0 turns off sending the PING request messages. Parameter allows detection of TCP connection collapse. | sec | 60 | ||||||
| Pokiaľ do požadovaného času MQTT server neodpovie na správy If the MQTT server does not respond to the SUBSCRIBE, UNSUBSCRIBE a PING request, prípadne sa nepodarí načítať ľubovolnú správu (a je načítaná iba jej časť), D2000 KOM proces vyhlási chybu, zavrie spojenie a znovu ho otvorí. Hodnota 0 vypína časový limit.Parameter umožňuje reagovať na problematické chovanie MQTT servera , and PING requests within the required time or fails to retrieve any message (and only part of it is retrieved), the D2000 KOM process declares an error, closes the connection, and opens it again. Value 0 turns off the timeout. | sec | 20 | ||||||
| Timeout čakanie pri jednom čítaní z TCP spojeniawaiting at a reading of TCP connection. D2000 KOM opakuje čítanie spontánnych dátrepeats reading of spontaneous data Max. Wait Retry krát a pokiaľ nenačíta žiadne dáta, je vyhlásený timeout a čítanie je ukončené (a môže nasledovať ďalšie čítanie alebo prípadne zápis). Zmenšením parametrov Wait Timeout a Max. Wait Retry je možné dosiahnuť rýchlejšiu odozvu D2000 KOM procesu na zápis na úkor vyššej záťaže CPU, pokiaľ MQTT server nemá žiadne dátaand if no data is loaded, the timeout is declared and the reading is completed (and may be followed by a further reading or writing). By lowering Wait Timeout and Max. Wait Retry parameters, it is possible to achieve a faster response of D2000 KOM process for writing at the expense of a higher CPU load when the MQTT server has no data. | sec | 0.100 | ||||||
| Number of repetitions of reading from TCP connection. See description of the Wait Timeout parameter. | - | 3 |
...