MqttMonitor/MqttProtocols.py

branch
eric7
changeset 105
36ec7431ad04
child 114
8c0e9e602124
diff -r 9a4c9b7f078c -r 36ec7431ad04 MqttMonitor/MqttProtocols.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MqttMonitor/MqttProtocols.py	Fri Jul 23 19:48:14 2021 +0200
@@ -0,0 +1,30 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (c) 2021 Detlev Offenbach <detlev@die-offenbachs.de>
+#
+
+"""
+Module implementing an enum defining the supported MQTT protocol versions.
+"""
+
+import enum
+
+try:
+    import paho.mqtt.client as mqtt
+
+    class MqttProtocols(enum.IntEnum):
+        """
+        Class defining the supported MQTT protocol versions.
+        """
+        MQTTv31 = mqtt.MQTTv31
+        MQTTv311 = mqtt.MQTTv311
+        MQTTv5 = mqtt.MQTTv5
+except ImportError:
+    # define the enum with known values
+    class MqttProtocols(enum.IntEnum):
+        """
+        Class defining the supported MQTT protocol versions.
+        """
+        MQTTv31 = 3
+        MQTTv311 = 4
+        MQTTv5 = 5

eric ide

mercurial