What is the best practice when using the pubsub Arduino MQTT library to subscribe to a topic? If you do the subscribe in the setup(), and lose connection at some point, then you'll need to re-subscribe when connection comes back, right? How do people do that? Or do you just intermittently do all the subscribes?
Just wondering what the best way to go about it is.
I have an Arduino w/ ethernet, and it's using MQTT to subscribe to topics and taking actions based on these topic callbacks.
and lose connection at some point, then you'll need to re-subscribe when connection comes back, right?
Why? Subscribing to an event simply registers an action to be performed when that event occurs. When you lose the connection, the events stop happening. When the connection is restored, the events start happening again, so the actions should, too.
Now, if the library is doing something when events quit happening, or doesn't recognize when the connection is restored, there is nothing your code can do about that. You'd need to fix the library.