|
@ -139,8 +139,7 @@ void mqttConnect() { |
|
|
|
|
|
|
|
|
if (!mqtt.connected()) { |
|
|
if (!mqtt.connected()) { |
|
|
|
|
|
|
|
|
char * host = strdup(getSetting("mqttServer", MQTT_SERVER).c_str()); |
|
|
|
|
|
if (strlen(host) == 0) return; |
|
|
|
|
|
|
|
|
if (getSetting("mqttServer", MQTT_SERVER).length() == 0) return; |
|
|
|
|
|
|
|
|
// Last option: reconnect to wifi after MQTT_MAX_TRIES attemps in a row
|
|
|
// Last option: reconnect to wifi after MQTT_MAX_TRIES attemps in a row
|
|
|
#if MQTT_MAX_TRIES > 0
|
|
|
#if MQTT_MAX_TRIES > 0
|
|
@ -161,6 +160,7 @@ void mqttConnect() { |
|
|
|
|
|
|
|
|
mqtt.disconnect(); |
|
|
mqtt.disconnect(); |
|
|
|
|
|
|
|
|
|
|
|
char * host = strdup(getSetting("mqttServer", MQTT_SERVER).c_str()); |
|
|
unsigned int port = getSetting("mqttPort", MQTT_PORT).toInt(); |
|
|
unsigned int port = getSetting("mqttPort", MQTT_PORT).toInt(); |
|
|
char * user = strdup(getSetting("mqttUser").c_str()); |
|
|
char * user = strdup(getSetting("mqttUser").c_str()); |
|
|
char * pass = strdup(getSetting("mqttPassword").c_str()); |
|
|
char * pass = strdup(getSetting("mqttPassword").c_str()); |
|
@ -176,6 +176,10 @@ void mqttConnect() { |
|
|
DEBUG_MSG("\n"); |
|
|
DEBUG_MSG("\n"); |
|
|
mqtt.connect(); |
|
|
mqtt.connect(); |
|
|
|
|
|
|
|
|
|
|
|
free(host); |
|
|
|
|
|
free(user); |
|
|
|
|
|
free(pass); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|