MQTT API Reference
MQTT 3.1.1 client library
IotMqtt_Unsubscribe

Unsubscribes from the given array of topic filters and receive an asynchronous notification when the unsubscribe completes.

const IotMqttSubscription_t * pSubscriptionList,
size_t subscriptionCount,
uint32_t flags,
const IotMqttCallbackInfo_t * pCallbackInfo,
IotMqttOperation_t * pUnsubscribeOperation );

This function transmits an MQTT UNSUBSCRIBE packet to the server. An UNSUBSCRIBE packet removes registered topic filters from the server. After unsubscribing, the server will no longer send messages on these topic filters to the client.

Corresponding subscription callback functions are also removed from the MQTT connection. These subscription callback functions will be removed even if the MQTT UNSUBSCRIBE packet fails to send.

Parameters
[in]mqttConnectionThe MQTT connection used for the subscription.
[in]pSubscriptionListPointer to the first element in the array of subscriptions.
[in]subscriptionCountThe number of elements in pSubscriptionList.
[in]flagsFlags which modify the behavior of this function. See MQTT Function Flags.
[in]pCallbackInfoAsynchronous notification of this function's completion.
[out]pUnsubscribeOperationSet to a handle by which this operation may be referenced after this function returns. This reference is invalidated once the unsubscribe operation completes.
Returns
This function will return IOT_MQTT_STATUS_PENDING upon success.
Upon completion of the unsubscribe (either through an IotMqttCallbackInfo_t or IotMqtt_Wait), the status will be one of:
If this function fails before queuing an unsubscribe operation, it will return one of:
See also
IotMqtt_TimedSubscribe for a blocking variant of this function.
IotMqtt_Subscribe for the function that adds subscriptions.