Main Content

flush

Clear received MQTT messages

Description

example

flush(mqttClient) clears all received messages from all subscribed topics in the specified MQTT client.

flush(mqttClient,Topic=mqttTopic) clears all received messages from the specified MQTT topic.

Note that the read function also clears messages after reading them into MATLAB, but the peek function does not.

Examples

collapse all

View a recent message and then flush all messages.

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

  1×2 timetable

            Time              Topic           Data      
    ____________________    _________    _______________

    14-Dec-2021 16:29:09    "TopMW01"    "Hello World 3"
flush(mqttClient)
peek(mqttClient)
Warning: No data available to peek for topic "TopMW01". 

ans =

  0×2 empty timetable

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 flush messages from, specified as a string or character vector.

Example: "trubits/mqTop48"

Data Types: string | char

Version History

Introduced in R2022a

See Also

Functions