Skip to content

Update adafruit_aws_iot.py #14

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

Merged
merged 2 commits into from
Nov 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions adafruit_aws_iot.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

"""
import json
from adafruit_minimqtt import MMQTTException
from adafruit_minimqtt.adafruit_minimqtt import MMQTTException

__version__ = "0.0.0-auto.0"
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_AWS_IOT.git"
Expand Down Expand Up @@ -77,11 +77,11 @@ def __init__(self, mmqttclient, keep_alive=30):
assert (
self.cid[0] != "$"
), "Client ID can not start with restricted client ID prefix $."
except:
except Exception as ex:
raise TypeError(
"You must provide MiniMQTT with your AWS IoT Device's Identifier \
as the Client ID."
)
) from ex
# Shadow-interaction topic
self.shadow_topic = "$aws/things/{}/shadow".format(self.cid)
# keep_alive timer must be between 30 <= keep alive interval <= 1200 seconds
Expand Down Expand Up @@ -125,7 +125,7 @@ def disconnect(self):
try:
self.client.disconnect()
except MMQTTException as error:
raise AWS_IOT_ERROR("Error disconnecting with AWS IoT: ", error)
raise AWS_IOT_ERROR("Error disconnecting with AWS IoT: ", error) from error
self.connected_to_aws = False
# Reset user-defined callback methods to None
self.on_connect = None
Expand All @@ -142,7 +142,7 @@ def reconnect(self):
try:
self.client.reconnect()
except MMQTTException as error:
raise AWS_IOT_ERROR("Error re-connecting to AWS IoT:", error)
raise AWS_IOT_ERROR("Error re-connecting to AWS IoT:", error) from error

def connect(self, clean_session=True):
"""Connects to Amazon AWS IoT MQTT Broker with Client ID.
Expand All @@ -152,7 +152,7 @@ def connect(self, clean_session=True):
try:
self.client.connect(clean_session)
except MMQTTException as error:
raise AWS_IOT_ERROR("Error connecting to AWS IoT: ", error)
raise AWS_IOT_ERROR("Error connecting to AWS IoT: ", error) from error
self.connected_to_aws = True

# MiniMQTT Callback Handlers
Expand Down