Amazon AWS IoT MQTT Client for CircuitPython
- Author(s): Brent Rubell
Software and Dependencies:
- Adafruit CircuitPython firmware for the supported boards: https://github.com/adafruit/circuitpython/releases
Exception raised on MQTT API return-code errors.
Client for interacting with Amazon AWS IoT MQTT API.
- mmqttclient (MiniMQTT) – Pre-configured MiniMQTT Client object.
- keep_alive (int) – Optional Keep-alive timer interval, in seconds. Provided interval must be 30 <= keep_alive <= 1200.
Connects to Amazon AWS IoT MQTT Broker with Client ID. :param bool clean_session: Establishes a clean session with AWS broker.
Disconnects from Amazon AWS IoT MQTT Broker and de-initializes the MiniMQTT Client.
Returns if MQTT_CLIENT is connected to AWS IoT MQTT Broker
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.
Example of “pumping” an AWS IoT message loop: ..code-block::python
- while True:
Begins a blocking, asynchronous message loop. This method handles network connection/disconnection.
publish(topic, payload, qos=1)¶
Publishes to a AWS IoT Topic. :param str topic: MQTT topic to publish to. :param str payload: Data to publish to topic. :param int payload: Data to publish to topic. :param float payload: Data to publish to topic. :param json payload: JSON-formatted data to publish to topic. :param int qos: Quality of service level for publishing.
Publishes an empty message to the shadow delete topic to delete a device’s shadow
Publishes an empty message to shadow get topic to get the device’s shadow.
Subscribes to device’s shadow get response. :param int qos: Optional quality of service level.
Subscribes to all notifications on the device’s shadow update topic. :param int qos: Optional quality of service level.
Publishes a request state document to update the device’s shadow. :param json state_document: JSON-formatted state document.
Subscribes to an AWS IoT Topic. :param str topic: MQTT topic to subscribe to. :param int qos: Desired topic subscription’s quality-of-service.
Validates if user-provided pub/sub topics adhere to AWS Service Limits. https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html :param str topic: Desired topic to validate