MQTT.QOS
MQTT.MQTTConnection
MQTT.connect!
MQTT.connect_async!
MQTT.disconnect!
MQTT.disconnect_async!
MQTT.publish!
MQTT.publish_async!
MQTT.subscribe!
MQTT.subscribe_async!
MQTT.unsubscribe!
MQTT.unsubscribe_async!
MQTT.QOS
— TypeQOS
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.
MQTT.MQTTConnection
— FunctionMQTTConnection()
This function constructs the connection struct that a given backend needs for interfacing with the MQTT Broker.
MQTT.connect_async!
— Functionconnect_async!(c::AbstractConnection)
make a connection to a broker.
MQTT.connect!
— Functionconnect!(c::AbstractConnection)
make a connection to a broker, and wait for the connection to be acknowleged.
Example
mqttconnection = ...
connect!(mqttconnection)
MQTT.subscribe_async!
— Functionsubscribe_async!(callback::OnMessage, connection::AbstractConnection, topic, qos::QOS)
subscribe to a topic.
MQTT.subscribe!
— Functionsubscribe_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
MQTT.publish_async!
— Functionpublish_async!(connection::AbstractConnection, topic, payload, qos::QOS; retain = false)
publish to a topic.
MQTT.publish!
— Functionpublish!(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)
MQTT.unsubscribe_async!
— Functionunsubscribe_async!(connection::AbstractConnection, topic)
unsubscribe from a topic.
MQTT.unsubscribe!
— Functionunsubscribe!(connection::AbstractConnection, topic)
unsubscribe from a topic, and wait for unsubscription to be acknowleged.
Example
unsubscribe!(mqttconnection, "group1/device1")
MQTT.disconnect_async!
— Functiondisconnect_async!(connection::AbstractConnection)
disconnect from a broker.
MQTT.disconnect!
— Functiondisconnect!(connection::AbstractConnection)
disconnect from a broker, and wait for disconnect to be acknowleged.
Example
disconnect!(mqttconnection)