主要内容

peek

View most recent message from MQTT topic

Since R2022a

Description

mqttMsg = peek(mqttClient) returns the most recent message from all subscribed topics for the specified MQTT client as a timetable of messages. This function does not flush the messages from the buffer, so you might view the same messages multiple times.

For improved performance while reading recent messages over an extended period of time:

  • Flush messages periodically using the flush function.

  • Use the read function instead, which automatically flushes messages.

mqttMsg = peek(mqttClient,Topic=mqttTopic) returns the most recent message from the specified topic.

Examples

collapse all

View the most recent message of a subscribed MQTT topic.

mqttMsg = peek(mqttClient,Topic="TopMW01")
mqttMsg =

  1×2 timetable

            Time              Topic           Data      
    ____________________    _________    _______________

    14-Dec-2021 16:29:09    "TopMW01"    "Hello World 3"

Input Arguments

collapse all

MQTT client specified as an icomm.mqtt.Client object, created with the mqttclient function.

Example: mqttClient = mqttclient()

Data Types: object

MQTT topic to view the message from, specified as a string or character vector.

Example: "trubits/mqTop48"

Data Types: string | char

Output Arguments

collapse all

Message viewed from MQTT topic, returned as a timetable.

Version History

Introduced in R2022a

See Also

Functions