Read available messages from MQTT topic
Read Messages from MQTT Topics
Read messages from one or more subscribed MQTT topics.
Read all available messages from a specific subscribed topic.
mqttMsg = read(mqttClient,Topic="TopMW01");
Read all available messages from all subscribed topics.
mqttMsg = read(mqttClient)
mqttMsg = 2×2 timetable Time Topic Data ____________________ _________ _______________ 14-Dec-2021 16:00:37 "TopMW01" "Hello World 1" 14-Dec-2021 16:00:41 "TopMW01" "Hello World 2"
Programmatically access the first message.
ans = "Hello World 1"
mqttClient — MQTT client
MQTT client specified as an
icomm.mqtt.Client object, created with
mqttClient = mqttclient()
mqttTopic — MQTT topic
string | char
MQTT topic to read messages from, specified as a string or character vector.
mqttMsg — Messages read from MQTT topics
Messages read from MQTT topics, returned as a timetable of messages.