Versie 0.8.6 De mosquitto library is geen optie meer maar verplicht.

Thu, 02 Aug 2018 12:20:06 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 02 Aug 2018 12:20:06 +0200
changeset 557
ae17042a6d39
parent 556
c2ee7f9a069e
child 558
66656231c084

Versie 0.8.6 De mosquitto library is geen optie meer maar verplicht.

configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
thermferm/mqtt.c file | annotate | diff | comparison | revisions
thermferm/mqtt.h file | annotate | diff | comparison | revisions
thermferm/server.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
thermferm/thermferm.h file | annotate | diff | comparison | revisions
--- a/configure	Wed Aug 01 22:27:58 2018 +0200
+++ b/configure	Thu Aug 02 12:20:06 2018 +0200
@@ -2035,7 +2035,7 @@
 
 
 PACKAGE="mbsePi-apps"
-VERSION="0.8.5"
+VERSION="0.8.6"
 COPYRIGHT="Copyright (C) 2014-2018 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2018"
 
@@ -3050,7 +3050,6 @@
 #
 # Libraries for mbsePi-apps
 #
-MOSQUITTO=No
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for mosquitto_lib_init in -lmosquitto" >&5
 $as_echo_n "checking for mosquitto_lib_init in -lmosquitto... " >&6; }
@@ -3499,14 +3498,14 @@
   cat >>confdefs.h <<_ACEOF
 #define HAVE_MOSQUITTO_H 1
 _ACEOF
- MOSQUITTO=Yes
-else
-  MOSQUITTO=No
+
 fi
 
 done
 
   LIBS="$LIBS -lmosquitto"
+else
+  as_fn_error $? "mosquitto not found" "$LINENO" 5
 fi
 
 WIRINGPI=No
@@ -5259,7 +5258,6 @@
     Version : ............ ${VERSION}
     Main directory : ..... ${prefix}
     WiringPi : ........... ${WIRINGPI}
-    MQTT : ............... ${MOSQUITTO}
     SDL library : ........ ${SDL}
     Simulator : .......... ${SIMULATOR}
 
@@ -5273,7 +5271,6 @@
     Version : ............ ${VERSION}
     Main directory : ..... ${prefix}
     WiringPi : ........... ${WIRINGPI}
-    MQTT : ............... ${MOSQUITTO}
     SDL library : ........ ${SDL}
     Simulator : .......... ${SIMULATOR}
 
--- a/configure.ac	Wed Aug 01 22:27:58 2018 +0200
+++ b/configure.ac	Thu Aug 02 12:20:06 2018 +0200
@@ -8,7 +8,7 @@
 dnl General settings
 dnl After changeing the version number, run autoconf!
 PACKAGE="mbsePi-apps"
-VERSION="0.8.5"
+VERSION="0.8.6"
 COPYRIGHT="Copyright (C) 2014-2018 Michiel Broek, All Rights Reserved"
 CYEARS="2014-2018"
 AC_SUBST(PACKAGE)
@@ -32,11 +32,12 @@
 #
 # Libraries for mbsePi-apps
 #
-MOSQUITTO=No
 AC_CHECK_LIB(mosquitto,mosquitto_lib_init,result=yes,result=no)
 if test "$result" = "yes"; then
-  AC_CHECK_HEADERS(mosquitto.h,MOSQUITTO=Yes,MOSQUITTO=No)
+  AC_CHECK_HEADERS(mosquitto.h)
   LIBS="$LIBS -lmosquitto"
+else
+  AC_MSG_ERROR(mosquitto not found)
 fi
 
 WIRINGPI=No
@@ -157,7 +158,6 @@
     Version : ............ ${VERSION}
     Main directory : ..... ${prefix}
     WiringPi : ........... ${WIRINGPI}
-    MQTT : ............... ${MOSQUITTO}
     SDL library : ........ ${SDL}
     Simulator : .......... ${SIMULATOR}
 
--- a/thermferm/mqtt.c	Wed Aug 01 22:27:58 2018 +0200
+++ b/thermferm/mqtt.c	Thu Aug 02 12:20:06 2018 +0200
@@ -35,7 +35,6 @@
 int			Sequence = 0;
 
 
-#ifdef HAVE_MOSQUITTO_H
 
 
 /* Global variables for use in callbacks. */
@@ -1037,4 +1036,3 @@
 }
 
 
-#endif
--- a/thermferm/mqtt.h	Wed Aug 01 22:27:58 2018 +0200
+++ b/thermferm/mqtt.h	Thu Aug 02 12:20:06 2018 +0200
@@ -1,7 +1,6 @@
 #ifndef	_MQTT_H
 #define	_MQTT_H
 
-#ifdef HAVE_MOSQUITTO_H
 
 #define STATUS_CONNECTING 0
 #define STATUS_CONNACK_RECVD 1
@@ -53,6 +52,5 @@
  */
 void publishNData(bool birth, int flag);
 
-#endif
 
 #endif
--- a/thermferm/server.c	Wed Aug 01 22:27:58 2018 +0200
+++ b/thermferm/server.c	Thu Aug 02 12:20:06 2018 +0200
@@ -1029,10 +1029,8 @@
 	    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");
@@ -1112,9 +1110,7 @@
 		    } 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();
-#endif
 			mqtt_reconnect = 1;
 			if (Config.mqtt_host)
 			    free(Config.mqtt_host);
@@ -1127,9 +1123,7 @@
 			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();
-#endif
 				mqtt_reconnect = 1;
 			        Config.mqtt_port = ival;
 			    }
@@ -1138,9 +1132,7 @@
 		    } 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();
-#endif
 			mqtt_reconnect = 1;
 			if (Config.mqtt_username)
 			    free(Config.mqtt_username);
@@ -1152,9 +1144,7 @@
 		    } 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();
-#endif
 			mqtt_reconnect = 1;
 			if (Config.mqtt_password)
 			    free(Config.mqtt_password);
@@ -2668,7 +2658,6 @@
 				}
 
 			    }
-#ifdef HAVE_MOSQUITTO_H
 			    if (unit->mqtt_flag) {
 				    if (debug)
 					    fprintf(stdout, "flag value %d\n", unit->mqtt_flag);
@@ -2682,7 +2671,6 @@
 				}
 			    	unit->mqtt_flag |= MQTT_FLAG_DLOG;	// Something to log
 			    }
-#endif
 			}
 		    }
 		}
--- a/thermferm/thermferm.c	Wed Aug 01 22:27:58 2018 +0200
+++ b/thermferm/thermferm.c	Thu Aug 02 12:20:06 2018 +0200
@@ -79,7 +79,6 @@
 #endif
 
 
-#ifdef HAVE_MOSQUITTO_H
 
 extern int		mqtt_qos;
 extern int		mqtt_last_mid;
@@ -92,7 +91,6 @@
 extern struct mosquitto	*mosq;
 extern char		*state;
 
-#endif
 
 
 void help(void)
@@ -1002,9 +1000,7 @@
 	syslog(LOG_NOTICE, "Can't lock");
 	return 1;
     }
-#ifdef HAVE_MOSQUITTO_H
     mqtt_connect();
-#endif
 
     if ((rc = devices_detect())) {
 	syslog(LOG_NOTICE, "Detected %d new devices", rc);
@@ -1104,7 +1100,6 @@
 	}
     }
     printf("Units started\n");
-#ifdef HAVE_MOSQUITTO_H
     publishDBirthAll();
     printf("Birth all done\n");
 
@@ -1116,7 +1111,6 @@
 	    unit->event_msg = NULL;
 	}
     }
-#endif
 
 #ifdef HAVE_WIRINGPI_H
     piLock(LOCK_LCD);
@@ -1242,9 +1236,7 @@
 	     * update, send the NDATA message.
 	     */
 	    if (updateHT || (now > (ndata + 300))) {
-#ifdef HAVE_MOSQUITTO_H
 		publishNData(false, 0);
-#endif
 		ndata = now;
 	    }
 
@@ -1268,12 +1260,10 @@
 			deviation = 40000;
 			if ((unit->air_temperature == 0) ||
 			    (unit->air_temperature && (temp > (int)unit->air_temperature - deviation) && (temp < ((int)unit->air_temperature + deviation)))) {
-#ifdef HAVE_MOSQUITTO_H
 			    if (unit->air_temperature != temp) {
 				unit->mqtt_flag |= MQTT_FLAG_DATA;
 				pub_domoticz_temp(unit->air_idx, temp);
 			    }
-#endif
 			    unit->air_temperature = temp;
 			    unit->air_state = 0;
 			} else {
@@ -1292,12 +1282,10 @@
 			deviation = 40000;
 			if ((unit->beer_temperature == 0) ||
 			    (unit->beer_temperature && (temp > (int)unit->beer_temperature - deviation) && (temp < ((int)unit->beer_temperature + deviation)))) {
-#ifdef HAVE_MOSQUITTO_H
 			    if (unit->beer_temperature != temp) {
 				unit->mqtt_flag |= MQTT_FLAG_DATA;
 				pub_domoticz_temp(unit->beer_idx, temp);
 			    }
-#endif
     			    unit->beer_temperature = temp;
 			    unit->beer_state = 0;
 			} else {
@@ -1316,12 +1304,10 @@
 			deviation = 40000;
 			if ((unit->chiller_temperature == 0) ||
 			    (unit->chiller_temperature && (temp > (int)unit->chiller_temperature - deviation) && (temp < ((int)unit->chiller_temperature + deviation)))) {
-#ifdef HAVE_MOSQUITTO_H
 			    if (unit->chiller_temperature != temp) {
 				unit->mqtt_flag |= MQTT_FLAG_DATA;
 				pub_domoticz_temp(unit->chiller_idx, temp);
 			    }
-#endif
 			    unit->chiller_temperature = temp;
 			    unit->chiller_state = 0;
 			} else {
@@ -1344,19 +1330,15 @@
 			    if (unit->door_state == 0) {
 			    	syslog(LOG_NOTICE, "Unit `%s' door closed", unit->alias);
 			    	unit->door_state = 1;
-#ifdef HAVE_MOSQUITTO_H
 				pub_domoticz_output(unit->door_idx, unit->door_state);
 				unit->mqtt_flag |= MQTT_FLAG_DATA;
-#endif
 			    }
 			} else {
 			    if (unit->door_state) {
 			    	syslog(LOG_NOTICE, "Unit `%s' door opened", unit->alias);
 			    	unit->door_state = 0;
-#ifdef HAVE_MOSQUITTO_H
 				pub_domoticz_output(unit->door_idx, unit->door_state);
 				unit->mqtt_flag |= MQTT_FLAG_DATA;
-#endif
 			    }
 			    /*
 			     * If unit is active and the door is open
@@ -1382,19 +1364,15 @@
 			    if (unit->psu_state == 0) {
 				syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is on", unit->alias);
 				unit->psu_state = 1;
-#ifdef HAVE_MOSQUITTO_H
 				pub_domoticz_output(unit->psu_idx, unit->psu_state);
 				unit->mqtt_flag |= MQTT_FLAG_DATA;
-#endif
 			    }
 			} else {
 			    if (unit->psu_state) {
 				syslog(LOG_NOTICE, "Unit `%s' PSU (12 volt) is off", unit->alias);
 				unit->psu_state = 0;
-#ifdef HAVE_MOSQUITTO_H
 				pub_domoticz_output(unit->psu_idx, unit->psu_state);
 				unit->mqtt_flag |= MQTT_FLAG_DATA;
-#endif
 			    }
 			    unit->alarm_flag |= ALARM_FLAG_PSU;
 			}
@@ -1749,13 +1727,11 @@
 				if (unit->heater_state != power) {
 				    syslog(LOG_NOTICE, "Unit `%s' heater %d%% => %d%%", unit->alias, unit->heater_state, power);
 				    unit->heater_state = power;
-#ifdef HAVE_MOSQUITTO_H
 				    pub_domoticz_output(unit->heater_idx, unit->heater_state);
 				    if (unit->heater_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
 					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
-#endif
 				}
 			    }
 			} else {
@@ -1765,13 +1741,11 @@
 				if (unit->heater_state) {
 				    syslog(LOG_NOTICE, "Unit `%s' heater On => Off", unit->alias);
 				    unit->heater_state = 0;
-#ifdef HAVE_MOSQUITTO_H
 				    pub_domoticz_output(unit->heater_idx, unit->heater_state);
 				    if (unit->heater_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
 					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
-#endif
 				}
 			    }
 			}
@@ -1791,13 +1765,11 @@
 				if (unit->cooler_state != power) {
 				    syslog(LOG_NOTICE, "Unit `%s' cooler %d%% => %d%%", unit->alias, unit->cooler_state, power);
 				    unit->cooler_state = power;
-#ifdef HAVE_MOSQUITTO_H
 				    pub_domoticz_output(unit->cooler_idx, unit->cooler_state);
 				    if (unit->cooler_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
 				    	unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
-#endif
 				}
 			    }
 			} else {
@@ -1807,13 +1779,11 @@
 				if (unit->cooler_state) {
 				    syslog(LOG_NOTICE, "Unit `%s' cooler On => Off", unit->alias);
 				    unit->cooler_state = 0;
-#ifdef HAVE_MOSQUITTO_H
 				    pub_domoticz_output(unit->cooler_idx, unit->cooler_state);
 				    if (unit->cooler_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
 					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
-#endif
 				}
 			    }
 			}
@@ -1840,13 +1810,11 @@
 			    	if (! unit->fan_state) {
 				    syslog(LOG_NOTICE, "Unit `%s' Fan Off => On", unit->alias);
 				    unit->fan_state = 100;
-#ifdef HAVE_MOSQUITTO_H
 				    pub_domoticz_output(unit->fan_idx, unit->fan_state);
 				    if (unit->fan_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
 					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
-#endif
 			    	}
 			    }
 			} else {
@@ -1856,13 +1824,11 @@
 			    	if (unit->fan_state) {
 				    syslog(LOG_NOTICE, "Unit `%s' Fan On => Off", unit->alias);
 			    	    unit->fan_state = 0;
-#ifdef HAVE_MOSQUITTO_H
 				    pub_domoticz_output(unit->fan_idx, unit->fan_state);
 				    if (unit->fan_address) {
 					unit->mqtt_flag |= MQTT_FLAG_DATA;
 					unit->mqtt_flag |= MQTT_FLAG_DLOG;
 				    }
-#endif
 				}
 			    }
 			}
@@ -1922,7 +1888,6 @@
 		/*
 		 * Publish MQTT messages set in flag
 		 */
-#ifdef HAVE_MOSQUITTO_H
 		if (unit->mqtt_flag) {
 		    if (unit->mqtt_flag & MQTT_FLAG_BIRTH) {
 			publishDBirth(unit);
@@ -1945,7 +1910,6 @@
 			unit->mqtt_flag &= ~MQTT_FLAG_DLOG;
 		    }
 		}
-#endif
 
 		/*
 		 * Handle changed alarms
@@ -2082,19 +2046,12 @@
 	unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->light_state = 0;
 	unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
 	device_out(unit->heater_address, unit->heater_state);
-#ifdef HAVE_MOSQUITTO_H
 	pub_domoticz_output(unit->heater_idx, unit->heater_state);
-#endif
 	device_out(unit->cooler_address, unit->cooler_state);
-#ifdef HAVE_MOSQUITTO_H
 	pub_domoticz_output(unit->cooler_idx, unit->cooler_state);
-#endif
 	device_out(unit->fan_address, unit->fan_state);
-#ifdef HAVE_MOSQUITTO_H
 	pub_domoticz_output(unit->fan_idx, unit->fan_state);
-#endif
 	device_out(unit->light_address, unit->light_state);
-#ifdef HAVE_MOSQUITTO_H
 	if (unit->mode != UNITMODE_OFF) {
 	    /*
 	     * If unit ia active, publish we are dying.
@@ -2107,14 +2064,11 @@
 	    free(unit->event_msg);
 	    unit->event_msg = NULL;
 	}
-#endif
 	syslog(LOG_NOTICE, "Unit `%s' stopped in mode %s", unit->alias, UNITMODE[unit->mode]);
     }
 
     usleep(100000);
-#ifdef HAVE_MOSQUITTO_H
     mqtt_disconnect();
-#endif
 
     syslog(LOG_NOTICE, "Out of loop");
 
--- a/thermferm/thermferm.h	Wed Aug 01 22:27:58 2018 +0200
+++ b/thermferm/thermferm.h	Thu Aug 02 12:20:06 2018 +0200
@@ -44,10 +44,7 @@
 #include <libxml/parser.h>
 #include <libxml/encoding.h>
 #include <libxml/xmlwriter.h>
-
-#ifdef HAVE_MOSQUITTO_H
 #include <mosquitto.h>
-#endif
 
 #ifdef HAVE_WIRINGPI_H
 /* wiringPi */

mercurial