You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes we do multiple iterations of esp_mqtt_start() esp_mqtt__publish() esp_mqtt__stop() sequences in the same program; either to save resources or when we need to publish to multiple MQTT servers.
For the moment the library has no MQTT status event in mqtt_status_callback() to signal when the func esp_mqtt__stop() has done its work; e.g. the main mqtt task has been deleted etcetera. So in the calling program we have to, for example, clear an MQTT_CONNECTED_BIT manually every time after calling the esp_mqtt__stop() method.
It would be cleaner if the mqtt_status_callback() would provide a status event when stopped() has really finished, for example ESP_MQTT_STATUS_STOPPED. The idea is similar to how the existing ESP_MQTT_STATUS_CONNECTED event works.
Note: the event ESP_MQTT_STATUS_DISCONNECTED already exists but it seems to have another purpose (when an existing connection has been aborted/disconnected unintentionally for whatever reason, opposed to being stopped specifically).
I don't think this needs to be provided by the library. When esp_mqtt_stop returns, the connection has been dropped and the background task deleted. The status callback is only there to know exactly when the client is connected (for making subscriptions) and disconnected (due to some connection loss). You usually call esp_mqtt_stop if you're done using the client (whatever the current state is).
This is a feature request.
Environment: branch idf3.
Sometimes we do multiple iterations of esp_mqtt_start() esp_mqtt__publish() esp_mqtt__stop() sequences in the same program; either to save resources or when we need to publish to multiple MQTT servers.
For the moment the library has no MQTT status event in mqtt_status_callback() to signal when the func esp_mqtt__stop() has done its work; e.g. the main mqtt task has been deleted etcetera. So in the calling program we have to, for example, clear an MQTT_CONNECTED_BIT manually every time after calling the esp_mqtt__stop() method.
It would be cleaner if the mqtt_status_callback() would provide a status event when stopped() has really finished, for example ESP_MQTT_STATUS_STOPPED. The idea is similar to how the existing ESP_MQTT_STATUS_CONNECTED event works.
Note: the event ESP_MQTT_STATUS_DISCONNECTED already exists but it seems to have another purpose (when an existing connection has been aborted/disconnected unintentionally for whatever reason, opposed to being stopped specifically).
Please check with the project https://github.com/pantaluna/support_esp_mqtt for inspiration (I changed it for this issue).
The text was updated successfully, but these errors were encountered: