thermferm/server.c

changeset 500
5aa914eb644e
parent 499
602d9968960f
child 502
0e2c58f8eb78
--- a/thermferm/server.c	Mon May 02 16:15:37 2016 +0200
+++ b/thermferm/server.c	Mon May 09 21:35:55 2016 +0200
@@ -1005,6 +1005,11 @@
 	srv_send((char *)"HUM_VALUE,%.0f", Config.hum_value / 1000.0);
 	srv_send((char *)"LCD_COLS,%d", Config.lcd_cols);
 	srv_send((char *)"LCD_ROWS,%d", Config.lcd_rows);
+	srv_send((char *)"NEXT_UNIT,%d", Config.next_unit);
+#ifdef HAVE_MOSQUITTO_H
+	srv_send((char *)"MQTT_HOST,%s", Config.mqtt_host);
+	srv_send((char *)"MQTT_PORT,%d", Config.mqtt_port);
+#endif
 	srv_send((char *)".");
 	return 0;
     }
@@ -1984,6 +1989,10 @@
     }
 
     if (strcmp(opt, (char *)"ADD") == 0) {
+	char an[128];
+
+	sprintf(an, "unit%d", Config.next_unit);
+	Config.next_unit++;
 	unit = (units_list *)malloc(sizeof(units_list));
 	unit->next = NULL;
 	unit->version = 1;
@@ -1991,6 +2000,7 @@
 	uuid_generate(uu);
 	uuid_unparse(uu, unit->uuid);
 	unit->name = xstrcpy(param);
+	unit->alias = xstrcpy(an);
 	unit->air_address = unit->beer_address = unit->heater_address = unit->cooler_address = \
 			    unit->fan_address = unit->door_address = unit->light_address = \
 			    unit->psu_address = unit->profile = NULL;
@@ -2072,6 +2082,7 @@
 		srv_send((char *)"213 Unit listing follows:");
 		srv_send((char *)"NAME,%s", unit->name);
 		srv_send((char *)"UUID,%s", unit->uuid);
+		srv_send((char *)"ALIAS,%s", unit->alias);
 		srv_send((char *)"VOLUME,%2f", unit->volume);
 		srv_send((char *)"AIR_ADDRESS,%s", unit->air_address);
 		srv_send((char *)"AIR_STATE,%s", TEMPSTATE[unit->air_state]);

mercurial