MQTT.QOSType
QOS

An enum representing the different Quality of Service (QoS) levels in MQTT.

Values

  • AT_MOST_ONCE: QoS level 0, at most once delivery. The message is delivered at most once, or it may not be delivered at all. This is also known as "fire and forget".
  • AT_LEAST_ONCE: QoS level 1, at least once delivery. The message is guaranteed to be delivered at least once, but it may be delivered multiple times.
  • EXACTLY_ONCE: QoS level 2, exactly once delivery. The message is guaranteed to be delivered exactly once.
source
MQTT.MQTTConnectionFunction
MQTTConnection()

This function constructs the connection struct that a given backend needs for interfacing with the MQTT Broker.

source
MQTT.connect!Function
connect!(c::AbstractConnection)

make a connection to a broker, and wait for the connection to be acknowleged.

Example

mqttconnection = ...
connect!(mqttconnection)
source
MQTT.subscribe_async!Function
subscribe_async!(callback::OnMessage, connection::AbstractConnection, topic, qos::QOS)

subscribe to a topic.

source
MQTT.subscribe!Function
subscribe_async!(callback::OnMessage, connection::AbstractConnection, topic, qos::QOS)

subscribe to a topic, and wait for subscription to be acknowleged.

Example

use a previously defined callback function.

cb(topic, payload) = do_a_thing_for_device_one(payload)
subscribe!(cb, mqttconnection, "group1/device1", QOS.EXACTLY_ONCE)

define the callback in a do block

subscribe!(mqttconnection, "group1/device2", QOS.EXACTLY_ONCE) do (topic, payload)
    do_a_thing_for_device_two(payload)
end
source
MQTT.publish_async!Function
publish_async!(connection::AbstractConnection, topic, payload, qos::QOS; retain = false)

publish to a topic.

source
MQTT.publish!Function
publish!(connection::AbstractConnection, topic, payload, qos::QOS; retain = false)

publish to a topic, and wait for message to be acknowleged.

Example

publish!(mqttconnection, "group1/device1", "hello world", QOS.EXACTLY_ONCE)
source
MQTT.unsubscribe!Function
unsubscribe!(connection::AbstractConnection, topic)

unsubscribe from a topic, and wait for unsubscription to be acknowleged.

Example

unsubscribe!(mqttconnection, "group1/device1")
source
MQTT.disconnect!Function
disconnect!(connection::AbstractConnection)

disconnect from a broker, and wait for disconnect to be acknowleged.

Example

disconnect!(mqttconnection)
source