enums.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import enum
  2. class MQTTErrorCode(enum.IntEnum):
  3. MQTT_ERR_AGAIN = -1
  4. MQTT_ERR_SUCCESS = 0
  5. MQTT_ERR_NOMEM = 1
  6. MQTT_ERR_PROTOCOL = 2
  7. MQTT_ERR_INVAL = 3
  8. MQTT_ERR_NO_CONN = 4
  9. MQTT_ERR_CONN_REFUSED = 5
  10. MQTT_ERR_NOT_FOUND = 6
  11. MQTT_ERR_CONN_LOST = 7
  12. MQTT_ERR_TLS = 8
  13. MQTT_ERR_PAYLOAD_SIZE = 9
  14. MQTT_ERR_NOT_SUPPORTED = 10
  15. MQTT_ERR_AUTH = 11
  16. MQTT_ERR_ACL_DENIED = 12
  17. MQTT_ERR_UNKNOWN = 13
  18. MQTT_ERR_ERRNO = 14
  19. MQTT_ERR_QUEUE_SIZE = 15
  20. MQTT_ERR_KEEPALIVE = 16
  21. class MQTTProtocolVersion(enum.IntEnum):
  22. MQTTv31 = 3
  23. MQTTv311 = 4
  24. MQTTv5 = 5
  25. class CallbackAPIVersion(enum.Enum):
  26. """Defined the arguments passed to all user-callback.
  27. See each callbacks for details: `on_connect`, `on_connect_fail`, `on_disconnect`, `on_message`, `on_publish`,
  28. `on_subscribe`, `on_unsubscribe`, `on_log`, `on_socket_open`, `on_socket_close`,
  29. `on_socket_register_write`, `on_socket_unregister_write`
  30. """
  31. VERSION1 = 1
  32. """The version used with paho-mqtt 1.x before introducing CallbackAPIVersion.
  33. This version had different arguments depending if MQTTv5 or MQTTv3 was used. `Properties` & `ReasonCode` were missing
  34. on some callback (apply only to MQTTv5).
  35. This version is deprecated and will be removed in version 3.0.
  36. """
  37. VERSION2 = 2
  38. """ This version fix some of the shortcoming of previous version.
  39. Callback have the same signature if using MQTTv5 or MQTTv3. `ReasonCode` are used in MQTTv3.
  40. """
  41. class MessageType(enum.IntEnum):
  42. CONNECT = 0x10
  43. CONNACK = 0x20
  44. PUBLISH = 0x30
  45. PUBACK = 0x40
  46. PUBREC = 0x50
  47. PUBREL = 0x60
  48. PUBCOMP = 0x70
  49. SUBSCRIBE = 0x80
  50. SUBACK = 0x90
  51. UNSUBSCRIBE = 0xA0
  52. UNSUBACK = 0xB0
  53. PINGREQ = 0xC0
  54. PINGRESP = 0xD0
  55. DISCONNECT = 0xE0
  56. AUTH = 0xF0
  57. class LogLevel(enum.IntEnum):
  58. MQTT_LOG_INFO = 0x01
  59. MQTT_LOG_NOTICE = 0x02
  60. MQTT_LOG_WARNING = 0x04
  61. MQTT_LOG_ERR = 0x08
  62. MQTT_LOG_DEBUG = 0x10
  63. class ConnackCode(enum.IntEnum):
  64. CONNACK_ACCEPTED = 0
  65. CONNACK_REFUSED_PROTOCOL_VERSION = 1
  66. CONNACK_REFUSED_IDENTIFIER_REJECTED = 2
  67. CONNACK_REFUSED_SERVER_UNAVAILABLE = 3
  68. CONNACK_REFUSED_BAD_USERNAME_PASSWORD = 4
  69. CONNACK_REFUSED_NOT_AUTHORIZED = 5
  70. class _ConnectionState(enum.Enum):
  71. MQTT_CS_NEW = enum.auto()
  72. MQTT_CS_CONNECT_ASYNC = enum.auto()
  73. MQTT_CS_CONNECTING = enum.auto()
  74. MQTT_CS_CONNECTED = enum.auto()
  75. MQTT_CS_CONNECTION_LOST = enum.auto()
  76. MQTT_CS_DISCONNECTING = enum.auto()
  77. MQTT_CS_DISCONNECTED = enum.auto()
  78. class MessageState(enum.IntEnum):
  79. MQTT_MS_INVALID = 0
  80. MQTT_MS_PUBLISH = 1
  81. MQTT_MS_WAIT_FOR_PUBACK = 2
  82. MQTT_MS_WAIT_FOR_PUBREC = 3
  83. MQTT_MS_RESEND_PUBREL = 4
  84. MQTT_MS_WAIT_FOR_PUBREL = 5
  85. MQTT_MS_RESEND_PUBCOMP = 6
  86. MQTT_MS_WAIT_FOR_PUBCOMP = 7
  87. MQTT_MS_SEND_PUBREC = 8
  88. MQTT_MS_QUEUED = 9
  89. class PahoClientMode(enum.IntEnum):
  90. MQTT_CLIENT = 0
  91. MQTT_BRIDGE = 1