diff -r e2889b17f48c -r c382a6c58c20 thermferm/server.c --- a/thermferm/server.c Wed Jul 18 13:26:37 2018 +0200 +++ b/thermferm/server.c Thu Jul 19 12:47:52 2018 +0200 @@ -1018,7 +1018,7 @@ } if (strcmp(opt, (char *)"PUT") == 0) { - bool mqtt_reconnect = false; + int mqtt_reconnect = 0; while (1) { rlen = srv_recv(ibuf); if (rlen == -1) { @@ -1027,8 +1027,10 @@ if (strlen(ibuf)) { if (strcmp(ibuf, (char *)".") == 0) { srv_send((char *)"219 Accepted Global record"); +#ifdef HAVE_MOSQUITTO_H if (mqtt_reconnect) mqtt_connect(); +#endif return 1; } kwd = strtok(ibuf, ",\0"); @@ -1108,8 +1110,10 @@ } else if (strcmp(kwd, (char *)"MQTT_HOST") == 0) { if (val && Config.mqtt_host && (strcmp(val, Config.mqtt_host))) syslog(LOG_NOTICE, "Global MQTT host `%s' to `%s'", Config.mqtt_host, val); +#ifdef HAVE_MOSQUITTO_H mqtt_disconnect(); - mqtt_reconnect = true; +#endif + mqtt_reconnect = 1; if (Config.mqtt_host) free(Config.mqtt_host); if (val) @@ -1121,8 +1125,10 @@ if (sscanf(val, "%d", &ival) == 1) { if (Config.mqtt_port != ival) { syslog(LOG_NOTICE, "Global MQTT port %d to %d", Config.mqtt_port, ival); +#ifdef HAVE_MOSQUITTO_H mqtt_disconnect(); - mqtt_reconnect = true; +#endif + mqtt_reconnect = 1; Config.mqtt_port = ival; } } @@ -1130,8 +1136,10 @@ } else if (strcmp(kwd, (char *)"MQTT_USER") == 0) { if (val && Config.mqtt_username && (strcmp(val, Config.mqtt_username))) syslog(LOG_NOTICE, "Global MQTT username `%s' to `%s'", Config.mqtt_username, val); +#ifdef HAVE_MOSQUITTO_H mqtt_disconnect(); - mqtt_reconnect = true; +#endif + mqtt_reconnect = 1; if (Config.mqtt_username) free(Config.mqtt_username); if (val) @@ -1142,8 +1150,10 @@ } else if (strcmp(kwd, (char *)"MQTT_PASS") == 0) { if (val && Config.mqtt_password && (strcmp(val, Config.mqtt_password))) syslog(LOG_NOTICE, "Global MQTT password `%s' to `%s'", Config.mqtt_password, val); +#ifdef HAVE_MOSQUITTO_H mqtt_disconnect(); - mqtt_reconnect = true; +#endif + mqtt_reconnect = 1; if (Config.mqtt_password) free(Config.mqtt_password); if (val) @@ -2611,6 +2621,7 @@ } } +#ifdef HAVE_MOSQUITTO_H if (unit->mqtt_flag) { if (debug) fprintf(stdout, "flag value %d\n", unit->mqtt_flag); @@ -2623,6 +2634,7 @@ publishDDeath(unit); } } +#endif } } }