diff -r 6d97eb820cc1 -r 3518c07737d8 thermferm/rdconfig.c --- a/thermferm/rdconfig.c Sat Apr 20 11:48:20 2024 +0200 +++ b/thermferm/rdconfig.c Mon Apr 22 11:33:04 2024 +0200 @@ -33,7 +33,6 @@ #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 UNITSTAGE[4][12] = { "PRIMARY", "SECONDARY", "TERTIARY", "CARBONATION" }; const char PROFSTATE[5][6] = { "OFF", "PAUSE", "RUN", "DONE", "ABORT" }; @@ -59,14 +58,14 @@ free(Config.name); Config.name = NULL; - Config.my_port = 6554; - Config.tempFormat = 'C'; - if (Config.temp_address) - free(Config.temp_address); - if (Config.hum_address) - free(Config.hum_address); + Config.server_port = 6554; + Config.websocket_port = 8020; + if (Config.temp_uuid) + free(Config.temp_uuid); + if (Config.hum_uuid) + free(Config.hum_uuid); Config.temp_hum_idx = 0; - Config.temp_address = Config.hum_address = NULL; + Config.temp_uuid = Config.hum_uuid = NULL; Config.temp_value = 20000; Config.temp_state = Config.hum_state = 1; // missing Config.hum_value = 50000; @@ -219,13 +218,13 @@ xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", Config.name); xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", Config.uuid); - xmlTextWriterWriteFormatElement(writer, BAD_CAST "LISTEN_PORT", "%d", Config.my_port); - xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMPFORMAT", "%c", Config.tempFormat); + xmlTextWriterWriteFormatElement(writer, BAD_CAST "SERVER_PORT", "%d", Config.server_port); + xmlTextWriterWriteFormatElement(writer, BAD_CAST "WS_PORT", "%d", Config.websocket_port); - xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_ADDRESS", "%s", Config.temp_address); + xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_UUID", "%s", Config.temp_uuid); xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_STATE", "%d", Config.temp_state); xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_VALUE", "%d", Config.temp_value); - xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_ADDRESS", "%s", Config.hum_address); + xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_UUID", "%s", Config.hum_uuid); xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_STATE", "%d", Config.hum_state); xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_VALUE", "%d", Config.hum_value); xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_HUM_IDX", "%d", Config.temp_hum_idx); @@ -238,7 +237,6 @@ xmlTextWriterWriteFormatElement(writer, BAD_CAST "MQTT_USER", "%s", Config.mqtt_username); xmlTextWriterWriteFormatElement(writer, BAD_CAST "MQTT_PASS", "%s", Config.mqtt_password); } - xmlTextWriterWriteFormatElement(writer, BAD_CAST "WS_PORT", "%d", Config.websocket_port); /* * Start an element named "LCDS" as child of THERMFERM. @@ -579,7 +577,7 @@ unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = unit->beer_set_lo = unit->beer_set_hi = \ unit->fridge_set_lo = unit->fridge_set_hi = unit->profile_inittemp_lo = unit->profile_inittemp_hi = 20.0; - unit->air_state = unit->beer_state = unit->chiller_state = 1; // missing + unit->air_state = unit->beer_state = unit->chiller_state = DEVPRESENT_NO; // missing unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = \ unit->light_state = unit->light_timer = unit->psu_state = unit->mode = unit->prof_state = unit->stage = 0; unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \ @@ -1590,22 +1588,17 @@ if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) { Config.name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); } - if ((!xmlStrcmp(cur->name, (const xmlChar *)"LISTEN_PORT"))) { + if ((!xmlStrcmp(cur->name, (const xmlChar *)"SERVER_PORT")) || (!xmlStrcmp(cur->name, (const xmlChar *)"LISTEN_PORT"))) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); if (sscanf((const char *)key, "%d", &ival) == 1) - Config.my_port = ival; + Config.server_port = ival; xmlFree(key); } - if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMPFORMAT"))) { - key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); - Config.tempFormat = key[0]; - xmlFree(key); + if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_UUID")) || (!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_ADDRESS"))) { + Config.temp_uuid = (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); + if ((!xmlStrcmp(cur->name, (const xmlChar *)"HUM_UUID")) || (!xmlStrcmp(cur->name, (const xmlChar *)"HUM_ADDRESS"))) { + Config.hum_uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); } if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_HUM_IDX"))) { key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);