mqttunsubscribe

Unsubscribe to a topic.

Attention: Valid only with Altair Communication Extension.

Syntax

[mid,status,messageinfo] = mqttunsubscribe(clientid, topic)

Inputs

clientid
client id, an output of mqttclient.
Type: string
topic
topic to be unsubscribed.
Type: string

Outputs

mid
message id of publish command.
Type: scalar
status
status return codes.
Type: scalar
messageinfo
description of publish status flag
Type: string
status = 0:
on success.
status = 1:
out of memory condition occurred.
status = 3:
input parameters were invalid.
status = 4:
client isn’t connected to a broker.
status = 18:
topic is not valid UTF-8.
status = 25:
resulting packet is larger than supported by the broker.

Examples

unsubscribe to a given topic
cld = mqttclient('test.mosquitto.org','port',1883);
[mid, rc, Mqttmessageinfo] = mqttsubscribe(cld, 'topic100',2);
[mid, rc, Mqttmessageinfo] = mqttunsubscribe(cld, 'topic100')
mid = 2
rc = 0
Mqttmessageinfo = success
unsubscribe to a topic with on_unsubscribe callback
function test_unsubscribecallback(clientid, mid)
		printf('UnSubscribe callback is triggered successfully\n');
		printf('message id: %s\n', num2str(mid));
end
cld = mqttclient('test.mosquitto.org','port',1883,'on_unsubscribe','test_unsubscribecallback');
[mid, rc, Mqttmessageinfo] = mqttsubscribe(cld, 'topic100',2);
[mid, rc, Mqttmessageinfo] = mqttunsubscribe(cld, 'topic100')
mid = 2
rc = 0
Mqttmessageinfo = success
UnSubscribe callback is triggered successfully
message id: 2