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

Resume a session by resending publishes if a session is present in the broker, or clear state information if not.

Parameters
[in]pMqttAgentContextThe MQTT agent to use.
[in]sessionPresentThe session present flag from the broker.
Note
This function is NOT thread-safe and should only be called from the context of the task responsible for MQTTAgent_CommandLoop.
Returns
#MQTTSuccess if it succeeds in resending publishes, else an appropriate error code from MQTT_Publish()

Example

// Variables used in this example.
MQTTStatus_t status;
MQTTAgentContext_t mqttAgentContext;
MQTTConnectInfo_t connectInfo = { 0 };
MQTTPublishInfo_t willInfo = { 0 };
bool sessionPresent;
// The example assumes that all variables have been filled with
// data for the MQTT_Connect call
// Refer to the MQTT_Connect API for a more detailed example.
// Attempt to resume session with the broker.
status = MQTT_Connect( &( mqttAgentContext.mqttContext ), &connectInfo, &willInfo, 100, &sessionPresent )
if( status == MQTTSuccess )
{
// Process the session present status sent by the broker.
status = MQTTAgent_ResumeSession( &mqttAgentContext, sessionPresent );
}
MQTTStatus_t MQTTAgent_ResumeSession(MQTTAgentContext_t *pMqttAgentContext, bool sessionPresent)
Resume a session by resending publishes if a session is present in the broker, or clear state informa...
Definition core_mqtt_agent.c:1076
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