class documentation

class MQTTClient(object):

View In Hierarchy

The general MQTT manager for this CSE.

Method configUpdate Callback for the configUpdate event.
Method configure Configure the MQTT client.
Method connectToMqttBroker Connect to a oneM2M MQTT Broker. The connection is cached and reused. The key for identifying the broker is a tupple (address, port). A new MQTTClientHandler() object be used for handling requests.
Method disconnectFromMqttBroker Remove the appropriate MQTTConnection for address and port from the connection cache and also shut-down the connection.
Method getMqttBroker Return the MQTTConnection for the address and port from the internal connection cache.
Method init Initialize the MQTT client.
Method isConnected Check whether the MQTT client is connected to a broker. Wait for a moment to take startup connection into account.
Method isFullySubscribed Check whether this mqttConnection is fully subscribed.
Method pause Stop handling requests.
Method run Initialize and run the MQTT client as a BackgroundWorker/Actor.
Method sendMqttRequest Sending a request via MQTT.
Method shutdown Shutdown the MQTTClient.
Method unpause Continue handling requests.
Method validate Validate the MQTT client configuration.
Class Variable __slots__ Slots for the MQTTClient.
Class Variable requestManager Injected RequestManager instance.
Instance Variable isStopped Flag to indicate whether the MQTT client is stopped.
Instance Variable mqttConnection The MQTT connection.
Instance Variable mqttConnections Dictionary of MQTT connections.
@onEvent(eventManager.configUpdate)
def configUpdate(self, eventData: EventData):

Callback for the configUpdate event.

Parameters
eventData:EventDataThe event data, containing the name of the updated configuration setting and its new value.
def configure(self, config: Configuration):

Configure the MQTT client.

Parameters
config:ConfigurationThe configuration object to update with the MQTT client configuration.
def connectToMqttBroker(self, address: str, port: int, useTLS: bool, username: str | None, password: str | None) -> MQTTConnection | None:

Connect to a oneM2M MQTT Broker. The connection is cached and reused. The key for identifying the broker is a tupple (address, port). A new MQTTClientHandler() object be used for handling requests.

def disconnectFromMqttBroker(self, address: str, port: int):

Remove the appropriate MQTTConnection for address and port from the connection cache and also shut-down the connection.

def getMqttBroker(self, address: str, port: int) -> MQTTConnection:

Return the MQTTConnection for the address and port from the internal connection cache.

def init(self):

Initialize the MQTT client.

def isConnected(self) -> bool:

Check whether the MQTT client is connected to a broker. Wait for a moment to take startup connection into account.

def isFullySubscribed(self) -> bool:

Check whether this mqttConnection is fully subscribed.

def pause(self):

Stop handling requests.

def run(self) -> bool:

Initialize and run the MQTT client as a BackgroundWorker/Actor.

def sendMqttRequest(self, request: CSERequest, url: str, ignoreResponse: bool) -> Result:

Sending a request via MQTT.

def shutdown(self) -> bool:

Shutdown the MQTTClient.

def unpause(self):

Continue handling requests.

def validate(self, config: Configuration):

Validate the MQTT client configuration.

Parameters
config:ConfigurationThe configuration object to validate.
__slots__: tuple[str, ...] =

Slots for the MQTTClient.

requestManager: RequestManager =

Injected RequestManager instance.

isStopped: bool =

Flag to indicate whether the MQTT client is stopped.

mqttConnection: MQTTConnection | None =

The MQTT connection.

mqttConnections: dict[tuple[str, int], MQTTConnection] =

Dictionary of MQTT connections.