Skip to content

Commit d1280ff

Browse files
authored
Merge pull request #84 from adafruit/fix_isconnected
the property did not work before. now it does what you expect - return true or false
2 parents 41c8ec5 + 2cee8b9 commit d1280ff

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

adafruit_io/adafruit_io.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import json
2323
import re
2424

25+
from adafruit_minimqtt.adafruit_minimqtt import MMQTTException
2526
from adafruit_io.adafruit_io_errors import (
2627
AdafruitIO_RequestError,
2728
AdafruitIO_ThrottleError,
@@ -117,7 +118,10 @@ def disconnect(self):
117118
@property
118119
def is_connected(self):
119120
"""Returns if connected to Adafruit IO MQTT Broker."""
120-
return self._client.is_connected
121+
try:
122+
return self._client.is_connected()
123+
except MMQTTException:
124+
return False
121125

122126
# pylint: disable=not-callable, unused-argument
123127
def _on_connect_mqtt(self, client, userdata, flags, return_code):

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
Adafruit-Blinka
66
Adafruit_CircuitPython_ESP32SPI
7+
Adafruit_CircuitPython_MiniMQTT

0 commit comments

Comments
 (0)