Improve network handling and implement time-based KeepAlive #4
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 pull request improves how the library handles the MQTT KeepAlive with the initial CONNECT packet [MQTT-3.1.2-23]. We'll connect to a server, and stay connected.
keep_alive
exposed as an init kwarg - different brokers expect differentkeeep_alive
values and a user may also want to set this value manually.loop
method now checks the time and sends a PINGREQ (expecting a PINGRESP, this is handled in theping()
method) to the server if the time elapsed is greater than or equal to the provided keepalive value.loop_forever
method has been refactored to callloop
instead of_wait_for_msg
. This method also now handles network control, for both the socket and the NetworkManager (currently WiFiManager) objects.is_wifi_connected
,is_sock_connected
) have been added as well as additional management for both the socket and ESP32SPI wifi module (reconnect_socket
,reconnect_wifi
)Before this patch was applied:
After: