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.
- topic
- topic to be unsubscribed.
Outputs
- mid
- message id of publish command.
- status
- status return codes.
- messageinfo
- description of publish status flag
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