iotswarm.messaging package

Submodules

iotswarm.messaging.aws module

Contains communication protocols for AWS services.

class iotswarm.messaging.aws.IotCoreMQTTConnection(endpoint: str, cert_path: str, key_path: str, ca_cert_path: str, client_id: str, *args, port: int | None = None, clean_session: bool = False, keep_alive_secs: int = 1200, inherit_logger: logging.Logger | None = None, **kwargs)

Bases: MessagingBaseClass

Handles MQTT communication to AWS IoT Core.

connected_flag: bool = False

Tracks whether connected.

connection: awscrt.mqtt.Connection | None = None

A connection to the MQTT endpoint.

send_message(message: dict, topic: str) bool

Sends a message to the endpoint.

Parameters
  • message – The message to send.

  • topic – MQTT topic to send message under.

Returns

True if sent sucessfully, else false.

Return type

bool

iotswarm.messaging.core module

class iotswarm.messaging.core.MessagingBaseClass(inherit_logger: logging.Logger | None = None)

Bases: ABC

MessagingBaseClass Base class for messaging implementation

All messaging classes implement this interface.

abstract property connection

A property for the connection object where messages are sent.

abstract send_message() bool

Method for sending the message.

class iotswarm.messaging.core.MockMessageConnection(inherit_logger: logging.Logger | None = None)

Bases: MessagingBaseClass

Mock implementation of base class. Consumes send_message calls but does no work.

connection: None = None

Connection object. Not needed in a mock but must be implemented

send_message(*_) bool

Consumes requests to send a message but does nothing with it.

Returns

True if sent sucessfully, else false.

Return type

bool