<reponame>InstaMsg/instamsg-python<filename>src/instamsg/mqtt/constants.py
# -*- coding: utf-8 -*-

MQTT_PROTOCOL_VERSION = 3
MQTT_PROTOCOL_NAME = "MQIsdp"
MQTT_MAX_INT = 65535
MQTT_RESULT_HANDLER_TIMEOUT = 10
MQTT_MAX_RESULT_HANDLER_TIMEOUT = 500
MQTT_MAX_TOPIC_LEN = 32767
MQTT_MAX_PAYLOAD_SIZE = 10000
MQTT_KEEP_ALIVE_TIMER_GRACE = 0.5
MQTT_SOCKET_MAX_BYTES_READ = 1024  # Maximum bytes to read from socket in recv
MQTT_SOCKET_TIMEOUT = 10
MQTT_SOCKET_TCP_KEEP_ALIVE = 240
MQTT_MAX_CLIENT_ID_LENGTH = 23
MQTT_MAX_KEEP_ALIVE_TIMER = 64800
# Mqtt Message Types
CONNECT = 0x10
CONNACK = 0x20
PUBLISH = 0x30
PUBACK = 0x40
PUBREC = 0x50
PUBREL = 0x60
PUBCOMP = 0x70
SUBSCRIBE = 0x80
SUBACK = 0x90
UNSUBSCRIBE = 0xA0
UNSUBACK = 0xB0
PINGREQ = 0xC0
PINGRESP = 0xD0
DISCONNECT = 0xE0
PROVACK = 0xF0
# CONNACK codes
CONNECTION_ACCEPTED = 0x00
CONNECTION_REFUSED_UNACCEPTABLE_PROTOCOL_VERSION = 0X01
CONNECTION_REFUSED_IDENTIFIER_REJECTED = 0x02
CONNECTION_REFUSED_SERVER_UNAVAILABLE = 0x03
CONNECTION_REFUSED_BAD_USERNAME_OR_PASSWORD = 0x04
CONNECTION_REFUSED_NOT_AUTHORIZED = 0x05;
# PROVACK codes
PROVISIONING_SUCCESSFUL = 0
PROVISIONING_SUCCESSFUL_WITH_CERT = 6
# QOS codes
MQTT_QOS0 = 0
MQTT_QOS1 = 1
MQTT_QOS2 = 2
# Extra var
CONNECT_ACK_TIMEOUT = 300
MQTT_DECODER_ERROR_COUNT_FOR_SOCKET_RESET = 5 # Consecutive MqttDecoderError on which connection is reset
PROVISIONING_CLIENT_ID = 'PROVISIONING'
MQTT_SOCKET_RECONNECT_TIMER = 90
# Logging Levels
MQTT_LOG_LEVEL_DISABLED = 0
MQTT_LOG_LEVEL_INFO = 1
MQTT_LOG_LEVEL_ERROR = 2
MQTT_LOG_LEVEL_DEBUG = 3
# Error codes
MQTT_ERROR_TIMEOUT = 0
MQTT_ERROR_NO_HANDLERS = 1
MQTT_ERROR_SOCKET = 2
MQTT_ERROR_AUTHENTICATION = 3
# keep alive setting
KEEP_ALIVE_TIMEOUT = 10
