diff -r 012576d7386d -r 1302abe92eb1 thermferm/rdconfig.c --- a/thermferm/rdconfig.c Fri Jul 11 22:53:33 2014 +0200 +++ b/thermferm/rdconfig.c Sat Jul 12 17:57:53 2014 +0200 @@ -29,6 +29,7 @@ #define MY_ENCODING "utf-8" +const char TEMPSTATE[3][8] = { "OK", "MISSING", "ERROR" }; const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" }; const char UNITmode[5] = { 'o', 'n', 'f', 'b', 'p' }; const char PROFSTATE[4][6] = { "OFF", "PAUSE", "RUN", "DONE" }; @@ -62,6 +63,8 @@ if (Config.air_address) free(Config.air_address); Config.air_address = NULL; + Config.air_temperature = 20000; + Config.air_state = 1; // missing for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) { if (tmp2->uuid) @@ -173,9 +176,19 @@ syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); return 1; } - if (Config.air_address && (rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", Config.air_address)) < 0) { - 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; + } } #ifdef HAVE_WIRINGPI_H @@ -303,13 +316,33 @@ syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); return 1; } - if (tmp3->air_address && ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", tmp3->air_address)) < 0)) { - syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); - return 1; + if (tmp3->air_address) { + if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_ADDRESS", "%s", tmp3->air_address)) < 0)) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } + if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_STATE", "%d", tmp3->air_state)) < 0)) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } + if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", tmp3->air_temperature)) < 0)) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } } - if (tmp3->beer_address && ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) { - syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); - return 1; + if (tmp3->beer_address) { + if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } + if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_STATE", "%d", tmp3->beer_state)) < 0)) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } + if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) { + syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); + return 1; + } } if (tmp3->io1_address && ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO1_ADDRESS", "%s", tmp3->io1_address)) < 0)) { syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); @@ -631,7 +664,8 @@ unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->io1_address = unit->io2_address = unit->profile = NULL; unit->volume = 0.0; unit->heater_available = unit->cooler_available = unit->fan_available = FALSE; - unit->air_temp = unit->beer_temp = unit->beer_set = unit->fridge_set = 20.0; + unit->air_temperature = unit->beer_temperature = unit->beer_set = unit->fridge_set = 20.0; + unit->air_state = unit->beer_state = 1; // missing unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = unit->prof_state = 0; unit->temp_set_min = 1.0; unit->temp_set_max = 30.0; @@ -665,9 +699,33 @@ if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_ADDRESS"))) { unit->air_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_STATE"))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%d", &ival) == 1) + unit->air_state = ival; + xmlFree(key); + } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_TEMPERATURE"))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%d", &ival) == 1) + unit->air_temperature = ival; + xmlFree(key); + } if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_ADDRESS"))) { unit->beer_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_STATE"))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%d", &ival) == 1) + unit->beer_state = ival; + xmlFree(key); + } + if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_TEMPERATURE"))) { + key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); + if (sscanf((const char *)key, "%d", &ival) == 1) + unit->beer_temperature = ival; + xmlFree(key); + } if ((!xmlStrcmp(cur->name, (const xmlChar *)"IO1_ADDRESS"))) { unit->io1_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); }