coreMQTT Agent v1.1.0
Thread safe MQTT 3.1.1 Client
MQTTAgent_CommandLoop

Process commands from the command queue in a loop.

MQTTStatus_t MQTTAgent_CommandLoop(MQTTAgentContext_t *pMqttAgentContext)
Process commands from the command queue in a loop.
Definition: core_mqtt_agent.c:996
MQTTStatus_t
Information used by each MQTT agent. A context will be initialized by MQTTAgent_Init(),...
Definition: core_mqtt_agent.h:185
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 MQTT_Disconnect(MQTTContext_t *pContext)
MQTTNotConnected
MQTTSuccess
MQTTContext_t mqttContext
Definition: core_mqtt_agent.h:186
MQTTConnectionStatus_t connectStatus
TransportInterface_t transportInterface
NetworkContext_t * pNetworkContext