Porovnávané verzie

Kľúč

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

Supported device types and versions 
About the MQTT Sparkplug protocol
Communication line configuration
Communication line parameters
Communication station configuration
I/O tag configuration
Tell commands
Literature
Document revisions

...

The protocol is an implementation of the MQTT 3.1.1 standard (October 2014) and the MQTT 5.0 standard (March 2019). MQTT protocol is a client/server protocol of a subscribe/publish type. It is simple, has little overhead, and is easy to implement. It is used for M2M communication (Machine to Machine) and in the IoT context (Internet of Things). The MQTT server is also called the MQTT broker.
D2000 KOM implements the client part of the protocol. The protocol is implemented on a TCP/IP line. TCP/IP-TCP and TCP/IP-TCP Redundant lines. MQTTS (Secure MQTT, MQTT over TLS) is also supported - either directly in the D2000 KOM process (using TLS settings on TCP/IP-TCP and TCP/IP-TCP Redundant lines) or via the stunnel utility.
For the transfer of LoRaWAN data encapsulated within the MQTT protocol, see LoRaWan protocol description.

The communication was tested/deployed against:

Note: communication with the cloud liveobjects.orange-business.com via WebSockets (wss://liveobjects.orange-business.com:443/mqtt) was also tested. The program https://github.com/jimparis/unwebsockify.git was used as a WSS wrapper. This program started with the following parameters:
./unwebsockify.py --port 1883 --listen 172.16.0.1 wss://liveobjects.orange-business.com:443/mqtt
The D2000 KOM process connected to address 172.16.0.1 on port 1883. The WSS wrapper connected to the defined URL and wrapped the MQTT communication data in a WebSocket envelope.

...

  • QoS_0 - PUBLISH message is not confirmed, it may be lost
  • QoS_1 - PUBLISH message is confirmed by the other side's PUBACK, it may be duplicated
  • QoS_2 - PUBLISH message is confirmed by the 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. The D2000 KOM process considers the writing of the output tag to be successfully finished depending on the QoS:

  • QoS_0after the data is successfully sent via the TCP connection
  • QoS_1 - after receiving PUBACK
  • QoS_2 - after receiving PUBCOMP

 

The MQTT communication starts with the CONNECT message sent by the client (D2000 KOM). The message contains User Name, Passwordand other parameters, from which only Clean Session Flag and Client ID can be modified (parameter Will Flag is not used, as well as Will QoS and Will Retain, parameter Keep Alive is set to 0). The server replies with a CONNACK message with a return code that contains information about the success of the connect operation.

Then the client sends a SUBSCRIBE message with a filter of topics (Topic Filter parameter), specifying which topics it is interested in, and with the required maximum level of confirmation (parameter Subscribe QoS).

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.

...

  • Communication line category: TCP/IP-TCP.
  • Host: IP address of MQTT server (or redundant addresses separated by a comma or semicolon).
  • Port: the default port number is 1883 or 8883 for the encrypted SSL/TLS variant.
  • Line number: unused, set the value to 0.

Note: The default port for the MQTT protocol is 1883 or 8883 for the SSL/TLS version. D2000 KOM does not contain an implementation of the SSL/TLS protocol variant, but it is possible to configure it by using the stunnel utility http://www.stunnel.org working in a client mode (client = yes). Stunnel 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).

Forced disconnection: If all stations on the line are in the simulation mode or the communication is stopped for them, the line will be disconnected (the communication socket will be closed). If the simulation is disabled for at least one station and the communication is not stopped for it (the Parameters tab of the Station type object), the line will be connected again.

...

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

Table 1

...

Unique client identifier (Client Identifier) sent within the CONNECT message.
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) returned an error if the Client ID was blank and Clean Session Flag=NO.

Note: a specific MQTT broker (PIXII.COM) identified clients only by Client ID. In practice, this meant that two different D2000 systems that connected to the same broker were considered as one client, and the broker closed an existing connection that it considered old when a new connection was established. After setting the Client ID to a unique value, the communications started to work without connection breakdowns.

...

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 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.

...

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 (until time Reply Timeout).

A value of 0 turns off sending the PING request messages. The parameter allows detection of TCP connection failure.

...

The setting of message parsing:

  • Text only - the message is not parsed, it is assigned to the I/O tag with address IN_TOPIC
  • JSON - the message is parsed as JSON data. If there is an I/O tag with address IN_TOPIC, the whole message will be assigned to it.
    If there are I/O tags with addresses JA=json_address, they will be populated with the appropriate data from the JSON message. If no such addresses exist in the message, the I/O tags will be invalidated.

...

  • UNIX - the numeric value represents the number of seconds from epoch 00:00:00 01.01.1970 UTC.
  • UNIXMS - the numeric value represents the number of milliseconds from epoch 00:00:00.000 01.01.1970 UTC.

...

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 the handling of problematic behavior of the MQTT server.

...

A timeout of a single reading from a TCP connection. D2000 KOM repeats reading of spontaneous data Max. Wait Retry 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 the D2000 KOM process at the expense of a higher CPU load when the MQTT server has no data.
Note: if a lot of messages come from the MQTT server and the D2000 KOM also needs to write values, we recommend setting a lower parameter value (e.g. 0.005 sec) so that writing is not blocked by reading (in any case, after 10 received messages, there is an interruption during which the accumulated writes can be performed).

...

  • Communication protocol "MQTT Client Protocol".
  • Station address: the station address corresponds to the Topic field in the PUBLISH message received from the MQTT server. The address can be a specific Topic, a regular expression, a # character representing all Topics, or a topic .* representing all Topics that are not suitable for other stations. The processing priority is as follows:
    • If there is a station with address # on the line, all messages are directed to its I/O tags and no further search is performed.
    • Otherwise, all other stations on the line are searched (with the exception of the .* address). If the Topic matches the address of a station, the message is directed to that station and no further search is performed.
    • Otherwise, all other stations on the line are searched (with the exception of the .* address), and their address is evaluated as a regular expression. If the Topic matches the station address, the message is directed to that station and no further search is performed.
      Stations are searched in descending order (by station address), so more specific terms go first (e.g., status/battery before status/batt.*)
    • Finally, if there is a station with a .* address, the message is addressed to it.
  • Polling parameters on the Time parameters tab - recommended value is Delay=0.

Station protocol parameters

Communication station - configuration dialog box - "Protocol parameters" tab.
They influence some of the optional parameters of the protocol.

Table 2

...

Meaning

...

Will topic of the device. If this parameter is set and a message with the same topic is received, the station will go into a communication error (StHardErr) and the values of the I/O tags will be invalidated. In this way, it is possible to emulate the standard behavior that occurs when there is a communication error with the device (even if the communication between the D2000 Kom process and the MQTT broker is functional).

...

Content of the Will message. If this parameter is set and a message with the same topic as defined by the Station Will Topic parameter is received, the Payload must also be the same. If this parameter is an empty string, matching the topic with the Station Will Topic parameter is sufficient.
Note: this parameter was implemented due to MQTT brokers sending messages with the same Topic when connecting/disconnecting the device, the difference being only in the Payload.

...

Possible value types of I/O tags: Ci, Co, TxtI, TxtO, Qi, Ci, Co, Ai, Ao, Di, Do, TiR, ToR, TiA, ToA.

...

TxtI, TxtO, Qi,
Ci, Co,
Ai, Ao,
Di, Do,
TiR, ToR

...

If Payload Type=JSON, the message is parsed as JSON data. The json_address value specifies the name of the JSON field whose value is to be assigned to the I/O tag
For JSON messages that can be structured, the syntax level1.level2.level3 ... is supported, e.g. rx.current, and if they contain fields (indexed from 1) also syntax level1[index1].level2[index2].level3 ... is possible, e.g. rx.gwrx[1].time.
Since the JSON message itself can be an array, the address can also start with an index, e.g. JA=[1].batt_cell_v_avg

For other examples, see the description of the LoRaWAN protocol's Envelope type I/O tags.

...

Sparkplug 3.0.0 standard (Sparkplug B MQTT Payload) is also supported. Support includes:

  • Connecting to the MQTT broker as a Host Application (data consumer, in Payload Type = Sparkplug Host mode):
    • reading simple value types
    • reading arrays (with support for the Destination column)
    • writing simple value types
    • reading of template items (UDT)
    • reading of dataset items
    • support for metric aliases
    • compression support (GZIP, DEFLATE)
    • browsing - finding a list of metrics
  • Connecting to an MQTT broker as an Edge Node (data producer, in Payload Type = Sparkplug Edge Node mode):
    • publishing values ​​with simple types
    • processing commands (NCMD, DCMD) with simple value types
    • processing commands (NCMD, DCMD) with template (UDT) items
    • processing commands (NCMD, DCMD) with dataset items
    • processing commands (NCMD, DCMD) with arrays
    • processing of the NCMD command with the Node Control/Next Server metric (connecting to the next MQTT server, if several are configured on the line)
    • processing of the STATE message with the content online=false, which comes from the Primary Host Application (disconnecting from the MQTT server and trying another one, if several are configured on the line - searching for an MQTT server with a connected Primary Host Application)
    • support for metric aliases

The communication was tested/deployed with:

Note: communication with the cloud liveobjects.orange-business.com via WebSockets (wss://liveobjects.orange-business.com:443/mqtt) was also tested. The program https://github.com/jimparis/unwebsockify.git was used as a WSS wrapper. This program started with the following parameters:
./unwebsockify.py --port 1883 --listen 172.16.0.1 wss://liveobjects.orange-business.com:443/mqtt
The D2000 KOM process was connected to address 172.16.0.1 on port 1883. The WSS wrapper was connected to the defined URL and wrapped the MQTT communication data in a WebSocket envelope.


Each PUBLISH message contains a topic (Topic), data (Payload), and level of confirmation (QoS). PUBLISH 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
The protocol defines the following levels of confirmation of PUBLISH messages - QoS (Quality of Service):

  • QoS_0 - PUBLISH message is not confirmed; it may be lost
  • QoS_1 - PUBLISH message is confirmed by the other side's PUBACK, it may be duplicated
  • QoS_2 - PUBLISH message is confirmed by the 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. The D2000 KOM process considers the writing of the output tag to be successfully finished depending on the QoS:

  • QoS_0after the data is successfully sent via the TCP connection
  • QoS_1 - after receiving PUBACK
  • QoS_2 - after receiving PUBCOMP

 

The MQTT communication starts with the CONNECT message sent by the client (D2000 KOM). The message contains User Name, Passwordand other parameters, which can be modified:  Clean Session FlagClient ID, Will Flag, Will QoSWill RetainKeep Alive, and Will Topic. The server replies with a CONNACK message with a return code that contains information about the success of the connect operation.

Then the client sends a SUBSCRIBE message with a filter of topics (Topic Filter parameter), specifying which topics it is interested in, and with the required maximum level of confirmation (parameter Subscribe QoS).

The server responds with a return code that contains information about the success and the 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 the 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.

Kotva
sparkplug
sparkplug
About the MQTT Sparkplug protocol

Sparkplug's MQTT protocol defines 3 groups of applications:

  • Edge Node - Supports the MQTT protocol and connects to the MQTT server. It sends him data obtained from the Device, its own, or aggregated data.
  • Device/Sensor - Represents a physical or logical device connected to an Edge Node and providing process data or metrics.
  • Host Application - Represents a data consumer (SCADA/MES system, Historian, analysis tool) that connects to the MQTT server and receives MQTT data from the Edge Node/Device and, if necessary, commands.

The D2000 can operate in Host Application mode or Edge Node mode (plus one or more Device/Sensor devices) according to the Payload Type line parameter. In Edge Node mode, exactly one station with an Edge Node address and optionally additional stations with slave Device/Sensor addresses must be configured on the line.

Image Added

MQTT Sparkplug defines the following message types:

  • NBIRTH – Birth certificate for Sparkplug Edge Nodes (information about the connection of the Edge Node to the MQTT Server)
  • NDEATH – Death certificate for Sparkplug Edge Nodes (information about the loss of the connection between the MQTT Server and the Edge Node)
  • DBIRTH – Birth certificate for Devices (information about Device connection to Edge Node)
  • DDEATH – Death certificate for Devices (information about the loss of Edge Node connection with Device)
  • NDATA – Edge Node data message (data from Edge Node)
  • DDATA – Device data message (data from Device)
  • NCMD – Edge Node command message (Host Application command for Edge Node)
  • DCMD – Device command message (Host Application command for Device)
  • STATE – Sparkplug Host Application state message (information from the state of the Host Application for the Edge Node/Device [online/offline]).

MQTT Sparkplug defines a Topic syntax for all message types, which has the form namespace/group_id/message_type/edge_node_id/[device_id], where:

  • namespace is a spBv1.0 constant (for Sparkplug B)
  • group_id is an arbitrary name of a logical group (e.g. by device type, operation, organizational structure, etc.)
  • message_type is the message type
  • edge_node_id is the identifier of the Edge Node
  • device_id is the identifier of the Device (only if the message is from/for a Device)

Examples:

  • spBv1.0/Sparkplug Devices/DDATA/Marvin/Sensor1
  • pBv1.0/MIMIC/DDATA/20:19:AB:F4:0E:0D/sensor11
  • spBv1.0/SparkplugDevices/NBIRTH/JsonScada

Note: STATE messages have a Topic of the form spBv1.0/STATE/sparkplug_host_id, where sparkplug_host_id is the unique name of the host application  (Sparkplug Host ID parameter).

Examples:

  • spBv1.0/STATE/CFGHUB2023
  • spBv1.0/STATE/D2Kom

All message types except STATE have a binary Sparkplug payload. The STATE messages have a JSON payload - they contain only the items "online" (True/False value) and "timestamp" (time stamp in milliseconds).

The Sparkplug payload contains metrics - each required metric can be configured into a single I/O tag. The metric contains a text identifier (specified in the I/O tag configuration as sparkplug_address), value type, value (simple/array/structured), optionally a timestamp, and other attributes. D2000 supports working with simple values ​​and array values ​​- the first field item is stored in the I/O tag; it is possible to configure the Destination Columnfor the I/O tag, in which all array items are stored (or the first N, if the structure does not have enough rows). D2000 can read items of template (UDT) and Dataset metrics.
Note: If a metric arrives with the is_null flag set, the I/O tag will have the Invalid value.


Recommended settings for optimizing data flow

  • If the MQTT server supports Topic aliases, use MQTT Version = MQTT 5.0, and set Topic Alias Maximum to a value greater than the number of stations on the line (for Payload Type = Sparkplug Edge Node) or greater than the number of topics expected from the MQTT broker (for Payload TypeText only / JSON). On the MQTT broker side, ensure that its Topic Alias ​​Maximum value is greater than the number of topics that will be sent to the D2000 KOM process, so that numeric aliases can be used instead of text topics.
    Note: the Topic Alias ​​Maximum value that the MQTT broker sends when connecting as a parameter of the CONNACK message is visible in the communication logs:
    09:31:12.086 13-05-2025|D|MQTT> CONNACK Property # 1 Topic Alias Maximum ( 34)
    09:31:12.087 13-05-2025|T|MQTT> Recv:<00><0A>
    09:31:12.088 13-05-2025|D|MQTT> CONNACK Property value= 10

  • Set Subscribe QoS = QoS_0 to not require acknowledgments for PUBLISH messages (unless they are needed for some reason). Additionally, if TLS is also active, this will cause a small packet (e.g., PUBACK for QoS_1) to be encrypted and result in a larger encrypted packet.

  • Use aliases for metrics (for Payload Type = Sparkplug Edge Node): automatically using the Sparkplug Alias Mode=Automatic (HOBJ) parameter or manually using the SAL=alias item in the I/O tag address. If you use manual aliases, use low numbers (aliases 0-127 are encoded as 1 byte).

  • For Payload Type = Sparkplug Edge Node: if there are many changes to the output I/O tags, we recommend setting the Batch Size parameter to a larger value than the default (10) and possibly increasing the Delay parameter in the station's time parameters. This will cause fewer messages to be generated (and each will contain multiple metrics), which reduces the overhead required to transmit one metric. If specific I/O tags change frequently, the message may contain several values ​​for the same I/O tag (with timestamps). The disadvantage is the delay in the values.


Kotva
komunikacna_linka
komunikacna_linka
Communication line configuration

...

  • Communication line category: TCP/IP-TCP or TCP/IP-TCP Redundant.
  • Host: IP address of MQTT server (or redundant addresses separated by a comma or semicolon).
    Note: In Payload Type = Sparkplug Edge Node mode, the Node Control/Next Server metric is supported, which can be used to command the D2000 KOM process to connect to the next MQTT server (if multiple servers are specified).
  • Port: the default port number is 1883 or 8883 for the encrypted SSL/TLS variant.
  • Line number: unused, set the value to 0.

Note: The default port for the MQTT protocol is 1883 or 8883 for the SSL/TLS version. D2000 KOM contains an implementation of the SSL/TLS protocol variant; it is also possible to configure it by using the stunnel utility http://www.stunnel.org working in a client mode (client = yes). Stunnel running on the same computer as the D2000 KOM should listen to the 1883 local port, and after connecting the D2000 KOM process to the port, it should encrypt the communication using SSL/TLS and send it to the target MQTT server (typically on port 8883).

Note: When using an SSL/TLS connection, you must pay attention to the expiration of the certificates used. The expiration date can be found on Linux with the command

openssl x509 -text -in file.crt | grep "After"


Notes on MQTT broker redundancy

If the TCP/IP-TCP line is configured, one TCP connection is created, which can be directed to one of multiple configured IP addresses.

If the TCP/IP-TCP Redundant line is configured, two TCP connections are created (to 2 MQTT brokers), each of which can be directed to one of multiple configured IP addresses. The D2000 KOM process receives values from both MQTT brokers and sends all values of the output I/O tags to both MQTT brokers. The write is considered successful if the value is successfully sent to at least one MQTT broker (in the case of confirmation, if "Subscribe QoS" > QoS_0, if it is confirmed by at least one of the MQTT brokers). Such a configuration allows you to configure a redundant system in which the D2000 KOM connects to two redundant MQTT brokers and the other side to at least one MQTT broker, while the MQTT brokers do not have to form a "cluster", i.e. synchronize messages with each other (so the simple and free Eclipse Mosquitto can also be used - see configuration example).


Forced disconnection: If all stations on the line are in the simulation mode or the communication is stopped for them, the line will be disconnected (the communication socket will be closed). If the simulation is disabled for at least one station and the communication is not stopped for it (the Parameters tab of the Station type object), the line will be connected again.

In Payload Type = Sparkplug Edge Node mode, if communication on the Edge Node station is stopped, the line will be disconnected (even if Device type substations have communication stopped). If communication on the Device station is stopped and the Edge Node station is communicating, the D2000 KOM will send a DDEATH message and after turning on the Device station, it will send a DBIRTH message.

Kotva
linka_parametre
linka_parametre
Communication line parameters

...

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

Table 1

ParameterDescriptionUnit/sizeDefault value

Kotva
fd
fd
Full Debug

Activates detailed debug information about sending and receiving values.YES/NONO

Kotva
mv
mv
MQTT Version

The version of the MQTT protocol that will be used to connect to the MQTT server. It is possible to use the older MQTT 3.1.1 standard (October 2014) or the newer MQTT 5.0 standard (March 2019). MQTT brokers usually support both standards; the older standard is simpler and more economical. On the other hand, MQTT 5.0 allows message size reduction by using Topic Aliases.

MQTT 3.1.1

MQTT 5.0

MQTT 3.1.1
Kotva
un
un
User Name
User name used in a CONNECT message to connect to the MQTT server.-
Kotva
pw
pw
Password
Password used in a CONNECT message to connect to the MQTT server.-
Kotva
tc
tc
Topic Filter
The name of one topic or a multiple-topic filter sent within the SUBSCRIBE message. Using the filter, the MQTT client specifies topics for 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, and a hash (#) character is used as a mask for multiple levels.
Examples of filter: a/b , level1/+ , # , +/+/+/up
Note: the change of the Topic Filter parameter will be reflected after restarting the communication, e.g., due to the breakdown of the TCP connection, as long as all stations on the line are switched off (StOff) and switched on again, or after a restart of the KOM process. In the first two cases, the message UNSUBSCRIBE is sent to the original Topic Filter and then SUBSCRIBE to the new Topic Filter (this can be important in so-called persistent sessions when the Client ID parameter is specified and the MQTT server remembers the state of the client even after the TCP connection is broken).
Note: for Payload Type = Sparkplug Host, the filter spBv1.0/# is sufficient to receive all Sparkplug messages. It is also possible to specify an empty filter, as by default, SUBSCRIBE is generated for BIRTH/DATA/DEATH messages derived from station addresses that are in Sparkplug format (group_id/edge_node_id/[device_id]) are sent.
Note: for Payload Type = Sparkplug Edge Node, a SUBSCRIBE message is automatically sent to all NCMD/DCMD topics derived from the addresses of Edge Node/Device stations configured on the line.

Example:

  • For an Edge Node station with the address myGroup/myEdgeNode, a SUBSCRIBE message is sent to the topic spBv1.0/myGroup/NCMD/myEdgeNode
  • For a Device station with the address myGroup/myEdgeNode/myDevice1, a SUBSCRIBE message is sent to the topic spBv1.0/myGroup/DCMD/myEdgeNode/myDevice1

Note: Payload Type = Sparkplug Edge Node, a SUBSCRIBE message is automatically sent to the topic spBv1.0/STATE/<primaryHostApplication> if the Sparkplug Host ID parameter is specified (<primaryHostApplication> is the value of this parameter), so that the D2000 KOM process is informed about the connection/disconnection of the Primary Host Application. If a STATE message about the Primary Host Application disconnection is received (STATE message with online=false) and multiple IP addresses are specified in the line configuration, the D2000 KOM process disconnects from the current MQTT server and tries other MQTT servers until it finds one to which the Primary Host Application is connected (STATE message with online=true).

-#

Kotva
sq
sq
Subscribe QoS

The desired maximum level of validation (QoS) sent within the SUBSCRIBE message.
The MQTT server can then send PUBLISH messages with such or lower levels 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 at QoS_1, and 4 at QoS_2).
Note: For Payload Type = Sparkplug Edge Node, QoS_1 is always used.
QoS_0
QoS_1
QoS_2
QoS_1
Kotva
ci
ci
Client ID

Unique client identifier (Client Identifier) sent within the CONNECT message.
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) returned an error if the Client ID was blank and Clean Session Flag=NO.

Note: Some MQTT brokers (PIXII.COM, Eclipse Mosquitto) identified clients only by Client ID. In practice, this meant that two different D2000 systems that connected to the same broker were considered as one client, and the broker closed an existing connection that it considered old when a new connection was established, or it did not allow a new connection to be created and returned the error Connection Refused, identifier rejected (2).
After setting the Client ID to a unique value, the communications started to work without connection breakdowns.

-D2000kom
Kotva
cs
cs
Clean Session Flag

Parameter Clean Session Flag of the CONNECT message. The NO value means that the server uses the current session state (connection) - e. g. after the 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.
Note: If Payload Type = Sparkplug Host and the Sparkplug Host ID parameter is not empty, this parameter is ignored, and Clean Session Flag is set to YES (see the description of the Sparkplug Host ID parameter).
Note: If Payload Type = Sparkplug Edge Node, this parameter is ignored, and Clean Session Flag is set to YES (see the description of the Sparkplug Host ID parameter).

YES/NONO

Kotva
pq
pq
Publish QoS

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 the OUT_VALUE address. The higher the confirmation level, the more messages between the client and server are exchanged (1 for QoS_0, 2 for QoS_1, and 4 for QoS_2).
Note: If Payload Type = Sparkplug Host or Sparkplug Edge Node, this parameter is ignored and QoS_0 is used.
QoS_0
QoS_1
QoS_2
QoS_0

Kotva
pr
pr
Publish Retain

Setting the Retain flag used when sending PUBLISH messages by the D2000 KOM process. Activating the Retain flag causes the last message sent by the D2000 KOM process to be available on the MQTT server to other clients immediately after they are connected, as well as after the D2000 KOM process is disconnected.
Note: If Payload Type = Sparkplug Host or Sparkplug Edge Node, this parameter is ignored, and Retain=False is used.
YES/NONO

Kotva
ka
ka
Keep Alive

Parameter Keep Alive sent as part of a CONNECT message.
If it is non-zero, it indicates the interval in seconds in which the client must send a message (if it does not send it, the MQTT broker can disconnect the client). If it has no data to send, it will at least send a PING request. A zero value means that the MQTT broker does not require periodic messaging.

The recommended Keep Alive value is several minutes.

The D2000 KOM process sends PING requests according to the settings of the Keep Alive and Ping Interval parameters (whichever interval expires first).

0-65535 sec0

Kotva
pi
pi
Ping Interval

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 (until time Reply Timeout).

A value of 0 turns off sending the PING request messages. The parameter allows detection of TCP connection failure.

0-3600 sec60

Kotva
pt
pt
Payload Type

The setting of message parsing:

  • Text only - the message is not parsed, it is assigned to the I/O tag with the address IN_TOPIC
  • JSON - the message is parsed as JSON data. If there is an I/O tag with the address IN_TOPIC, the whole message will be assigned to it.
    If there are I/O tags with addresses JA=json_address, they will be populated with the appropriate data from the JSON message. If no such addresses exist in the message, the I/O tags will be invalidated.
  • Sparkplug Host - the message is parsed as Sparkplug B payload (binary coded), The D2000 KOM process behaves as a Host Application (data consumer, sends CMD and STATE messages).
  • Sparkplug Edge Node- the message is parsed as Sparkplug B payload (binary coded), The D2000 KOM process behaves as an Edge Node (data producer, sends BIRTH and DATA messages).

Text only

JSON

Sparkplug Host

Sparkplug Edge Node

Text only

Kotva
tf
tf
Time Field Name

If Payload Type=JSON, the name of the field with a timestamp. If the field name is not specified or the field is not found, the current time is assigned to the values.
For more information on the field name format, see  I/O tags with addresses JA=json_address.
--
Kotva
tm
tm
Time Mask
If Payload Type=JSON, the mask for parsing a value in the JSON field with a timestamp. Special masks are:
  • UNIX - the numeric value represents the number of seconds from epoch 00:00:00 01.01.1970 UTC.
  • UNIXMS - the numeric value represents the number of milliseconds from epoch 00:00:00.000 01.01.1970 UTC.
  • ISO8601 - text format according to ISO 8601, equivalent to specifying the mask 'yyyy-mm-ddThh:mi:ss.mssZ' (e.g. 2025-05-28T05:51:10.112Z)

Note: Whether the time is interpreted as local or UTC with a configured offset depends on the time station parameters settings. This rule does not apply when using the special masks listed above, when UTC time with a zero offset is always used.

-yyyy-mm-dd hh:mi:ss.mss

Kotva
imt
imt
Ignore Missing Time

If Payload Type=JSON, ignoring a missing timestamp - if it is not present in the JSON payload, no warning will be issued.YES/NONO

Kotva
wf
wf
Will Flag

Parameter Will Flag of a CONNECT message. A value of Yes means that the server will send a Last Will message to interested parties if the connection to the D2000 KOM process is lost.
Note: If Payload Type = Sparkplug Host and the Sparkplug Host ID parameter is not empty, this parameter is ignored and Last Will will be sent (see the description of the Sparkplug Host ID parameter).
Note: If Payload Type = Sparkplug Edge Node, this parameter is ignored and Last Will will be sent (see the description of the Sparkplug Host ID parameter).
YES/NONO

Kotva
wq
wq
Will QoS

The acknowledgment level (QoS) used when sending a Last Will message in the event of a loss of connection to the D2000 KOM process.
Note: If Payload Type = Sparkplug Host and the Sparkplug Host ID parameter is not empty, this parameter is ignored, and QoS_1 level will be set (see the description of the Sparkplug Host ID parameter).
Note: If Payload Type = Sparkplug Edge Node, this parameter is ignored, and QoS_1 level will be set (see the description of the Sparkplug Host ID parameter).
QoS_0
QoS_1
QoS_2
QoS_0

Kotva
wr
wr
Will Retain

The setting of the Retain flag used when sending a Last Will message if the connection to the D2000 KOM process is lost.
Note: If Payload Type = Sparkplug Host and the Sparkplug Host ID parameter is not empty, this parameter is ignored and Retain is set to YES (see the description of the Sparkplug Host ID parameter).
Note: If Payload Type = Sparkplug Edge Node, this parameter is ignored and Retain is set to NO (see the description of the Sparkplug Host ID parameter).
YES/NONO

Kotva
wtp
wtp
Will Topic

The topic used to send the Last Will message if the connection to the D2000 KOM process is lost.
Note: If Payload Type = Sparkplug Host and the Sparkplug Host ID parameter is not empty, this parameter is ignored (see the description of the Sparkplug Host ID parameter).
Note: If Payload Type = Sparkplug Edge Node, this parameter is ignored, and Topic is set according to the Sparkplug standard (see the description of the Sparkplug Host ID parameter).
-

Kotva
wm
wm
Will Message

Contents of the Last Will report if the connection to the D2000 KOM process is lost.
Note: If Payload Type = Sparkplug Host and the Sparkplug Host ID parameter is not empty, this parameter is ignored (see the description of the Sparkplug Host ID parameter).
Note: If Payload Type = Sparkplug Edge Node, this parameter is ignored, and Last Will is set according to the Sparkplug standard (see the description of the Sparkplug Host ID parameter).
-
Kotva
rt
rt
Reply Timeout

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 the handling of problematic behavior of the MQTT server.

sec20
Kotva
wt
wt
Wait Timeout

A timeout of a single reading from a TCP connection. D2000 KOM repeats reading of spontaneous data Max. Wait Retry 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 the D2000 KOM process at the expense of a higher CPU load when the MQTT server has no data.
Note: if a lot of messages come from the MQTT server and the D2000 KOM also needs to write values, we recommend setting a lower parameter value (e.g. 0.005 sec) so that writing is not blocked by reading (in any case, after 10 received messages, there is an interruption during which the accumulated writes can be performed).

sec0.100
Kotva
mwr
mwr
Max. Wait Retry
The number of repetitions of reading from the TCP connection. See the description of the Wait Timeout parameter.-3

Kotva
pe
pe
Payload Encoding

Payload field encoding. The MQTT protocol does not specify the content of the Payload field; the ISO-8859-1 standard encoding is suitable for both text and binary content, and UTF-8 is suitable if UTF-8 encoded texts are transmitted. Currently supported encodings are:

  • UTF-8

  • ISO-8859-1

  • Windows-1250

-

ISO-8859-1

MQTT 5.0 Parameters

Kotva
tam
tam
Topic Alias Maximum

Number of Topic Aliases that can be sent by the MQTT broker (parameter is sent in the CONNECT message). The value 0 (default) means that Topic Aliases are not used. The parameter is used only for MQTT Version = MQTT 5.0.

Topic Aliases are numeric identifiers from the interval <1 ... Topic Alias ​​Maximum>, which are sent by the D2000 KOM and the MQTT Broker instead of text identifiers.

Note: In the CONNACK message (response to CONNECT), the MQTT broker optionally sends its value "Topic Alias ​​Maximum", which has the meaning of the number of Topic Aliases that can be sent by the D2000 KOM process (e.g. test.mosquitto.org sends the value 10). D2000 KOM uses Topic Aliases only if the value of its configuration parameter Topic Alias ​​Maximum is non-zero.
Note: Topic Aliases are sent by the D2000 KOM process only when writing values ​​(NDATA/DDATA/NCMD/DCMD), it does not use them for NBIRT/DBIRTH/NDEATH/DDEATH messages (within MQTT Sparkplug) due to alias saving.

00 - 65535

Sparkplug parameters

Kotva
rot
rot
Reorder Timeout

For Payload Type = Sparkplug Host: Timeout (in seconds) for the arrival of a missing NDATA/DDATA message(s). NDATA/DDATA messages contain a sequence number (0..255), while the NBIRTH message contains a sequence number of 0 (resets the sequence). If the D2000 KOM detects a gap in the sequence and the missing message(s) do not arrive within the Reorder Timeout, it sends an NCMD command with the metric 'Node Control/Rebirth' to the corresponding station, which causes the corresponding Edge Node to send an NBIRTH message (and DBIRTH messages for all its Devices). This parameter is implemented on the recommendation of the Sparkplug specification.
Note: Setting Reorder Timeout=0.000 disables missing message detection.

05.0000-59.999

Kotva
rum
rum
Report Unknown Metrics

The parameter activates listings of unknown metrics and topics that do not have their own stations, but end up at a station with the address ".*" (if there is any). The listings will be in the line log as error messages even if the debug on the line is turned off (to facilitate the addition of I/O tags).

YES/NONO

Kotva
nt
nt
Nonstandard Topic

For Payload Type = Sparkplug Host: Activation of parsing of non-standard SparkPlug topics.
The standard topic has the form 'namespace/group_id/message_type/edge_node_id/[device_id]' e.g. 'spBv1.0/Owner/DDATA/devicebase1/local_inputs'.
A non-standard topic has several levels instead of group_id, e.g., 'spBv1.0/Basel/Packaging/DDATA/Falcon11/plannedProductionQuantity'.
Note: writing to I/O tags on stations with a non-standard SparkPlug topic is not supported.

YES/NONO

Kotva
iuq
iuq
Ignore Unknown Quality

For Payload Type = Sparkplug Host: Within the metric, it is possible to define a property called Quality of type Int32. According to the Sparkplug standard, it must be one of the values ​​0=BAD, 192=GOOD, 500=STALE. Any other D2000 Kom process reports as an error. The Ignore Unknown Quality parameter can be used to suppress this error message.

YES/NONO

Kotva
bdm
bdm
Browse Dataset Mode

For Payload Type = Sparkplug Host:The parameter specifies which addresses of the Dataset metric are displayed when browsing:

  • Columns only: one address is displayed for each dataset column (e.g. Dataset[*]^ColA)
  • Items only: the address of each item is displayed (e.g. Dataset[1]^ColA, Dataset[2]^ColA, ...)
  • Columns + Items: addresses for both columns and items are displayed
-
Columns only

Kotva
is
is
Item Separator

For Payload Type = Sparkplug Host: Separator of individual levels in Templates used when entering the address of the I/O tag in Sparkplug mode.
The default value is "->", so the address of the I/O tag can be e.g. SA=Template1->SubTemplate2->Item. If the template name contains the pair "->", it is possible to replace this separator (e.g. "=>").


->

Kotva
hi
hi
Sparkplug Host ID

For Payload Type = Sparkplug Host:

Identifier of Host Application (D2000 is a Host Application). 
If specified, the D2000 KOM process will send a STATE message (with online=true) according to the MQTT Sparkplug standard after connecting to the MQTT server. This message announces that it is alive (equivalent to the NBIRTH and DBIRTH messages sent by Edge Nodes and Devices). At the same time, it sets the Will Topic/Will Message in the CONNECT message according to the Sparkplug standard (STATE message with online=false), with Will QoS=QoS_1, Will Retain=YES, Clean Session Flag=YES.
If the identifier is not specified, the D2000 KOM does not send the STATE message (and the Will parameters are configurable).
According to the MQTT Sparkplug standard, the identifier is mandatory for theSparkplug Host mode (without specifying it, the D2000 KOM process pretends to be an "anonymous" client and does not send a STATE message)..

For Payload Type = Sparkplug Edge Node:

Identifier of Primary Host Application (Identifier of the Host Application that is defined as primary - the most important - for this Edge Node).
If the identifier is specified, the D2000 KOM process waits for a STATE message after connecting to the MQTT server. When it is received and contains online=true, it sends an NBIRTH message with definitions and values ​​of all output I/O tags of the station corresponding to the Edge Node and optionally DBIRTH messages for stations corresponding to Device/Sensor devices (if such stations are configured). If the STATE message contains online=false (i.e., the Primary Host Application is not connected to the MQTT server), the D2000 KOM disconnects from the MQTT server and tries another MQTT server according to the communication line configuration, provided that multiple MQTT servers are configured. If a single MQTT server is configured, the D2000 KOM waits to receive a STATE message with online=true from the Primary Host Application and only then starts sending NBIRTH/DBIRTH/NDATA/DDATA messages. If the Store & Forward parameter is set and the Primary Host application is not connected to the MQTT server, changes to values are stored in memory (the same as when communication with the MQTT broker is not working).
If the identifier is not specified, the D2000 KOM process sends NBIRTH and possibly DBIRTH messages immediately after connecting to the MQTT server (and subsequently sends NDATA/DDATA messages with value changes).
According to the MQTT Sparkplug standard, the specification of the Primary Host Application is optional for theSparkplug Edge Node mode.
Note: Regardless of the value of the Sparkplug Host ID parameter, the D2000 KOM sets the Will Topic/Will Message in the CONNECT message according to the Sparkplug standard, with Will QoS=QoS_1, Will Retain=NO, Clean Session Flag=YES.

--

Kotva
sfl
sfl
Store & Forward

If Payload Type = Sparkplug Edge Node, the parameter enables Store & Forward functionality for all stations on the line. If communication with the MQTT broker is down, values ​​are stored in memory and sent with the is_historical flag when communication is restored.
Note: this setting can be changed for individual stations using the Store & Forward station parameter.

YES/NONO

Kotva
ctt
ctt
Convert Datatype/Timestamp to Text

Adding a textual representation of the value type (e.g., Int32) and a timestamp to the text I/O tag with IN_SP2JS address used to convert the Sparkplug payload to JSON for optional parsing in an ESL script.

YES/NONO

Kotva
komunikacna_stanica
komunikacna_stanica
Communication station configuration

...

  • Communication protocol "MQTT Client Protocol".
  • Polling parameters on the Time parameters tab - recommended value is Delay=0.
  • Station address: The station address corresponds to the Topic field in the PUBLISH message received from the MQTT server. The address can be a specific Topic, a regular expression, a # character representing all Topics, or a topic .* representing all Topics that are not covered by other stations. The processing priority is as follows
    Kotva
    prio_processing
    prio_processing
    :
    • If there is a station with address # on the line, all messages are directed to its I/O tags, and no further search is performed.
    • Otherwise, all other stations on the line are searched (except the .* address). If the Topic matches the address of a station, the message is directed to that station, and no further search is performed.
    • Otherwise, all other stations on the line are searched (except the .* address), and their address is evaluated as a regular expression. If the Topic matches the station address, the message is directed to that station, and no further search is performed.
      Stations are searched in descending order (by station address), so more specific terms go first (e.g., status/battery before status/batt.*)
    • Finally, if there is a station with a .* address, the message is addressed to it.

For a SparkPlug MQTT server, the Topic has the form 'namespace/group_id/message_type/edge_node_id/[device_id]', where message_type indicates the message type (e.g., DDATA, DBIRTH, DDEATH).

If Payload Type = Sparkplug Host: A regular expression (e.g., spBv1.0/Sparkplug Devices/.*/MyDevice/Sensor2) can be used instead of message_type to cover all message types. It is, however, recommended to omit the namespace and message_type parts and write the Topic in the abbreviated form group_id/edge_node_id/[device_id] (e.g., Sparkplug Devices/MyDevice/Sensor2).
Note: Disabling communication on all stations will cause communication to be disconnected from the MQTT broker.

If Payload Type = Sparkplug Edge Node: One station on the line should correspond to the Edge Node; its address must be in the form group/node (e.g., myGroup/myNode). There may be other stations corresponding to the Device/Sensor on the line, their addresses must be in the form group/node/device (e.g., myGroup/myNode/myDevice1), where group/node is the same as the address of the station corresponding to the Edge Node. According to the Sparkplug standard, these Device/Sensor stations belong to the corresponding Edge Node station (are its substations) and represent devices with which the Edge Node station communicates (e.g., via Modbus protocol).
Note: Disabling communication on the Edge Node station will cause communication to be disconnected from the MQTT broker.


Kotva
komunikacna_stanica_pozn
komunikacna_stanica_pozn
Note:
If Payload Type = Sparkplug Host and the station address is in abbreviated form, the station doesn't process commands (DCMD, NCMD). If it is in the form of a regular expression ('namespace/group_id/.*/edge_node_id/[device_id]'), the station also processes commands (including the command sent by the D2000 KOM process if Send Node Control/Rebirth=YES). Therefore, we recommend specifying the station address in abbreviated form. If it is also necessary to process commands (from other Host Applications), then create another station with an address in the form of a regular expression (e.g., spBv1.0/Sparkplug Devices/DCMD/MyDevice).
If Payload Type = Sparkplug Edge Node, the station processes commands (DCMD, NCMD) and ignores data messages (NDATA, DDATA, NBIRTH, DBIRTH).


The Browse button opens a browse dialog for the station address. As long as the communication is functional, a dialogue containing the Topics received so far will be displayed. The list of received topics can be cleared with the Refresh button.
Double-clicking on a particular line will insert the value from the Address column into the configuration of the station from which the browse dialog was opened.
Note: The Station column shows the station to which the Topic has been assigned (based on the abovementioned processing priorities). For Sparkplug addresses, the abbreviated form of the address is displayed.

Image Added

Station protocol parameters

Communication station - configuration dialog box - "Protocol parameters" tab.
They influence some of the optional parameters of the protocol.

Table 2

KeywordFull name

Meaning

UnitDefault value

Kotva
ssa
ssa
SSA

Subscribe Station Address

If this parameter has the value YES, the Topic related to the station address is also added to the SUBSCRIBE message:

  • For Payload Type = Sparkplug Host, the following topics are created from the station address:
    • NDATA/DDATA topic (e.g., spBv1.0/myGroup/NDATA/myEdgeNode or spBv1.0/myGroup/DDATA/myEdgeNode/myDevice1)
    • NBIRTH/DBIRTH topic (e.g., spBv1.0/myGroup/NBIRTH/myEdgeNode or spBv1.0/myGroup/DBIRTH/myEdgeNode/myDevice1)
    • NDEATH/DDEATH topic (e.g., spBv1.0/myGroup/NDEATH/myEdgeNode or spBv1.0/myGroup/DDEATH/myEdgeNode/myDevice1)
  • For Payload Type = Sparkplug Edge Node, the parameter is ignored - NCMD/DCMD topic is always created (e.g., spBv1.0/myGroup/NCMD/myEdgeNode or spBv1.0/myGroup/DCMD/myEdgeNode/myDevice1)
  • For Payload Type = Text only or JSON, the topic is the same as the station address (i.e., it makes no sense to set this parameter on stations that have addresses in the form of a regular expression, e.g., status/batt.*)
YES/NONO

Kotva
swt
swt
SWT

Station Will Topic

Will topic of the device. If this parameter is set and a message with the same topic is received, the station will go into a communication error (StHardErr) and the values of the I/O tags will be invalidated. In this way, it is possible to emulate the standard behavior that occurs when there is a communication error with the device (even if the communication between the D2000 Kom process and the MQTT broker is functional).
If Payload Type = Sparkplug Host, it is not necessary to enter this parameter - if an NDEATH/DDEATH message arrives with a Topic that matches the station address, the station will go into a communication error.



Kotva
swp
swp
SWP

Station Will Payload

Content of the Will message. If this parameter is set and a message with the same topic as defined by the Station Will Topic parameter is received, the Payload must also be the same. If this parameter is an empty string, matching the topic with the Station Will Topic parameter is sufficient.
Note: This parameter was implemented because MQTT brokers send messages with the same Topic when connecting/disconnecting the device, the difference being only in the payload.



Kotva
fpt
fpt
FPT

Payload Type

The setting of message parsing (overriding the line parameter Payload Type):

  • Default - the line parameter Payload Type is respected
  • Text only - the message is not parsed, it is assigned to the I/O tag with the address IN_TOPIC
  • JSON - the message is parsed as JSON data. If there is an I/O tag with the address IN_TOPIC, the whole message will be assigned to it.
    If there are I/O tags with addresses JA=json_address, they will be populated with the appropriate data from the JSON message. If no such addresses exist in the message, the I/O tags will be invalidated.
  • Sparkplug - the message is parsed as Sparkplug B payload (binary coded). Based on the line parameter Payload Type, this is Sparkplug Host/Edge Node mode, Sparkplug Host by default.
Default
Text only
JSON
Sparkplug
Default

Kotva
ftf
ftf
FTF

Time Field Name

If Payload Type = JSON, the name of the field with a timestamp - overriding the line parameter Time Field Name--

Kotva
ftm
ftm
FTM

Time Mask

Mask for parsing a value in the field with a timestamp - overriding the line parameter Time Mask.

Note: Whether the time is interpreted as local or UTC with a configured offset depends on the time station parameters settings.

--

Sparkplug parameters



Kotva
sr
sr
SR

Send Node Control/Rebirth

If Payload Type = Sparkplug Host, when connecting to the MQTT server, a command (NCMD or DCMD) with the metric 'Node Control/Rebirth' is sent to the SparkPlug station. The response should be a message (NBIRTH/DBIRTH) with all current metrics.

YES/NOYES

Kotva
bs
bs
BS

 Batch Size

If Payload Type = Sparkplug Edge Node: The parameter specifies the maximum number of values ​​(metrics) that are sent in one message (NDATA/DDATA). The parameter allows for optimization of the number of MQTT messages (more smaller or fewer larger with a delay). Reading values ​​from the station (ReadAllPoints function) will cause the buffered values ​​to be sent even if the configured maximum has not yet been reached (i.e., a larger time delay in the station parameters will cause more values ​​to be buffered).

1-100010

Kotva
sf
sf
SF

Store & Forward

The parameter allows you to change the Store & Forward functionality, which is defined for all stations on the line by the Store & Forward line parameter. The value Default means using the settings configured on the line.

Default
False
True
Default

Kotva
sfbs
sfbs
SFBS

Store & Forward Batch Size

If the Store & Forward functionality is active (see Store & Forward parameter), the parameter specifies the maximum number of historical values ​​sent in one message (NDATA/DDATA) after communication is resumed.

1-100010

Kotva
sam
sam
SAM

Sparkplug Alias Mode

If Payload Type = Sparkplug Edge Node, the parameter specifies the alias usage mode. Aliases are numeric (integer - Int64) identifiers, used optionally in data and command messages (NDATA/DDATA/NCMD/DCMD) instead of text identifiers, due to the message size reduction. If used, they are listed in the NBIRTH/DBIRTH message together with text identifiers. Aliases must be unique within all I/O tags belonging to one station. 

  • Default (SAL=alias) - Aliases are used for those I/O tags that have them configured directly in the address as a SAL item (e.g. ST=UInt16;SAL=2;SA=Second).
  • Automatic (HOBJ) - Aliases are used for allI/O tags belonging to the station. The alias value is the HOBJ (ID) of the I/O tag. If an alias is configured in the I/O tag address, it is ignored.
  • Off - Aliases are not used. If they are configured directly in theI/O tag address, they are ignored.

Default (SAL=alias)

Automatic (HOBJ)

Off

Default (SAL=alias)

Kotva
sjm
sjm
SJM

Sparkplug-to-JSON Mode

The parameter defines the JSON data format for the measured point with the address IN_SP2JS (Sparkplug payload to JSON conversion). The JSON data is either generated in a compact mode suitable for further machine processing (fields separated by spaces) or in a form suitable for human viewing (multiline format).

Compact

Multiline

Compact


Kotva
merany_bod
merany_bod
I/O tag configuration

...

Possible value types of I/O tags: Ci, Co, TxtI, TxtO, Qi, Ci, Co, Ai, Ao, Di, Do, TiR, ToR, TiA, ToA.

The MQTT implementation supports three work modes:

  • Text mode: The original implementation of the MQTT protocol contained only input text I/O tags with the addresses IN_TOPIC, IN_DATA, and optionally a pair of I/O tags with the addresses IN_ID and ACK_ID. The first two I/O tags were used to publish the received Topic and Payload (which then needed to be parsed in the script), the second two points were used to publish the packet identifier and confirm the processing of the packet. Thus, it was possible to ensure that for data sent with QoS > QoS_0, confirmation was sent only after data processing in the script.
    Output I/O tags with the addresses OUT_TOPIC and OUT_VALUE are used for writing.
  • JSON mode: An extension for processing Payload with JSON data (Payload Type=JSON) was implemented with the help of input I/O tags with addresses JA=json_address. The D2000 KOM process directly parses the JSON payload and sets the values of I/O tags​​with JSON addresses. I/O tags with addresses IN_TOPIC, IN_DATA, IN_ID, and ACK_ID may not exist at all.
    Output I/O tags with the addresses OUT_TOPIC and OUT_VALUE are used for writing.
  • Kotva
    sparkplug_address
    sparkplug_address
    Sparkplug mode
    : An extension for Payload processing with Sparkplug data (Payload Type = Sparkplug Host/Edge Node) has been implemented using input I/O tags with addresses SA=sparkplug_address. The D2000 KOM process directly parses the Sparkplug payload and sets the values of I/O tags ​​with the Sparkplug addresses. I/O tags with addresses IN_TOPIC, IN_DATA, IN_ID, and ACK_ID may not exist at all.
    Writing simple values ​​is possible using output I/O tags with addresses ST=type;SA=sparkplug_address, where type is the Sparkplug definition of a data type (e.g., Int8, UInt16, DateTime, String, etc). The output I/O tags must be on the station with the Sparkplug address since the Topic is derived from it when writing.
    Note: Messages of STATE type (generated by Host Application clients) with a JSON payload can be parsed using I/O tags with a JSON address (typically an I/O tag of Di type with an address of JA=online).


Type of  I/O tagAddressDescription
I/O tags for reading data sent by the MQTT server through a PUBLISH message (usually used in Text mode or JSON mode, rarely in Sparkplug mode).
Note: Values of I/O tags are set by the D2000 KOM process in the order IN_TOPIC, IN_DATA, and IN_ID. The configuration doesn't need to contain all three I/O tags.
TxtI
Kotva
in_topic
in_topic
IN_TOPIC
Topic (Topic) of the received PUBLISH message.
TxtI
Kotva
in_data
in_data
IN_DATA
Data (Payload) of the received PUBLISH message.
Ci
Kotva
in_id
in_id
IN_ID
Identifier of a packet (Packet Identifier) of a PUBLISH message that depends on the level of validation (QoS).
For messages sent with QoS_0, the identifier is zero; for QoS_1 and QoS_2, it is a positive 16-bit number. On the TCP/IP-TCP line, the identifier is monotonically increasing; on the TCP/IP-TCP Redundant line, values from two monotonically increasing sequences can alternate (so they can also be repeated), so the recommendation given in the following note applies:
Note: If the MQTT server also sends messages with the QoS_0 level of validation and the ACK_ID I/O tag is configured, then we recommend activating 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 in a timestamp to be generated.
I/O tag to confirm the received data to the MQTT server.
Co
Kotva
ack_id
ack_id
ACK_ID
If an output I/O tag with the ACK_ID address is defined, the D2000 KOM expects confirmation of the processing of each message by writing a copy of the value of the IN_ID tag. Only after, it sets values from the next received PUBLISH message (if it was received in the meantime) into the IN_TOPIC, IN_DATA, and IN_ID I/O tags (in this order). 
In the case of the QoS_0 level of confirmation, it is, therefore, necessary to repeatedly set the value of the 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, and IN_ID I/O tags immediately after the PUBLISH message is received and processed.
Note: For messages received with a QoS_0 level of validation, no confirmation is sent to the MQTT server; only the values of the received PUBLISH message will be published. 
I/O tags for sending values to the MQTT server through a 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.
TxtO
Kotva
out_topic
out_topic
OUT_TOPIC
The topic of the PUBLISH message being sent.
Note: If the I/O tag with the OUT_TOPIC address does not exist, the station address will be used directly as the Topic (if it is empty, the writing will not be performed).
TxtO

Kotva
out_value
out_value
OUT_VALUE

Data (Payload) of the PUBLISH message being sent.
Note: Sending the message is performed as a result of writing to the OUT_VALUE I/O tag (i.e., if the Topic does not change, then it is sufficient to set the OUT_TOPIC point once, e.g., by using the default value).
I/O tags for parsing JSON messages

TxtI, TxtO, Qi,
Ci, Co,
Ai, Ao,
Di, Do,
TiR, ToR

Kotva
ja
ja
JA=json_address

If Payload Type=JSON, the message is parsed as JSON data. The json_address value specifies the name of the JSON field whose value is to be assigned to the I/O tag
For JSON messages that can be structured, the syntax level1.level2.level3 ... is supported, e.g. rx.current, and if they contain fields (indexed from 1) also syntax level1[index1].level2[index2].level3 ... is possible, e.g. rx.gwrx[1].time.
Since the JSON message itself can be an array, the address can also start with an index, e.g. JA=[1].batt_cell_v_avg

For other examples, see the description of the LoRaWAN protocol's Envelope type I/O tags.


Writing to an I/O tag with a JSON address is also supported, but it must not have indexes. Examples of correct addresses for writing:

  • JA=myaddress
  • JA=mystruct.mylevel.myitem

When writing, the generated JSON contains the value itself and optionally a timestamp, if the station protocol parameter Time Field Name or the line parameter Time Field Name is set.
Note: Before writing to an I/O tag with a JSON address, a topic must first be set (an I/O tag with the OUT_TOPIC address). If the I/O tag with the OUT_TOPIC address does not exist, the station address will be used directly as the Topic (if it is empty, the writing will not be performed).

I/O tags for parsing Sparkplug messages

TxtI, TxtO, Qi,
Ci, Co,
Ai, Ao,
Di, Do,
TiR, ToR, TiA, ToA

Kotva
sa
sa

SA=sparkplug_address

SAL=alias;SA=sparkplug_address

ST=type;SA=sparkplug_address

ST=type;SAL=alias;SA=sparkplug_address

If Payload Type = Sparkplug Host/Edge Node, the message is parsed as Sparkplug data (a binary format built on Google Protocol Buffers). Sparkplug data contains metrics that have text identifiers (sparkplug_address) or possibly numeric aliases (alias).

Reading template items  is possible by specifying sparkplug_address in the format <TemplateName1><Separator><TemplateName2><Separator> ... <Separator><ItemName> where:

  • <TemplateNameX> is the name of the template/sub-template
  • <Separator> is the separator for individual levels (standard characters "->", which can be changed with the Item Separator parameter if this sequence occurs in template/item names)
  • <ItemName> is the item name of the deepest nested template

Examples of template item addresses:
SA=Template1->SubTemplate2->Item
SA=secUDT->sec

Reading dataset items (equivalent to structured variables in D2000) is possible by specifying sparkplug_address in the format <DatasetName>[<Row>]^<ColumnName> where:

  • <DatasetName> is the name of the dataset (it can also be part of a structure, e.g., Template1->SubTemplate2->Dataset3)
  • <Row> is the column number (1..N) or the "*" character. In the latter case, it is possible to configure the Destination column to which all rows are written (values ​​from the first row of the corresponding column are written to the I/O tag)
  • <ColumnName> is the name of the dataset column

Examples of dataset item addresses:
SA=Performance[3]^ActivePower
SA=Machine2->Parameters[1]^ActivePower
SA=DHS/Formation Data->Reservoir Parameter[*]^Gas density

For output I/O tags, the value type can be explicitly (ST=type). Simple types are supported (not template items/dataset items):

  • Int8
  • Int16
  • Int32
  • Int64
  • UInt8
  • UInt16
  • UInt32
  • UInt64
  • Float
  • Double
  • Boolean
  • String
  • DateTime
  • Text
  • Unknown
    (undefined type)

If the value type is not specified, the default value depends on the type of I/O tag:

I/O tag typeValue type
Dout

Boolean

CoInt64
Ao

Double

ToA

DateTime

ToRDouble
TxtO

String

Note: There is no difference between the String and Text types.
Note: for Payload Type = Edge Node, the D2000 KOM process sends DBIRTH/NBIRTH messages that contain only I/O tags (both input and output ones) with a defined value type. If we want to hide some (input) I/O tags, we need to set ST=Unknown in the address.

For Payload Type = Edge Node, it is also possible to specify a numerical alias (SAL=alias) as a natural number (0, 1, 2, ...) for both input and output I/O tags. The alias of the I/O tag within the station must be unique. Aliasing allows you to reduce the size of the transmitted data: in the NBIRTH/DBIRTH message, both the text identifier (sparkplug_address) and the alias are specified for each I/O tag; in the NDATA/DDATA messages, only aliases that are shorter than the text addresses are sent. Alias ​​is only used if Sparkplug Alias Mode = "Default (SAL=alias)".
Note: If aliases are used in the I/O tag address in Payload Type = Sparkplug Host mode, they will be replaced by aliases from the NBIRTH/DBIRTH message. However, if for some reason the Edge Node does not send these messages (and sends NDATA/DDATA with aliases), aliases can be useful for matching a text name with an alias.

The PUBLISH message created during writing contains a Topic derived from the station address. The message type depends on the station address:

  • for Payload Type = Sparkplug Host, depending on whether it is an Edge Node (NCMD) or Device/Sensor (DCMD)
  • for Payload Type = Edge Node, depending on whether it is an Edge Node (NDATA) or Device/Sensor (DDATA)

The Payload of the message contains a timestamp, a value type (type), a written value (encoded according to the specified value type), and a metric name (sparkplug_address) or an alias.

TxtI

Kotva
IN_SP2JS
IN_SP2JS
IN_SP2JS

The I/O tag is used to convert the Sparkplug payload into a JSON representation, which can then be processed, e.g., in an ESL script. Depending on the Convert Datatype/Timestamp to Text parameter, a textual representation of the value type and timestamp is also added. 
An example of value:

{"metrics":[{"datatype":3,"int_value":7338992,"name":"Corrected Vol Acc Stn","timestamp":1729664005479}],"seq":32,"timestamp":1729664005479}

After formatting into a readable form:

{
    "metrics": [
        {
            "datatype": 3,
            "int_value": 7338992,
            "name": "Corrected Vol Acc Stn",
            "timestamp": 1729664005479
        }
    ],
    "seq": 32,
    "timestamp": 1729664005479
}

An example of a more complex value containing properties and a dataset, and also displaying a textual representation of the data type (datatype_txt) and timestamp (timestamp_txt) as a result of the set parameter Convert Datatype/Timestamp to Text:

{
    "metrics": [
        {
            "datatype": 12,
            "datatype_txt": "String",
            "name": "Node Properties/Configuration",
            "string_value": "{}",
            "timestamp": 1730305529539,
            "timestamp_txt": "30-10-2024 17:25:29.539"
        },
        {
            "alias": 30064771073,
            "datatype": 5,
            "datatype_txt": "Uint8",
            "int_value": 0,
            "name": "Node Properties/Missing Param",
            "properties": {
                "keys": [
                    "usage"
                ],
                "values": [
                    {
                        "string_value": "technical information",
                        "type": 12,
                        "type_txt": "String"
                    }
                ]
            },
            "timestamp": 1730305529537,
            "timestamp_txt": "30-10-2024 17:25:29.537"
        },
        {
            "alias": 0,
            "dataset_value": {
                "columns": [
                    "topic_name",
                    "offset",
                    "length",
                    "crc"
                ],
                "num_of_columns": 4,
                "rows": [
                    {
                        "row": [
                            "N/A",
                            0,
                            0,
                            0
                        ]
                    }
                ],
                "types": [
                    12,
                    7,
                    7,
                    7
                ],
                "types_txt": [
                    "String",
                    "UInt32",
                    "UInt32",
                    "UInt32"
                ]
            },
            "datatype": 16,
            "datatype_txt": "DataSet",
            "name": "Node Control/FW Update",
            "timestamp": 1730305529537,
            "timestamp_txt": "30-10-2024 17:25:29.537"
        }
    ],
    "seq": 0,
    "timestamp": 1730305529536,
    "timestamp_txt": "30-10-2024 17:25:29.536"
}


Note: it is also possible to monitor the status of other Sparkplug Host Applications connected to the MQTT server. If the Identifier of Host Application is e.g. "ACME", so it is necessary to create a station with the address "spBv1.0/STATE/ACME" (or in abbreviated form "ACME") and on it an I/O tag of type Di with the address "JA=online" (since the Host Application sends a STATE message with a JSON payload).


Kotva
browse
browse
Browse

In the Sparkplug Host mode, for the I/O tags, it is possible to discover the list of metrics, as long as the KOM process is running and communication with an MQTT server is established.
(For I/O tags in Sparkplug Edge Node, it is only possible to find the list of metrics to which writes were made using NCMD/DCMD Topics).
Clicking the Browse button opens the MQTT Item Browser window and displays a list of received metrics. The object list is created dynamically as a result of received messages.

The list of objects is dynamic, i.e. when a new value arrives in the KOM process, it is updated. Filtering in individual columns (with the exception of the Time column) is also supported; asterisks can be used in the mask (e.g., *Short*).

Double-clicking on a particular line will insert the value from the Address column into the configuration of the I/O tag from which the MQTT Item Browser window was opened. At the same time, it is also inserted into the clipboard.

The Refresh button clears the list of values in both the CNF and the KOM process and optionally sends the Rebirth command (In the Sparkplug Host mode, if Send Node Control/Rebirth=YES).

The Value column contains the received value.

Image Added



Kotva
tell_cmd
tell_cmd
Tell commands

...


PríkazSyntaxPopis
STCOMMANDSTCOMMAND StationName PUTOLDVAL BeginTime EndTime

For Payload Type = Edge Node:

The Tell command reads out historical values ​​of output I/O tags (if the I/O tags or their control objects are archived) and sends them as historical values. Reading works independently of the Store & Forward protocol parameter. Using this command, it is possible to send historical values ​​even for the period when the D2000 KOM was turned off (and therefore the Store & Forward functionality could not work).
The BeginTime and EndTime parameters must be in the format "dd-mm-yyyy hh:mi:ss"

Example: STCOMMAND B.MQTT_MOSQUITTO_EN.Device1 PUTOLDVAL "30-05-2025 00:00:00" "30-05-2025 00:10:00"


Kotva
literatura
literatura
Literature

...

Links
Official website of the MQTT protocol http://mqtt.org

Official website of the MQTT Sparkplug protocol https://sparkplug.eclipse.org


Specifications and Standards
MQTT 3.1.1 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

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


Info
titleAn example of communication - text payload

The attached ZIP contains the configuration of two lines and two stations with the MQTT protocol and the definition of the S.MqttTest scheme. Data written over one line is received over the other line. The functionality was verified against the Mosquitto broker installed locally on Windows, listening on TCP port 1883.

View file
nameMosquito_test.zip
height150

Image Added


Info
titleAn example of communication - Sparkplug B payload

The attached ZIP contains a configuration of two lines and four stations with the MQTT Sparkplug B protocol. Both lines connect (alternatively) to the servers test.mosquitto.org and localhost.

The line L.MQTT_MOSQUITTO_EN (parent MQTT_MOSQUITTO_EN.KOM) is in Sparkplug Edge Node (data producer) mode, has two stations B.MQTT_MOSQUITTO_EN (Edge Node with address myGroup/myEdgeNode) and B.MQTT_MOSQUITTO_EN.Device1 (Device with address myGroup/myEdgeNode/myDevice1). These stations publish the values ​​of the objects Hour, Min, Sec.
The line parameter Sparkplug Host ID is set to "D2000komHA" (The Host application with this name is considered primary). The line L.MQTT_MOSQUITTO_EN connects alternately to the servers test.mosquitto.org and localhost until it finds a connected Primary Host Application.

The L.MQTT_MOSQUITTO_HA line (parent MQTT_MOSQUITTO_HA.KOM) is in Sparkplug Host mode (data consumer), has two stations B.MQTT_MOSQUITTO_HA (receiving data with the topic myGroup/myEdgeNode) and B.MQTT_MOSQUITTO_HA.Device1 (receiving data with the address myGroup/myEdgeNode/myDevice1). These stations receive object values ​​published by I/O tags on Sparkplug Edge Node stations.
The line parameter Sparkplug Host ID is set to "D2000komHA" (this is the Host application identification).

Using the output I/O tags on Sparkplug Host stations (M.MQTT_MOSQUITTO_HA.Output1_Int32, M.MQTT_MOSQUITTO_HA.Output2_Float, and M.MQTT_MOSQUITTO_HA.Device1.Output1_Bool), it is possible to send DCMD and NCMD messages and write to the input I/O tags on Sparkplug Edge Node stations (M.MQTT_MOSQUITTO_EN1.Input1, M.MQTT_MOSQUITTO_EN1.Input2, and M.MQTT_MOSQUITTO_EN.Device1.Input1_Bool).

View file
nameSparkplug.zip
height150



Info
titleBlog

You can read a blog about the MQTT protocol


Kotva
revizie
revizie
Document revisions

...

  • Ver. 1.0 - August 8th, 2017 - document creation.
  • Ver. 1.1 - October 15th, 2021 - support LastWill and Retain parameters
  • Ver. 1.2 - October 27th, 2021 - support for parsing of JSON messages
  • Ver. 1.3 - February 1st, 2022 - support for timestamps in JSON messages
  • Ver. 1.4 - October 4th, 2024 - support for MQTT Sparkplug (in Sparkplug Host mode), support for browsing
  • Ver. 1.5 - November 8th, 2024 - support for MQTTS (encrypted MQTT, MQTT over TLS)
  • Ver. 1.6 - April 25, 2025 - support for MQTT Sparkplug (in Sparkplug Edge Node mode)
  • Ver. 1.7 - May 5, 2025 - support for aliases in MQTT Sparkplug mode
  • Ver. 1.8 - May 12, 2025 - support for MQTT 5.0 


Info
titleRelated pages

...

Info
titleBlog

You can read a blog about the MQTT protocol

...

  • Ver. 1.0 - August 8th, 2017 - document creation.
  • Ver. 1.1 - October 15th, 2021 - support LastWill and Retain parameters
  • Ver. 1.2 - October 27th, 2021 - support for parsing of JSON messages
  • Ver. 1.3 - February 1st, 2022 - support for timestamps in JSON messages
Info
titleSúvisiace stránky:

Communication Protocols