seguro.common.broker¶
Classes
|
Helper class for MQTT interaction with the SEGuRo platform. |
- class seguro.common.broker.Client(uid=None, host='localhost', port=8883, tls_cert='keys/clients/admin.crt', tls_key='keys/clients/admin.key', tls_cacert='keys/ca.crt', keepalive=60)[source]¶
Bases:
object
Helper class for MQTT interaction with the SEGuRo platform.
This class provides an abstraction layer for MQTT based communication between the SEGuRo platform and the MQTT broker.
Creates a paho.mqtt.client object and initialize the message queue.
- Parameters:
uid – An identifier of the client
host (str) – The MQTT hostname or IP address. Defaults to localhost.
port (int) – The port number used for connecting to the MQTT broker. Defaults to 8883.
tls_cert (str) – File containing the TLS client certificate for mutual TLS authentication.
tls_key (str) – File containing the TLS client key for mutual TLS authentication.
tls_cacert (str) – File containing the TLS certificate authority to validate the servers certificate against.
keepalive – The keepalive interval in seconds.
- publish(topic, message)[source]¶
Publish message to given topic
- Parameters:
topic (str)
message (str | bytes | bytearray | int | float | None)
- Returns:
The MQTT message information
- Return type:
MQTTMessageInfo
- publish_samples(topic, samples)[source]¶
Publish sample to given topic.
- Parameters:
topic
samples (Iterable[Sample])
- Returns:
The MQTT message information
- Return type:
MQTTMessageInfo