Improved reconnection
This commit is contained in:
18
src/mqtt.h
18
src/mqtt.h
@@ -21,7 +21,22 @@ class MQTTwrapper
|
||||
{
|
||||
|
||||
private:
|
||||
static MQTTwrapper *getInstance(MQTTwrapper *inst = nullptr)
|
||||
const std::map<int, std::string> stateMap = {
|
||||
{-4, "MQTT_CONNECTION_TIMEOUT"},
|
||||
{-3, "MQTT_CONNECTION_LOST"},
|
||||
{-2, "MQTT_CONNECT_FAILED"},
|
||||
{-1, "MQTT_DISCONNECTED"},
|
||||
{0, "MQTT_CONNECTED"},
|
||||
{1, "MQTT_CONNECT_BAD_PROTOCOL"},
|
||||
{2, "MQTT_CONNECT_BAD_CLIENT_ID"},
|
||||
{3, "MQTT_CONNECT_UNAVAILABLE"},
|
||||
{4, "MQTT_CONNECT_BAD_CREDENTIALS"},
|
||||
{5, "MQTT_CONNECT_UNAUTHORIZED"}
|
||||
};
|
||||
|
||||
private:
|
||||
static MQTTwrapper *
|
||||
getInstance(MQTTwrapper *inst = nullptr)
|
||||
{
|
||||
static std::unique_ptr<MQTTwrapper> m_instance;
|
||||
if (inst)
|
||||
@@ -37,6 +52,7 @@ public:
|
||||
|
||||
const bool connect();
|
||||
const bool disconnect();
|
||||
const bool connected();
|
||||
|
||||
const bool subscribe(topic_t topic, action_t action);
|
||||
const bool unsubscribe(topic_t topic);
|
||||
|
||||
Reference in New Issue
Block a user