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

Process commands from the command queue in a loop.

Parameters
[in]pMqttAgentContextThe MQTT agent to use.
Returns
appropriate error code, or #MQTTSuccess from a successful disconnect or termination.

Example

// Variables used in this example.
MQTTStatus_t status;
MQTTAgentContext_t mqttAgentContext;
status = MQTTAgent_CommandLoop( &mqttAgentContext );
// The function returns on either receiving a terminate command,
// undergoing network disconnection OR encountering an error.
if( ( status == MQTTSuccess ) && ( mqttAgentContext.mqttContext.connectStatus == MQTTNotConnected ) )
{
// A terminate command was processed and MQTT connection was closed.
// Need to close socket connection.
Platform_DisconnectNetwork( mqttAgentContext.mqttContext.transportInterface.pNetworkContext );
}
else if( status == MQTTSuccess )
{
// Terminate command was processed but MQTT connection was not
// closed. Thus, need to close both MQTT and socket connections.
status = MQTT_Disconnect( &( mqttAgentContext.mqttContext ) );
assert( status == MQTTSuccess );
Platform_DisconnectNetwork( mqttAgentContext.mqttContext.transportInterface.pNetworkContext );
}
else
{
// Handle error.
}
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