API Reference
adafruit_aws_iot
Amazon AWS IoT MQTT Client for CircuitPython
Author(s): Brent Rubell
Implementation Notes
Hardware:
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
- exception adafruit_aws_iot.AWS_IOT_ERROR
Exception raised on MQTT API return-code errors.
- class adafruit_aws_iot.MQTT_CLIENT(mmqttclient: adafruit_minimqtt.adafruit_minimqtt.MQTT, keep_alive: int = 30)
Client for interacting with Amazon AWS IoT MQTT API.
- Parameters:
mmqttclient (MQTT) – Pre-configured MiniMQTT Client object.
keep_alive (int) – Optional Keep-alive timer interval, in seconds. Provided interval must be 30 <= keep_alive <= 1200.
- connect(clean_session: bool = True) None
Connects to Amazon AWS IoT MQTT Broker with Client ID.
- Parameters:
clean_session (bool) – Establishes a clean session with AWS broker.
- disconnect() None
Disconnects from Amazon AWS IoT MQTT Broker and de-initializes the MiniMQTT Client.
- loop(timeout: float = 0) None
Starts a synchronous message loop which maintains connection with AWS IoT. Must be called within the keep_alive timeout specified to init. This method does not handle network connection/disconnection.
- Parameters:
timeout (float) – client return after this timeout, in seconds.
Example of “pumping” an AWS IoT message loop: ..code-block::python
- while True:
aws_iot.loop()
- shadow_delete() None
Publishes an empty message to the shadow delete topic to delete a device’s shadow
- shadow_get_subscribe(qos: int = 1) None
Subscribes to device’s shadow get response.
- Parameters:
qos (int) – Optional quality of service level.
- shadow_subscribe(qos: int = 1) None
Subscribes to all notifications on the device’s shadow update topic.
- Parameters:
qos (int) – Optional quality of service level.
- shadow_update(document: str)
Publishes a request state document to update the device’s shadow.
- Parameters:
state_document (str) – JSON-formatted state document string.
- static validate_topic(topic: str) None
Validates if user-provided pub/sub topics adhere to AWS Service Limits. https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html
- Parameters:
topic (str) – Desired topic to validate