Fixed double commands to 433 MHz switches, they did not switch.

Tue, 05 Aug 2014 11:57:05 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 05 Aug 2014 11:57:05 +0200
changeset 181
4099412fca09
parent 180
b62644eb442f
child 182
dd69ccba8fa8

Fixed double commands to 433 MHz switches, they did not switch.

thermferm/devices.c file | annotate | diff | comparison | revisions
thermferm/units.c file | annotate | diff | comparison | revisions
--- a/thermferm/devices.c	Mon Aug 04 23:36:05 2014 +0200
+++ b/thermferm/devices.c	Tue Aug 05 11:57:05 2014 +0200
@@ -42,6 +42,9 @@
     if (uuid == NULL)
 	return 0;
 
+    if (debug)
+	fprintf(stdout, "device_out(%s, %d)\n", uuid, value);
+
     for (device = Config.devices; device; device = device->next) {
 	if (strcmp(uuid, device->uuid) == 0) {
 	    if (value != device->value) {
--- a/thermferm/units.c	Mon Aug 04 23:36:05 2014 +0200
+++ b/thermferm/units.c	Tue Aug 05 11:57:05 2014 +0200
@@ -21,6 +21,7 @@
  *****************************************************************************/
 
 #include "thermferm.h"
+#include "devices.h"
 #include "units.h"
 #include "xutil.h"
 
@@ -58,7 +59,6 @@
 #endif
 {
     units_list		*unit;
-    devices_list	*device;
     int			rc, temp, deviation;
 
     /*
@@ -156,17 +156,8 @@
 	    if (my_shutdown)
 		break;
 
-	    device_out(unit->heater_address, unit->heater_state);
-	    if (my_shutdown)
-		break;
-	    device_out(unit->cooler_address, unit->cooler_state);
-	    if (my_shutdown)
-		break;
-	    device_out(unit->fan_address, unit->fan_state);
-	    if (my_shutdown)
-		break;
     	}
-	usleep(10000);
+	usleep(100000);
     }
 
     /*
@@ -177,6 +168,9 @@
 	 * Turn everything off
 	 */
 	unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = 0;
+	device_out(unit->heater_address, unit->heater_state);
+	device_out(unit->cooler_address, unit->cooler_state);
+	device_out(unit->fan_address, unit->fan_state);
 	syslog(LOG_NOTICE, "Stopped unit %s mode %s", unit->name, UNITMODE[unit->mode]);
     }
 

mercurial