thermferm/rdconfig.c

changeset 206
78fb6f99e473
parent 194
9eaaba49450f
child 209
c5b1dfd83e81
--- a/thermferm/rdconfig.c	Sun Aug 10 13:26:35 2014 +0200
+++ b/thermferm/rdconfig.c	Sun Aug 10 14:45:11 2014 +0200
@@ -54,11 +54,14 @@
 
     Config.my_port = 6554;
     Config.tempFormat = 'C';
-    if (Config.air_address)
-	free(Config.air_address);
-    Config.air_address = NULL;
-    Config.air_temperature = 20000;
-    Config.air_state = 1;	// missing
+    if (Config.temp_address)
+	free(Config.temp_address);
+    if (Config.hum_address)
+	free(Config.hum_address);
+    Config.temp_address = Config.hum_address = NULL;
+    Config.temp_value = 20000;
+    Config.temp_state = Config.hum_state = 1;	// missing
+    Config.hum_value = 50000;
 
     for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) {
 	if (tmp2->uuid)
@@ -188,19 +191,29 @@
 	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 	return 1;
     }
-    if (Config.air_address) {
-    	if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", Config.air_address)) < 0) {
-	    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
-	    return 1;
-    	}
-	if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_STATE", "%d", Config.air_state)) < 0) {
-	    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
-	    return 1;                           
-	}
-	if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", Config.air_temperature)) < 0) {
-	    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
-	    return 1;
-	}
+    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_ADDRESS", "%s", Config.temp_address)) < 0) {
+	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+	return 1;
+    }
+    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_STATE", "%d", Config.temp_state)) < 0) {
+	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+	return 1;                           
+    }
+    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_VALUE", "%d", Config.temp_value)) < 0) {
+	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+	return 1;
+    }
+    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_ADDRESS", "%s", Config.hum_address)) < 0) {
+	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+	return 1;
+    }   
+    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_STATE", "%d", Config.hum_state)) < 0) {
+	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+	return 1;    
+    }   
+    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_VALUE", "%d", Config.hum_value)) < 0) {
+	syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+	return 1;
     }
 
 #ifdef HAVE_WIRINGPI_H
@@ -1221,8 +1234,11 @@
 	    Config.tempFormat = key[0];
 	    xmlFree(key);
 	}
-	if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_ADDRESS"))) {
-	    Config.air_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_ADDRESS"))) {
+	    Config.temp_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"HUM_ADDRESS"))) {
+	    Config.hum_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	}
 #ifdef HAVE_WIRINGPI_H
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCDS"))) {

mercurial