Check the connected flag before doing any send operation on the connection
Make all the APIs that do send operations, thread safe
Update the connected flag within MQTT_Disconnect regardless of the return status of the send operation
Following are the specifics of the changes:
Add 3 new MQTTStatus_t values: MQTTStatusConnected, MQTTStatusNotConnected and MQTTStatusDisconnectPending
Added 1 new MQTTConnectionStatus_t value: MQTTDisconnectPending
Update the MQTT_Status_strerror function to handle the new MQTTStatus_t values
Add a new API function MQTT_CheckConnectStatus() that will check the value of the context→connectStatus flag safely.
Add this API to the core_mqtt.h file to make it available to users
Check the connected flag before doing any Send operation (following API's are updated)
a. sendPublishAcks
b. MQTT_Connect
c. MQTT_Subscribe
d. MQTT_Publish
e. MQTT_Ping
f. MQTT_Unsubscribe
g. MQTT_Disconnect
Use the MQTT_PRE_STATE_UPDATE_HOOK() and MQTT_POST_STATE_UPDATE_HOOK() to make the send APIs thread safe
The connect status is set to MQTTDisconnectPending whenever a transport send or receive function returns a negative error code
const keyword for the the MQTTStatus_t is removed in the input parameters for the receive functions as we need to update the connection status when the receive function returns a negative error code
Relevant Explanations
MQTT_PRE_SEND_HOOK(): The Pre and Post Send hook Macros are not required now, as the sending logic will be within the pre and post state update hook itself. (because we cannot allow other threads to change the connection state of the application until a send operation is complete).
I have split the handleSessionResumption function. The part of that function which was handling the clean session has been added within the mutex calls in the MQTT_Connect API and the unclean session part is handled by this new function that is called outside the mutex calls.
Description
Following is a brief summary of changes:
Following are the specifics of the changes:
const
keyword for the the MQTTStatus_t is removed in the input parameters for the receive functions as we need to update the connection status when the receive function returns a negative error codeRelevant Explanations
Pending Tasks