thermferm/server.c

changeset 184
db997a04fde3
parent 179
417ee898fb02
child 185
4f34271cf1e7
--- a/thermferm/server.c	Tue Aug 05 15:45:23 2014 +0200
+++ b/thermferm/server.c	Tue Aug 05 16:24:17 2014 +0200
@@ -23,6 +23,7 @@
 #include "rdconfig.h"
 #include "thermferm.h"
 #include "logger.h"
+#include "devices.h"
 #include "server.h"
 #include "xutil.h"
 
@@ -611,63 +612,6 @@
 
 
 /*
- * Set new operating mode
- * MODE OFF|NONE|BEER|FRIDGE|PROFILE
- */
-int cmd_mode(char *buf)
-{
-    char	*opt;
-    units_list	*unit;
-
-    opt = strtok(buf, " \0");
-    opt = strtok(NULL, "\0");
-
-    if (opt == NULL) {
-	srv_send((char *)"502 Missing command option");
-	return 1;
-    }
-
-    if (current_unit == NULL) {
-	srv_send((char *)"401 No fermenter unit selected");
-	return 1;
-    }
-    for (unit = Config.units; unit; unit = unit->next) {
-	if (strcmp(current_unit, unit->uuid) == 0)
-	    break;
-    }
-
-    if (strcmp(opt, (char *)"OFF") == 0) {
-	if (unit->mode != UNITMODE_OFF) {
-	    unit->mode = UNITMODE_OFF;
-	    syslog(LOG_NOTICE, "Unit %s mode set to OFF", unit->name);
-	}
-	srv_send((char *)"218 Unit mode to OFF");
-	return 0;
-
-    } else if (strcmp(opt, (char *)"NONE") == 0) {
-	if (unit->mode != UNITMODE_NONE) {
-	    unit->mode = UNITMODE_NONE;
-	    syslog(LOG_NOTICE, "Unit %s mode set to NONE", unit->name);
-	    initlog(unit->name);
-	}
-	srv_send((char *)"218 Unit mode to NONE");
-	return 0;
-
-    } else if (strcmp(opt, (char *)"FRIDGE") == 0) {
-
-    } else if (strcmp(opt, (char *)"BEER") == 0) {
-
-    } else if (strcmp(opt, (char *)"PROFILE") == 0) {
-
-    }
-
-    srv_send((char *)"502 Unknown command option");
-    return 1;
-}
-
-
-
-/*
  * PROFILE		List profile status of current unit
  * PROFILE uuid,name	Rename profile name
  * PROFILE GETS uuid	Get profile steps list
@@ -1289,6 +1233,9 @@
 					unit->mode = i;
 					/* Allways turn everything off after a mode change */
 					unit->heater_state = unit->cooler_state = unit->fan_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);
 					break;
 				    }
 				}
@@ -1412,7 +1359,6 @@
 		srv_send((char *)"LIST                          List all fermenter units");
 		srv_send((char *)"LIST LOG                      List logfile data in 1 hour lines");
 		srv_send((char *)"LIST PROFILES                 List available profiles");
-		srv_send((char *)"MODE OFF|NONE|BEER|FRIDGE|PROFILE");
 //		srv_send((char *)"PROFILE                       Profile status of current unit");
 		srv_send((char *)"PROFILE uuid,name             Profile rename");
 		srv_send((char *)"PROFILE GETS uuid             Profile get steps list");
@@ -1443,9 +1389,6 @@
 #endif
 	    } else if (strncmp(buf, "LIST", 4) == 0) {
 		cmd_list(buf);
-	    } else if (strncmp(buf, "MODE", 4) == 0) {
-		if (cmd_mode(buf) == 0)
-		    wrconfig();
 	    } else if (strncmp(buf, "PROFILE", 7) == 0) {
 		if (cmd_profile(buf) == 0)
 		    wrconfig();

mercurial