Difference between revisions of "MQTTCLIENT"
Jump to navigation
Jump to search
Line 91: | Line 91: | ||
/outdoor 0</pre> | /outdoor 0</pre> | ||
+ | |||
+ | |||
+ | |||
+ | == Datapoints == | ||
+ | |||
+ | {| class="wikitable" | ||
+ | !ID | ||
+ | !Value | ||
+ | !R/W | ||
+ | !Description | ||
+ | |||
+ | |- | ||
+ | |||
+ | |rowspan="2" |connection | ||
+ | |online | ||
+ | |R | ||
+ | |the broker is ready to accept connections from clients | ||
+ | |- | ||
+ | |offline | ||
+ | |R | ||
+ | |initialization of the driver failed or loop cycle failed | ||
+ | |||
+ | |- | ||
+ | |||
+ | |rowspan="2" |client.<clientId>.connected | ||
+ | |1 | ||
+ | |R | ||
+ | |clientId is connected to the broker | ||
+ | |- | ||
+ | |0 | ||
+ | |R | ||
+ | |clientId isn't connected to the broker | ||
+ | |||
+ | |- | ||
+ | |||
+ | |client.<clientId>.topic.<topicName> | ||
+ | |<message> | ||
+ | |R | ||
+ | |clientId published a message on topicName | ||
+ | |||
+ | |- | ||
+ | |||
+ | |client.<clientId>.willtopic.<topicName> | ||
+ | |<message> | ||
+ | |R | ||
+ | |MQTTBROKER published the will message of clientId, on topicName, because of connection problems or protocol violations | ||
+ | |||
+ | |- | ||
+ | |||
+ | |client.<clientdId>.lastseen | ||
+ | |<date> | ||
+ | |R | ||
+ | |timestamp of the last message or ping sent by clientId to the broker. The value has the format "yyyy-mm-dd hh:mm:ss.ms" (e.g. "2012-12-30 16:59:23.523") | ||
+ | |||
+ | |} |
Revision as of 14:49, 26 September 2019
This driver acts as an MQTT client (publisher/subscriber) for Hsyco, it fully supports MQTT version 3.1.1.
Contents
HSYCO Configuration
Add the MQTTCLIENT I/O Server in the I/O Servers section of the Settings and set its parameters:
Communication
- IP Address: host name or IP address of the MQTT broker
- IP Port: TCP/IP port of the MQTT broker
Authentication
- User: username for authentication with MQTT broker
- Password: password for authentication with MQTT broker
Options
ID | Default | Values | Description |
---|---|---|---|
startupevents | false | true | generate IO events also during the driver’s start-up phase |
false | start generating events only after HSYCO is aligned with the current status of the system | ||
cleansession | false | true | cleans eventually existing previous session held by the MQTT broker. This will remove any previous subscription and unacknowledged messages |
false | restores eventually existing previous session held by the MQTT broker. This will restore all existing subscriptions and resend any unacknowledged message | ||
messageretain | false | true | with this option true the MQTT broker will save publish messages for future subscribers |
false | with this option false the MQTT broker will not save publish messages for future subscribers | ||
keepalive | 60 | n >= 0 | this value, measured in seconds, defines the maximum time interval between messages sent or received. It enables this driver to detect if the MQTT broker is no longer available. In the absence of a data-related message during this time period, the client sends a very small "ping" message, which the server will acknowledge. A value of 0 disables keepalive processing in the client. |
connecttimeout | 30 | n >= 0 | this value, measured in seconds, defines the maximum time interval this driver will wait for the network connection to the MQTT broker to be established. A value of 0 disables timeout processing meaning the driver will wait until the network connection is made successfully or fails. |
messageqos | 0 | 0 | every publish message is sent at most one time, so it doesn't receive acknowledge message from the MQTT broker |
1 | every publish message is sent at least one time, so it waits acknowledge message from the MQTT broker | ||
2 | every publish message is sent exactly one time, so there will be a series of acknowledge messages between the MQTT client and broker |
Subscriptions file
Under the hsyco root directory there could be a file named "mqttsubscriptions-<IOServerId>.ini" (e.g "mqttsubscriptions-myclientid.ini") which can contain a series of line, each line represents a topic to subscribe and the topic's quality-of-service (qos). On each line topic and relative qos are separated by a white space:
E.g.
/mqtt/test 2 home/bathroom 1 /outdoor 0
Datapoints
ID | Value | R/W | Description |
---|---|---|---|
connection | online | R | the broker is ready to accept connections from clients |
offline | R | initialization of the driver failed or loop cycle failed | |
client.<clientId>.connected | 1 | R | clientId is connected to the broker |
0 | R | clientId isn't connected to the broker | |
client.<clientId>.topic.<topicName> | <message> | R | clientId published a message on topicName |
client.<clientId>.willtopic.<topicName> | <message> | R | MQTTBROKER published the will message of clientId, on topicName, because of connection problems or protocol violations |
client.<clientdId>.lastseen | <date> | R | timestamp of the last message or ping sent by clientId to the broker. The value has the format "yyyy-mm-dd hh:mm:ss.ms" (e.g. "2012-12-30 16:59:23.523") |