Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This refactor is to address the problem that MQTT message processing was causing the ESP8266 to reboot, because of the timeout of the watchdog that make sure to go back to the system tasks, like taking care of wifi connection.
Also the MQTT library mentions this: https://github.com/marvinroger/async-mqtt-client/blob/develop/docs/1.-Getting-started.md#fully-featured-sketch
The point is to remove blocking code from the MQTT callback and moving it to the main loop. This alone solves all my stability issues. Meanwhile I've also upgraded to the latest client version, which solved another issue where I wasn't getting all the MQTT messages that I was seeing in the serial monitor.
This PR fixes for me #388, and also I cannot reproduce anymore the errors in #324 and probably also #312 is related to this.
Every time MQTT message processing was going over a time limit the board was resetting.