Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add event ESP_MQTT_STATUS_STOPPED #17

Closed
pantaluna opened this issue Apr 22, 2018 · 2 comments
Closed

Feature: add event ESP_MQTT_STATUS_STOPPED #17

pantaluna opened this issue Apr 22, 2018 · 2 comments

Comments

@pantaluna
Copy link

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).

@256dpi
Copy link
Owner

256dpi commented Apr 23, 2018

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).

Please correct me if I don't see something.

@pantaluna
Copy link
Author

That is fine. I will put in a wrapper library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants