coreMQTT Agent v2.0.0
Thread safe MQTT 3.1.1 Client
Loading...
Searching...
No Matches
MQTTAgent_CancelAll
MQTTStatus_t MQTTAgent_CancelAll( MQTTAgentContext_t * pMqttAgentContext );

Cancel all enqueued commands and those awaiting acknowledgment while the command loop is not running.

Canceled commands will be terminated with return code #MQTTRecvFailed.

Parameters
[in]pMqttAgentContextThe MQTT agent to use.
Note
This function is NOT thread-safe and should only be called from the context of the task responsible for MQTTAgent_CommandLoop.
Returns
#MQTTBadParameter if an invalid context is given, else #MQTTSuccess.

Example

// Variables used in this example.
MQTTStatus_t status;
MQTTAgentContext_t mqttAgentContext;
status = MQTTAgent_CommandLoop( &mqttAgentContext );
//An error was returned, but reconnection is not desired. Cancel all commands
//that are in the queue or awaiting an acknowledgment.
if( status != MQTTSuccess )
{
//Cancel commands so any completion callbacks will be invoked.
status = MQTTAgent_CancelAll( &mqttAgentContext );
}
Platform_DisconnectNetwork( mqttAgentContext.mqttContext.transportInterface.pNetworkContext );
MQTTStatus_t MQTTAgent_CancelAll(MQTTAgentContext_t *pMqttAgentContext)
Cancel all enqueued commands and those awaiting acknowledgment while the command loop is not running.
Definition core_mqtt_agent.c:1119
MQTTStatus_t MQTTAgent_CommandLoop(MQTTAgentContext_t *pMqttAgentContext)
Process commands from the command queue in a loop.
Definition core_mqtt_agent.c:1034
Information used by each MQTT agent. A context will be initialized by MQTTAgent_Init(),...
Definition core_mqtt_agent.h:153
MQTTContext_t mqttContext
Definition core_mqtt_agent.h:154