adafruit / Adafruit_IO_Arduino

Arduino library to access Adafruit IO from WiFi, cellular, and ethernet modules.
Other
210 stars 107 forks source link

Add io.disconnect() function #101

Closed brentru closed 4 years ago

brentru commented 4 years ago

Add io.disconnect() function to shut down the connection and release any resources.

We support many types of network connections with this library (https://github.com/adafruit/Adafruit_IO_Arduino/tree/master/src/wifi). Each WiFi client may require a corresponding AdafruitIO_HARDWARETYPE::_disconnect() method, analogous to the AdafruitIO_HARDWARETYPE::_connect() method.

Originally suggested by @sellensr in issue https://github.com/adafruit/Adafruit_IO_Arduino/issues/99.

sellensr commented 4 years ago

Does the MQTT client actually need a negotiated disconnect, or does it fail resiliently whenever the hardware connection fails? The tests I did with forced WiFi.disconnect() always seemed to come back just fine with a subsequent call to io.connect().

brentru commented 4 years ago

EDIT: This is incorrect

@sellensr It might not need a negotiated disconnect, edited issue to reflect.

sellensr commented 4 years ago

I'll add the _disconnect() in my next pr along with the test for non-empty ssid, as it can be part of the same functionality.

brentru commented 4 years ago

WiFi disconnect is handled in https://github.com/adafruit/Adafruit_IO_Arduino/pull/104. After that's set, let's open a new PR to add a negotiated mqtt client disconnect and a wifi disconnect, io.disconnect()

brentru commented 4 years ago

Fixed in #104, closing...