coreMQTT Agent v1.1.0
Thread safe MQTT 3.1.1 Client
MQTTAgent_ResumeSession

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

bool 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:1038
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.
[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 MQTT_Connect(MQTTContext_t *pContext, const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, uint32_t timeoutMs, bool *pSessionPresent)
MQTTSuccess
MQTTContext_t mqttContext
Definition: core_mqtt_agent.h:186