Module MqttApplication

The class that's used to connect to an MQTT broker to publish messages, and to subscribe to topics and receive published messages.

Info:

  • Copyright: Debaru Kft. 2017
  • Release:
  • License: GNU
  • Author: Debaru Kft

Functions

MqttApplication () Creates an MqttApplication object.
saveTimestamp () Saves the current time and stores it in the timestampSec and timestampUsec fields.
start () Starts the client on a new Thread.
publish (topic, payload) Sends data to the broker.
is_delivered () Returns whether the last message was delivered or not.
is_connected () Returns whether the client is connected to the broker.
subscribe (topic) Subscribe to a topic.
consume () Consume received subscribed messages.
get_topic () Gets the topic of the received subscribed message.
get_payload () Gets the payload of the received subscribed message.

Fields

serverAddress The address of the Mqtt broker that the client tries to connect to.
clientId A string that represents the client.
qos Quality of service (QoS) is an attribute of an individual message being published.
username Username for client authentication.
password Password for client authentication.
caFile Filename of the Certificate Authority file of the server.
debugMode Turns on or off the debug mode.
retryTimeout The amount of time in seconds to wait after an Mqtt specific error has occured.
timestampSec With the saveTimestamp function the user can save the timestamp on the device.
timestampUsec With the saveTimestamp function the user can save the timestamp on the device.
keepaliveInterval A connection is regurarly checked for disruption.
connectTimeout The connect timeout in seconds.
autoReconnectMinRetryInterval Minimum retry interval in seconds.
autoReconnectMaxRetryInterval Maximum retry interval in seconds.


Functions

MqttApplication ()
Creates an MqttApplication object.
saveTimestamp ()
Saves the current time and stores it in the timestampSec and timestampUsec fields.
start ()
Starts the client on a new Thread. Must be called once at initialization. Returns TRUE if it's started and FALSE, if it's already running.

Returns:

    bool
publish (topic, payload)
Sends data to the broker.

Parameters:

is_delivered ()
Returns whether the last message was delivered or not.

Returns:

    bool
is_connected ()
Returns whether the client is connected to the broker.

Returns:

    bool
subscribe (topic)
Subscribe to a topic.

Parameters:

consume ()
Consume received subscribed messages.

Returns:

    bool
get_topic ()
Gets the topic of the received subscribed message.

Returns:

    string
get_payload ()
Gets the payload of the received subscribed message.

Returns:

    string

Fields

serverAddress
The address of the Mqtt broker that the client tries to connect to.
  • type string (default: "tcp://localhost:1883")
clientId
A string that represents the client. The broker can identify the client via this ID.
  • type string (default: "test/regor")
qos
Quality of service (QoS) is an attribute of an individual message being published.
  • type int (default: 2)
username
Username for client authentication.
password
Password for client authentication.
caFile
Filename of the Certificate Authority file of the server. The default path for the ca file is ssl/
  • type string (default: "mqtt.pem")
debugMode
Turns on or off the debug mode. In debug mode, error messages are verbose, and printed to the log.
  • type bool (default: FALSE))
retryTimeout
The amount of time in seconds to wait after an Mqtt specific error has occured. After the time elapsed, the client will try send the message again.
  • type int (default: 10)
timestampSec
With the saveTimestamp function the user can save the timestamp on the device. Then the user can read out this information with this field. Resolution is in seconds
timestampUsec
With the saveTimestamp function the user can save the timestamp on the device. Then the user can read out this information with this field. Resolution is in microseconds
keepaliveInterval
A connection is regurarly checked for disruption. The period if defined here. Resolution is in seconds
  • type int (default: 30)
connectTimeout
The connect timeout in seconds. This is the maximum time that the underlying library will wait for a connection before failing.
  • type int (default: 5)
autoReconnectMinRetryInterval
Minimum retry interval in seconds. Doubled on each failed retry.
  • type int (default: 1)
autoReconnectMaxRetryInterval
Maximum retry interval in seconds. The doubling stops here on failed retries.
  • type int (default: 32)
generated by LDoc 1.4.6 Last updated 2023-09-25 09:31:08