thermferm/server.c

changeset 170
3cb99272b84b
parent 167
56b008563db8
child 174
244de612c572
--- a/thermferm/server.c	Fri Aug 01 14:45:32 2014 +0200
+++ b/thermferm/server.c	Fri Aug 01 16:13:55 2014 +0200
@@ -280,6 +280,10 @@
 /*
  * GET AIR uuid
  * GET BEER uuid
+ * GET LED1 uuid
+ * GET LED2 uuid
+ * GET LED3 uuid
+ * GET MODE uuid
  * GET TARGET uuid
  */
 int cmd_get(char *buf)
@@ -305,12 +309,30 @@
 		else
 		    srv_send((char *)"215 AIR,NA");
 		return 0;
+
 	    } else if (strcmp(opt, (char *)"BEER") == 0) {
 		if (unit->beer_state == 0)
 		    srv_send((char *)"215 BEER,%.3f", unit->beer_temperature / 1000.0);
 		else
 		    srv_send((char *)"215 BEER,NA");
 		return 0;
+
+	    } else if (strcmp(opt, (char *)"LED1") == 0) {
+		srv_send((char *)"215 HEATER,%d", (unit->heater_available && unit->heater_state) ? 1:0);
+		return 0;
+
+	    } else if (strcmp(opt, (char *)"LED2") == 0) {
+		srv_send((char *)"215 COOLER,%d", (unit->cooler_available && unit->cooler_state) ? 1:0);
+		return 0;
+
+	    } else if (strcmp(opt, (char *)"LED3") == 0) {
+		srv_send((char *)"215 FAN,%d", (unit->fan_available && unit->fan_state) ? 1:0);
+		return 0;
+
+	    } else if (strcmp(opt, (char *)"MODE") == 0) {
+		srv_send((char *)"215 MODE,%s", UNITMODE[unit->mode]);
+		return 0;
+
 	    } else if (strcmp(opt, (char *)"TARGET") == 0) {
 		if (unit->mode == UNITMODE_BEER) {
 		    srv_send((char *)"215 TARGET,%.3f", unit->beer_set);
@@ -465,12 +487,15 @@
 		}
 		if (unit->heater_available) {
 		    srv_send((char *)"HEATER_AVAILABLE,%s", unit->heater_available);
+		    srv_send((char *)"HEATER_STATE,%d", unit->heater_state);
 		}
 		if (unit->cooler_available) {
 		    srv_send((char *)"COOLER_AVAILABLE,%s", unit->cooler_available);
+		    srv_send((char *)"COOLER_STATE,%d", unit->cooler_state);
 		}
 		if (unit->fan_available) {
 		    srv_send((char *)"FAN_AVAILABLE,%s", unit->fan_available);
+		    srv_send((char *)"FAN_STATE,%d", unit->fan_state);
 		}
 		srv_send((char *)"MODE,%s", UNITMODE[unit->mode]);
 		srv_send((char *)"FRIDGE_SET,%.1f", unit->fridge_set);
@@ -995,10 +1020,13 @@
 //		srv_send((char *)"DEL UNIT uuid                 Delete unit with uuid");
 		srv_send((char *)"GET AIR uuid                  Get Air temperature with uuid");
 		srv_send((char *)"GET BEER uuid                 Get Beer temperature with uuid");
-//		srv_send((char *)"GET LED1 uuid                 Get LED 1 (cooler) state");
-//		srv_send((char *)"GET LED2 uuid                 Get LED 2 (heater) state");
-//		srv_send((char *)"GET LED3 uuid                 Get LED 3 (fan) state");
-//		srv_send((char *)"GET DOOR uuid                 Get Door state");
+		srv_send((char *)"GET LED1 uuid                 Get LED 1 (cooler) state");
+		srv_send((char *)"GET LED2 uuid                 Get LED 2 (heater) state");
+		srv_send((char *)"GET LED3 uuid                 Get LED 3 (fan) state");
+		srv_send((char *)"GET MODE uuid                 Get Unit Mode");
+//		srv_send((char *)"GET SW1 uuid                  Get Switch 1 (cooler) state");
+//		srv_send((char *)"GET SW2 uuid                  Get Switch 2 (heater) state");
+//		srv_send((char *)"GET SW3 uuid                  Get Switch 3 (fan) state");
 		srv_send((char *)"GET TARGET uuid               Get Target temperature with uuid");
 		srv_send((char *)"LCD                           Get LCD screen (allways 4 rows of 20 characters)");
 		srv_send((char *)"LIST                          List all fermenter units");

mercurial