80 Config.uuid = NULL; |
80 Config.uuid = NULL; |
81 |
81 |
82 for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) { |
82 for (tmp2 = Config.units; tmp2; tmp2 = tmp2->next) { |
83 if (tmp2->uuid) |
83 if (tmp2->uuid) |
84 free(tmp2->uuid); |
84 free(tmp2->uuid); |
85 if (tmp2->name) |
85 if (tmp2->product_uuid) |
86 free(tmp2->name); |
86 free(tmp2->product_uuid); |
|
87 if (tmp2->product_code) |
|
88 free(tmp2->product_code); |
|
89 if (tmp2->product_name) |
|
90 free(tmp2->product_name); |
87 if (tmp2->air_address) |
91 if (tmp2->air_address) |
88 free(tmp2->air_address); |
92 free(tmp2->air_address); |
89 if (tmp2->beer_address) |
93 if (tmp2->beer_address) |
90 free(tmp2->beer_address); |
94 free(tmp2->beer_address); |
91 if (tmp2->chiller_address) |
95 if (tmp2->chiller_address) |
354 } |
358 } |
355 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp3->uuid)) < 0) { |
359 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", tmp3->uuid)) < 0) { |
356 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
360 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
357 return 1; |
361 return 1; |
358 } |
362 } |
359 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", tmp3->name)) < 0) { |
363 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRODUCT_UUID", "%s", tmp3->product_uuid)) < 0) { |
|
364 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
365 return 1; |
|
366 } |
|
367 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRODUCT_CODE", "%s", tmp3->product_code)) < 0) { |
|
368 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
369 return 1; |
|
370 } |
|
371 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRODUCT_NAME", "%s", tmp3->product_name)) < 0) { |
360 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
372 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
361 return 1; |
373 return 1; |
362 } |
374 } |
363 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ALIAS", "%s", tmp3->alias)) < 0) { |
375 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ALIAS", "%s", tmp3->alias)) < 0) { |
364 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
376 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
1114 units_list *unit, *tmp; |
1126 units_list *unit, *tmp; |
1115 |
1127 |
1116 unit = (units_list *)malloc(sizeof(units_list)); |
1128 unit = (units_list *)malloc(sizeof(units_list)); |
1117 unit->next = NULL; |
1129 unit->next = NULL; |
1118 unit->version = 1; |
1130 unit->version = 1; |
1119 unit->uuid = unit->name = unit->alias = unit->air_address = unit->beer_address = unit->chiller_address = unit->heater_address = \ |
1131 unit->uuid = unit->product_uuid = unit->product_code = unit->product_name = unit->event_msg = \ |
|
1132 unit->alias = unit->air_address = unit->beer_address = unit->chiller_address = unit->heater_address = \ |
1120 unit->cooler_address = unit->fan_address = unit->door_address = \ |
1133 unit->cooler_address = unit->fan_address = unit->door_address = \ |
1121 unit->light_address = unit->psu_address = unit->profile = NULL; |
1134 unit->light_address = unit->psu_address = unit->profile = NULL; |
1122 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
1135 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
1123 unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = unit->beer_set = unit->fridge_set = 20.0; |
1136 unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = unit->beer_set = unit->fridge_set = 20.0; |
1124 unit->air_state = unit->beer_state = unit->chiller_state = 1; // missing |
1137 unit->air_state = unit->beer_state = unit->chiller_state = 1; // missing |
1152 } |
1165 } |
1153 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { |
1166 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { |
1154 unit->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1167 unit->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1155 } |
1168 } |
1156 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) { |
1169 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) { |
1157 unit->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1170 /* |
|
1171 * Upgrade to product code and name |
|
1172 */ |
|
1173 char *oldname = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1174 if (strstr(oldname, (char *)" ")) { |
|
1175 unit->product_code = xstrcpy(strtok(oldname, " ")); |
|
1176 unit->product_name = xstrcpy(strtok(NULL, "\0")); |
|
1177 } else { |
|
1178 unit->product_code = xstrcpy((char *)"000000"); |
|
1179 unit->product_name = xstrcpy(oldname); |
|
1180 } |
|
1181 } |
|
1182 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PRODUCT_UUID"))) { |
|
1183 unit->product_uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1184 } |
|
1185 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PRODUCT_CODE"))) { |
|
1186 unit->product_code = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1187 } |
|
1188 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PRODUCT_NAME"))) { |
|
1189 unit->product_name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1158 } |
1190 } |
1159 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ALIAS"))) { |
1191 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ALIAS"))) { |
1160 unit->alias = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1192 unit->alias = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1161 } |
1193 } |
1162 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VOLUME"))) { |
1194 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VOLUME"))) { |