diff --git a/PyPI-README.md b/PyPI-README.md index fcb726a97339598c486da5a0e6ea6dc6eaee9f2c..ffe72ffde94cc1553460bf6a0d54b15b67b0de1d 100644 --- a/PyPI-README.md +++ b/PyPI-README.md @@ -1,6 +1,6 @@ # WZL-MQTT -Current stable version: 2.5.1 +Current stable version: 2.5.2 ## Documentation @@ -78,6 +78,10 @@ while True: ``` ## Changelog + +**2.5.2** - 2023-03-29 + - client handles slash in at the end of prefix and the beginning of topic to avoid multiple consecutive slashes correctly now + 2.5.1 - increased verbosity in case of errors by including the full stack trace diff --git a/README.md b/README.md index 8aeb1c5163a689a482097d3674a36ed0e00ce83a..75544dad0ab07f8615e490d65512470155dfc8bd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # WZL-MQTT -Current stable version: 2.5.1 +Current stable version: 2.5.2 ## Documentation @@ -89,6 +89,10 @@ European Metrology Programme for Innovation and Research EMPIR). The EMPIR initi the European Union’s Horizon 2020 research and innovation programme and the EMPIR Participating States. ## Changelog + +**2.5.2** - 2023-03-29 + - client handles slash in at the end of prefix and the beginning of topic to avoid multiple consecutive slashes correctly now + 2.5.1 - increased verbosity in case of errors by including the full stack trace diff --git a/doc/source/usage.rst b/doc/source/usage.rst index c9ccf66f5cdc2f0ff8c3f5a7ed3bf920c92d3a43..e278df5dd1381785bf970df4d340f749bf2b316d 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -30,20 +30,15 @@ Receiving MQTT Messages logger = mqtt.root_logger.get('Receiver') + # username and password required to connect to the broker MQTT_USER = "" MQTT_PASSWORD = "" + # address, port and virtual host of the broker to connect to MQTT_BROKER = "127.0.0.1" MQTT_PORT = 1883 MQTT_VHOST = "/" - ## To connect to the central MQTT-Broker of MQ-MS use the settings below. - ## Ask Mark Sanders (sdr) or Matthias Bodenbenner (bdn) for personal credentials. - ## Set the "ssl" flag of the connect function to "True". - # MQTT_BROKER = "mqtt.wzl-mq.rwth-aachen.de" - # MQTT_PORT = 8883 - # MQTT_VHOST = "metrology" - topic = "#" # set topic to subscribe according to MQTT syntax! qos = 0 # set QoS according to MQTT specifications! diff --git a/setup.py b/setup.py index 7fd16d1430e87d6ae00963bd9dc3232ae54c4b0b..7ce09fe42a1b0dfcebbcc51036ebac458a4c5010 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ with open("PyPI-README.md", "r", encoding="utf-8") as fh: long_description = fh.read() setup(name='wzl-mqtt', - version='2.5.1', + version='2.5.2', url='https://git-ce.rwth-aachen.de/wzl-mq-public/iot/mqtt/', project_urls={ "Bug Tracker": "https://git-ce.rwth-aachen.de/wzl-mq-public/iot/mqtt/-/issues", diff --git a/src/mqtt/client.py b/src/mqtt/client.py index 2df94628aa8b1902f8a3f103334b2f149536f524..a9730d8819b3bb98b5d8b37c02ecc0b42338a4ab 100644 --- a/src/mqtt/client.py +++ b/src/mqtt/client.py @@ -210,7 +210,7 @@ class MQTTPublisher(MQTTClient): """ try: if self.prefix is not None and self.prefix != "": - self._client.publish(self.prefix + "/" + topic.strip("/"), + self._client.publish(self.prefix.strip("/") + "/" + topic.strip("/"), message, qos, retain) else: self._client.publish(topic.strip("/"), message, qos, retain) @@ -272,7 +272,7 @@ class MQTTSubscriber(MQTTClient): SubscriptionError: If topic could not be subscribed successfully. """ try: - topic = f'{self.prefix}/{topic}' if self.prefix is not None and self.prefix != "" else topic + topic = f'{self.prefix.strip("/")}/{topic.strip("/")}' if self.prefix is not None and self.prefix != "" else topic for s in self._subscriptions: if s["topic"] == topic: raise RuntimeError(