Porovnávané verzie

Kľúč

  • Tento riadok sa pridal
  • Riadok je odstránený.
  • Formátovanie sa zmenilo.

Podporované typy a verzie zariadení 
Konfigurácia komunikačnej linky
Parametre protokolu linky
Konfigurácia komunikačnej stanice
Konfigurácia meraných bodov
Literatúra
Revízie dokumentuSupported device types and versions 
Communication line configuration
Communication line parameters
Communication station configuration
I/O tag configuration
Literature
Document revisions

Kotva
typy_verzie
typy_verzie

...

Supported device types and versions

...

The protocol is an implementation of the Protokol je implementáciou štandardu MQTT 3.1.1 standard (október October 2014). MQTT protokol je klientprotocol is a client/server protokol typu protocol of subscribe/publish type. Je jednoduchý, má malú réžiu a je ľahko implementovateľný. Používa sa na komunikáciu M2M It is simple, has little overhead and is easy to implement. It is used for M2M communication (Machine to Machine) a v kontexte IoT and in the IoT context (Internet of Things).
D2000 KOM implementuje klientskú časť protokolu. Protokol je implementovaný na implements the client part of the protocol. The protocol je implemented on a TCP/IP linkeline.
Pre prenos LoRaWAN dát v rámci MQTT protokolu viď popis protokolu LoRaWan.
Každá PUBLISH správa obsahuje tému  
For transfer of LoRaWAN data encapsulated within the MQTT protocol, see LoRaWan protocol description.

Each PUBLISH message contains a topic (Topic), samotné dáta data (Payload) a úroveň potvrdzovania and level of confirmation (QoS). PUBLISH správy môže odosielať klient aj server. Klient na začiatku komunikácie použije správu SUBSCRIBE na oznámenie, o aké témy (parameter protokolu Topic Filter) má záujem. messages can be sent both by the client and the server. The clients at the beginning of the communication will use the SUBSCRIBE message to indicate what topics (parameter of Topic Filter protocol) they are interested in. 

Kotva
qos
qos
Protokol definuje tieto úrovne potvrdzovania PUBLISH správ The protocol defines the following levels of confirmation of PUBLISH messages - QoS (Quality of Service):

  • QoS_0 - správa PUBLISH nie je potvrdzovaná, môže dôjsť ku strate PUBLISH message is not confirmed, it may be lost
  • QoS_1 - správa PUBLISH je druhou stranou potvrdzovaná PUBACK, môže dôjsť ku duplicite PUBLISH message is confirmed by other side's PUBACK, it may be duplicate
  • QoS_2 - správa PUBLISH je druhou stranou potvrdzovaná PUBREC, tá je spätne potvrdzovaná správou PUBREL a tá finálne správou PUBCOMP PUBLISH message is confirmed by other side's PUBREC which is then confirmed back by the PUBREL message and that one by a final PUBCOMP message.


The level of confirmation of the messages sent by the D2000 KOM process is defined by the protocol parameter Publish QoS . D2000 KOM process considers the writing of the output tag to be successfully finished depending on the Úroveň potvrdzovania správ posielaných procesom D2000 KOM definuje parameter protokolu Publish QoS. D2000 KOM proces považuje zápis výstupného meraného bodu za úspešne ukončený v závislosti od QoS:

  • QoS_0 - po úspešnom odoslaní dát cez TCP spojenie after the data is successfully sent via TCP connection
  • QoS_1 - po prijatí after receiving PUBACK
  • QoS_2 - po prijatí after receiving PUBCOMP


Komunikácia MQTT sa začína správou CONNECT, ktorú pošle klient The MQTT communication starts with the CONNECT message sent by client (D2000 KOM). Správa obsahuje prihlasovacie meno (Message contains User Name), heslo (Password) a ďalšie parametre, z ktorých sa dá nastaviť Password and other parameters, from which only Clean Session Flag a and Client ID can be modified (parameter Will Flag sa nevyužíva, podobne ako Will QoS a WillRetain is not used, as  well as Will QoS and Will Retain, parameter Keep Alive je nastavený na is set to 0). Server odpovedá správou CONNACK s návratovým kódom, ktorý obsahuje informáciu o úspešnosti pripojenia.
Následne klient pošle správu SUBSCRIBE s filtrom tém (parameter Topic Filter), o ktoré má záujem a požadovanou maximálnou úrovňou potvrdzovanie replies with CONNACK message with a return code that contains information about the success of connect operation.

Then client sends SUBSCRIBE message with filter of topics (Topic Filter parameter), specifying which topics it is interest in, 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 s témami zodpovedajúcimi filtru tém prijatej SUBSCRIBE správy) a podľa hodnoty parametra QoS prijatých

The server responds with a return code that contains information about the success and maximum QoS that was assigned to the requested topics.

Then follows a phase of 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.

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 with the MQTT server  správ PUBLISH ich potvrdzujú.
Pokiaľ server nepošle žiadnu správu dlhšie ako Ping Interval sekúnd, klient pošle PING request správu, na ktorú server musí odpovedať PING response správou (do času špecifikovaného parametrom Reply Timeout).
Pokiaľ dôjde k zmene parametrov na linke, spojenie je zavreté a znovu vytvorené.
Komunikácia bola otestovaná voči MQTT serveru www.TheThings.network.

Kotva
komunikacna_linka
komunikacna_linka

...

Communication line configuration

...

  • Communication line category: Kategória komunikačnej linky: TCP/IP-TCP.
  • Host: IP adresa address of MQTT servera (prípadne redundantné adresy oddelené čiarkou alebo bodkočiarkouserver (or redundant addresses separated by a coma or semicolon).
  • Port: číslo portu je štandardne 1883 alebo 8883 pre kryptovanú default port number is 1883 or 8883 for the encrypted SSL/TLS variantuvariant.
  • Číslo linkyLine number: nepoužité, nastavte hodnotu unused, set the value to 0.

PoznNote: Štandardný Default port pre MQTT protokol je 1883 resp. 8883 pre for the MQTT protocol is 1883 or 8883 for SSL/TLS verziuversion. D2000 KOM neobsahuje implementáciu does not contain implementation of the SSL/TLS varianty protokolu, ale je možné ju nakonfigurovať s použitím utility stunnel protocol variant, but it is possible to configure it by using the stunnel utility http://www.stunnel.org pracujúcej v klientskom móde  working in a client mode (client = yes). Stunnel bežiaci na rovnakom počítači ako D2000 KOM by mal počúvať na lokálnom porte 1883 a po pripojení sa D2000 KOM procesu na tento port by mal komunikáciu zakryptovať pomocou SLL/TLS a poslať na cieľový MQTT server (typicky na running on the same computer as the D2000 KOM should listen to the 1883 local port and after connecting of D2000 KOM process to the port should encrypt the communication using SLL/TLS and send to the target MQTT server (typically on port 8883).

Kotva
linka_parametre
linka_parametre

...

Communication line parameters

...

Dialog link configuration - Protocol parameters tab.
They affect some optional protocol parameters. The following protocol line parameters can be entered:

Table

Dialóg konfigurácia linky - záložka Parametre protokolu.
Ovplyvňujú niektoré voliteľné parametre protokolu. Môžu byť zadané nasledovné parametre protokolu linky:

Tab. č. 1

Parameter
Popis
Description
Jednotka
Unit /
rozmer
size
Náhradná hodnota
Default value

Kotva
fd
fd
Full Debug

Zapnutie podrobných výpisov o posielaní a prijímaní hodnôt
Activates detailed debug information about sending and receiving values.YES/NONO
Kotva
un
un
User Name
Užívateľské meno použité v správe CONNECT na pripojenie sa k MQTT serveru
User name used in CONNECT message to connect to the MQTT server.-
Kotva
pw
pw
Password
Heslo použité v správe CONNECT na pripojenie sa k MQTT serveru
Password used in CONNECT message to connect to the MQTT server.-
Kotva
tc
tc
Topic Filter
Meno jednej témy alebo filter pre viacero tém posielaný v rámci SUBSCRIBE správy. Filtrom špecifikuje MQTT klient témy, v rámci ktorých chce prijímať správy.
Pozn: témy sú zoradené hierarchicky, ako oddeľovač slúži lomítko (/), ako maska jednej úrovne slúži plus (+), ako maska pre viacero úrovní znak hash (#).
Príklady filtra
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
-#
Kotva
sq
sq
Subscribe QoS
Požadovaná maximálna úroveň potvrdzovania
The desired maximum level of validation (QoS)
posielaná v rámci SUBSCRIBE správy
sent within the SUBSCRIBE message.
The MQTT server
môže následne posielať PUBLISH správy s takouto alebo nižšou úrovňou potvrdzovania (ale nie vyššou). PUBLISH správy posielané MQTT serverom budú potvrdzované procesom D2000 KOM podľa úrovne potvrdzovania v nich špecifikovanej. Čím vyššia je úroveň potvrdzovania, tým viac správ je medzi klientom a serverom vymenených (1 pri
can then send PUBLISH messages with such or lower level of confirmation (but not higher). PUBLISH messages sent by the MQTT server will be confirmed by the D2000 KOM process according to the level of confirmation specified in them. The higher the level of confirmation, the more messages between the client and the server are exchanged (1 at QoS_0, 2
pri
at QoS_1
a
and 4
pri
at QoS_2).QoS_0
QoS_1
QoS_2
QoS_1
Kotva
ci
ci
Client ID
Unikátny identifikátor klienta

Unique client identifier (Client Identifier)

posielaný v rámci CONNECT správy

sent within the CONNECT message.

Pozn: 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).
Testovaný

Note: it is possible to enter a blank string - in which case the server can assign a unique name to the client (if it supports such functionality) or return an error. However, if the Client ID is not specified, the Clean Session Flag parameter settings will be ignored (as the server will assign a unique name each time).

The tested MQTT server (thethings.network)

vrátil chybu, pokiaľ bolo Client ID prázdne a

returned an error if the Client ID was blank and Clean Session Flag=NO.

-
Kotva
cs
cs
Clean Session Flag

Parameter Clean Session Flag

správy

of the CONNECT message.

Hodnota No znamená, že server použije aktuálny stav session (spojenia) - napr. po rozpade a znovuobnovení TCP spojenia. Znamená to, že sú zaslané všetky nepotvrdené PUBLISH správy s QoS_1 a QoS_2 (a voliteľne aj QoS_0 v závislosti na implementácii).
Hodnota Yes znamená, že sa session vytvorí nanovo a žiadne nepotvrdené PUBLISH správy nie sú opakované

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 unconfirmed PUBLISH messages with QoS_1 and QoS_2 are resent (optionally also QoS_0, depending on the implementation).

The Yes value means that the session is re-created and unconfirmed PUBLISH messages are not repeated.

YES/NONO
Kotva
pq
pq
Publish QoS
Úroveň potvrdzovania
Level of confirmation (QoS)
použitá pri posielaní PUBLISH správ procesom
used to send PUBLISH messages through the D2000 KOM process.
Poslanie PUBLISH správy je dôsledok zápisu do výstupného meraného bodu s adresou
Sending the PUBLISH message is the outcome of writing into the output tag with OUT_DATA
. Čím vyššia je úroveň potvrdzovania, tým viac správ medzi klientom a serverom poslaných (1 pri
address. The higher the confirmation level, the more messages between the client and server are exchanged (1 for QoS_0, 2
pri
for QoS_1
a
and 4
pri
for QoS_2).QoS_0
QoS_1
QoS_2
QoS_0
Kotva
pi
pi
Ping Interval
Pokiaľ MQTT server neposlal za špecifikovaný časový interval žiadnu správu, D2000 KOM proces pošle výzvu PING request a očakáva odpoveď PING response (do času

If the MQTT server did not send any 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).

Hodnota 0 posielanie

A value of 0 turns off sending the PING request

správ vypína

messages. Parameter

umožňuje detekovať rozpadnutie TCP spojenia

allows detection of TCP connection failure.

sec60
Kotva
rt
rt
Reply Timeout
Pokiaľ do požadovaného času MQTT server neodpovie na správy 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

If the MQTT server does not respond to the SUBSCRIBE, UNSUBSCRIBE, and PING requests within the required time or the D2000 KOM process fails to read a complete message (and only part of it is read), the D2000 KOM process declares an error, closes the connection, and opens it again. Value 0 turns off the timeout.
The parameter enables handling of problematic behavior of the MQTT server.

sec20
Kotva
wt
wt
Wait Timeout

Timeout

čakanie pri jednom čítaní z TCP spojenia

of a single reading from TCP connection. D2000 KOM

opakuje čítanie spontánnych dát

repeats 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áta

times and if no data is read, the reading is timeouted and finished (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 writing response of D2000 KOM process at the expense of a higher CPU load when the MQTT server has no data.

sec0.100
Kotva
mwr
mwr
Max. Wait Retry
Počet opakovaní čítania z TCP spojenia. Viď popis parametra Wait Timeout
Number of repetitions of reading from TCP connection. See description of the Wait Timeout parameter.-3

Kotva
komunikacna_stanica
komunikacna_stanica

...

Communication station configuration

...

  • Communication protocol Komunikačný protokol "MQTT Client Protocol".
  • Adresa stanice: adresa stanice je konkrétna téma (Topic) alebo znak # reprezentujúci všetky témy. Pokiaľ je na linke stanica s adresou #, všetky správy sú smerované na jej merané body. V opačnom prípade je hľadaná stanica s adresou zodpovedajúcou poľu Topic v správe PUBLISH prijatej od MQTT servera.
    Pozn: v adrese stanice zatiaľ nie sú podporené znaky masky "+" v zmysle parametra Topic Filter.
  • Station address: station address is a particular topic (Topic) or a character # representing all topics. If there is a station with address # on the line, all messages are directed to its I/O tags. Otherwise, KOM looks for a station with the address corresponding to the Topic field in the PUBLISH message received from the MQTT server.
    Note: station address doesn't support wildcard characters "+" corresponding to mask of Topic Filter parameter (yet).
  • Polling parameters on the Time parameters tab - recommended value is Parametre pollingu na záložke Časové parametre - odporúčaná je hodnota Delay=0.

Kotva
merany_bod
merany_bod

...

I/O tag configuration

...

Possible value types of I/O tags: Možné typy hodnôt meraných bodov: Ci, Co, TxtI, TxtO.

Typ boduAdresaPopisBody pre čítanie dát poslaných MQTT serverom správou PUBLISH.
Pozn: hodnoty bodov sú nastavené D2000 KOM procesom v poradí
Type of  I/O tagAddressDescription
I/O tags for reading data sent by MQTT server through PUBLISH message.
Note: values of I/O tags are set by D2000 KOM process in the order
IN_TOPIC, IN_DATA
a
and IN_ID.
Nie je nutné, aby konfigurácia obsahovala všetky tri body
It is not necessary for configuration to contain all three I/O tags.
TxtI
Kotva
in_topic
in_topic
IN_TOPIC
Téma
Topic (Topic)
prijatej správy
of received PUBLISH message.
TxtI
Kotva
in_data
in_data
IN_DATA
Dáta
Data (Payload)
prijatej správy
of received PUBLISH message.
Ci
Kotva
in_id
in_id
IN_ID
Identifikátor paketu
Identifier of packet (Packet Identifier)
správy PUBLISH, ktorý závisí od úrovne potvrdzovania
of PUBLISH message that depends on the level of validation (QoS).
Pre správy posielané s
For messages sent with QoS_0
je identifikátor nulový, pre
, the identifier is zero, for QoS_1
a
and QoS_2
je to kladné
, it is a positive 16-
bitové číslo
bit number.
Pozn
Note:
ak
 if MQTT server
posiela aj správy s úrovňou potvrdzovania
sends also messages with the QoS_0
a je nakonfigurovaný bod
level of validation and theACK_ID
, odporúčame v záložke Filter aktivovať voľbu Nová hodnota pri zmene času, aby opakovaný zápis hodnoty 0 spôsobil generovanie novej hodnoty s líšiacej sa iba časovou značkou.
I/O tag is configured, then we recommend to activate the option New value when changing time in the Filter tab, so that repeated writing of the value 0 will cause a new value that differs only with time stamp to be generated.
I/O tag to confirm a received data to MQTT server
Bod pre potvrdenie prijatia dát MQTT serveru
.
Co
Kotva
ack_id
ack_id
ACK_ID
Ak je definovaný výstupný meraný bod s adresou
If an output I/O tag with ACK_ID address is defined,
D2000 KOM očakáva potvrdenie spracovania každej správy zápisom kópie hodnoty bodu
the D2000 KOM expects confirmation of the processing of each message by writing a copy of value of theIN_ID
. Až následne nastaví do bodov
tag. Only after then it sets values from the next received PUBLISH message (if it was received in the meantime) into the IN_TOPIC, IN_DATA
a
and IN_ID
(v tomto poradí) hodnoty z ďalšej prijatej PUBLISH správy (ak bola medzitým prijatá).
V prípade úrovne potvrdzovania QoS_0 je teda nutné opakovane zapisovať do bodu hodnotu 0.
Pokiaľ meraný bod ACK_ID neexistuje, hodnoty do bodov
I/O tags (in this order). 
In case of the QoS_0 level of confirmation, it is therefore necessary to repeatedly set the value of I/O tag ACK_ID to 0. 
If the I/O tag ACK_ID does not exist, the values are written into the IN_TOPIC, IN_DATA
a
and IN_ID
sú nastavované ihneď po spracovaní PUBLISH správy.
Pozn: pre správy prijaté s úrovňou potvrdzovania QoS_0 sa neposiela žiadne potvrdenie MQTT serveru, iba sa zverejnia hodnoty ďalšej prijatej PUBLISH správy.
I/O tags immediately after the PUBLISH message is received and processed.
Note: for the messages received with the QoS_0 level of validation, no confirmation is sent to MQTT server, only the values of received PUBLISH message will be published. 
I/O tags for sending values to the MQTT server through PUBLISH message.
Note: in order for the D2000 KOM process to send the PUBLISH messages to the MQTT server, both I/O tags must be defined within one station
Body pre posielanie hodnôt MQTT serveru správou PUBLISH.
Pozn: ak má D2000 KOM proces posielať MQTT serveru správy PUBLISH, musia byť definované obidva body v rámci jednej stanice
.
TxtO
Kotva
out_topic
out_topic
OUT_TOPIC
Téma (Topic) v rámci posielanej správy PUBLISH
Topic of the PUBLISH message being sent.
TxtO
Kotva
out_data
out_data
OUT_DATA
Dáta
Data (Payload)
v rámci posielanej správy PUBLISH
of the PUBLISH message being sent.
Pozn: poslanie správy sa uskutoční ako reakcia na zápis do bodu
Note: sending the message is performed out as result of writing to the OUT_DATA I/O tag (
t
i.
j
e.
pokiaš sa Topic nemení, tak stačí bod
if the Topic does not change then it is sufficient to set theOUT_TOPIC
nastaviť jednorazovo - napr. pomocou štartovacej hodnoty
point once - e.g. by using default value).

Kotva
literatura
literatura

...

Literature

...

Odkazy
Oficiálna stránka MQTT protokolu Links
Official website of MQTT protocol http://mqtt.org
Špecifikácie a štandardy

Specifications and Standards
MQTT 3.1.1 špecifikácia specification http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html
ISO/IEC 20922:2016 http://www.iso.org/standard/69499.html

Popisy dátových formátov a Descriptions of Data Formats and API
www.loriot.io - Application API Data Format https://www.loriot.io/home/documentation.html#docu/app-data-format
www.thethingsnetwork.org - API Reference https://www.thethingsnetwork.org/docs/applications/mqtt/api.html

Kotva
revizie
revizie

...

Document revisions

...

  • Ver. 1.0 - 8. august August 8th, 2017 - vytvorenie dokumentudocument creation.


Info
titleSúvisiace stránky:

Komunikačné protokolyCommunication Protocols