thermferm/rdconfig.c

changeset 675
825210ba2707
parent 666
48cc8868f9f4
child 693
3518c07737d8
equal deleted inserted replaced
674:6cabc02f4c8d 675:825210ba2707
236 xmlTextWriterWriteFormatElement(writer, BAD_CAST "MQTT_PORT", "%d", Config.mqtt_port); 236 xmlTextWriterWriteFormatElement(writer, BAD_CAST "MQTT_PORT", "%d", Config.mqtt_port);
237 if (Config.mqtt_username && Config.mqtt_password) { 237 if (Config.mqtt_username && Config.mqtt_password) {
238 xmlTextWriterWriteFormatElement(writer, BAD_CAST "MQTT_USER", "%s", Config.mqtt_username); 238 xmlTextWriterWriteFormatElement(writer, BAD_CAST "MQTT_USER", "%s", Config.mqtt_username);
239 xmlTextWriterWriteFormatElement(writer, BAD_CAST "MQTT_PASS", "%s", Config.mqtt_password); 239 xmlTextWriterWriteFormatElement(writer, BAD_CAST "MQTT_PASS", "%s", Config.mqtt_password);
240 } 240 }
241 xmlTextWriterWriteFormatElement(writer, BAD_CAST "WS_PORT", "%d", Config.websocket_port);
241 242
242 /* 243 /*
243 * Start an element named "LCDS" as child of THERMFERM. 244 * Start an element named "LCDS" as child of THERMFERM.
244 */ 245 */
245 xmlTextWriterStartElement(writer, BAD_CAST "LCDS"); 246 xmlTextWriterStartElement(writer, BAD_CAST "LCDS");
1566 syslog(LOG_NOTICE, "rdconfig: using %s", mypath); 1567 syslog(LOG_NOTICE, "rdconfig: using %s", mypath);
1567 1568
1568 Config.mqtt_host = xstrcpy((char *)"localhost"); 1569 Config.mqtt_host = xstrcpy((char *)"localhost");
1569 Config.mqtt_port = 1883; 1570 Config.mqtt_port = 1883;
1570 Config.next_unit = 1; 1571 Config.next_unit = 1;
1572 Config.websocket_port = 8020;
1571 1573
1572 if ((cur = xmlDocGetRootElement(doc)) == NULL) { 1574 if ((cur = xmlDocGetRootElement(doc)) == NULL) {
1573 syslog(LOG_NOTICE, "XML file %s empty.", mypath); 1575 syslog(LOG_NOTICE, "XML file %s empty.", mypath);
1574 xmlFreeDoc(doc); 1576 xmlFreeDoc(doc);
1575 return 1; 1577 return 1;
1633 } 1635 }
1634 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_PASS"))) { 1636 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MQTT_PASS"))) {
1635 Config.mqtt_password = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1637 Config.mqtt_password = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1636 } 1638 }
1637 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { 1639 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) {
1638 Config.uuid= (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1640 Config.uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1639 } 1641 }
1642 if ((!xmlStrcmp(cur->name, (const xmlChar *)"WS_PORT"))) {
1643 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1644 if (sscanf((const char *)key, "%d", &ival) == 1)
1645 Config.websocket_port = ival;
1646 xmlFree(key);
1647 }
1640 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCDS"))) { 1648 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LCDS"))) {
1641 parseLCDs(doc, cur); 1649 parseLCDs(doc, cur);
1642 } 1650 }
1643 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FERMENTERS"))) { 1651 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FERMENTERS"))) {
1644 parseFermenters(doc, cur); 1652 parseFermenters(doc, cur);

mercurial