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

Improve network handling and implement time-based KeepAlive #4

Merged
merged 2 commits into from
Aug 15, 2019
Merged

Improve network handling and implement time-based KeepAlive #4

merged 2 commits into from
Aug 15, 2019

Conversation

brentru
Copy link
Member

@brentru brentru commented Aug 14, 2019

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 different keeep_alive values and a user may also want to set this value manually.
  • The loop method now checks the time and sends a PINGREQ (expecting a PINGRESP, this is handled in the ping() method) to the server if the time elapsed is greater than or equal to the provided keepalive value.
  • The loop_forever method has been refactored to call loop instead of _wait_for_msg. This method also now handles network control, for both the socket and the NetworkManager (currently WiFiManager) objects.
    • Properties for network management (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:
image

After:
image

@brentru brentru added bug Something isn't working enhancement New feature or request labels Aug 14, 2019
@brentru brentru requested a review from a team August 14, 2019 23:41
@brentru brentru merged commit 801b3a3 into adafruit:master Aug 15, 2019
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Aug 15, 2019
rtwfroody pushed a commit to rtwfroody/Adafruit_CircuitPython_MiniMQTT that referenced this pull request Sep 18, 2022
Improve network handling and implement time-based KeepAlive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants