Main Content

unsubscribe

Unsubscribe from MQTT topics

Since R2022a

Description

unsubscribe(mqttClient) unsubscribes the MQTT client from all its subscribed topics.

unsubscribe(mqttClient,Topic=mqttTopic) unsubscribes the MQTT client from the specified topic, mqttTopic.

example

Examples

collapse all

Unsubcribe a client from one, then from all MQTT topics.

View the subscriptions of a client.

mqttClient.Subscriptions
ans =

  3×3 table

          Topic          QualityOfService      Callback   
    _________________    ________________    _____________

    "trubits/mqTop48"           0            ""           
    "trubits/mqTmp52"           2            ""           
    "trubits/mqTsp61"           0            "showmessage"

Unsubscribe from one topic.

unsubscribe(mqttClient,Topic="trubits/mqTsp61")
mqttClient.Subscriptions
ans =

  2×3 table

          Topic          QualityOfService    Callback
    _________________    ________________    ________

    "trubits/mqTop48"           0               ""   
    "trubits/mqTmp52"           2               ""

Unsubscribe from all remaining topics.

unsubscribe(mqttClient)
mqttClient.Subscriptions
ans =

  0×3 empty table

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

Example: "trubits/mqTop48"

Data Types: string | char

Version History

Introduced in R2022a

See Also

Functions