An MQTT wrapper for operations with device authentication and proper topic adjustment to communicate with

from protocols import mqtt_config
from protocols import mqtt_client

protocol_config = mqtt_config.MQTTConfig()
protocol_config.server_ip = ""
protocol_config.server_port = 5683
protocol_config.message_channel_id = "aaaaa-bbbb-cccccc-ddddddd"
protocol_config.thing_id = "aaaaa-bbbb-cccccc-ddddddd"
protocol_config.thing_token = "aaaaa-bbbb-cccccc-ddddddd"

mqtt_cli = mqtt_client.MQTTClientCustom(cfg.protocol_config)
connectionStatus = mqtt_cli.connect()
mqtt_cli.sendMessage("{test: 1}")

class constructor


Create a new instance of the MQTTClientCustom. Requires an MQTTConfig instance with all the information filled as the configuration will be kept for future calls. Will prepare all the authentication and exchange topics required to properly communicate with backend.

  • params:
    • mqtt_config: MQTTConfig instance, for data fields details please advice MQTTConfig page

class methods


Initiates the connection to the MQTT broker.

  • returns
    • Boolean: connection status


Publish a non-retained MQTT message on topic based on message_channel_id with QoS 1.

  • params:
    • message: A string message to be transmitted.


Close transmission socket and deinitialize.