thermferm/server.c

changeset 614
389097dc665d
parent 606
798dd0c4fd00
child 645
49eb753a958b
equal deleted inserted replaced
613:163fcb0914e2 614:389097dc665d
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2008-2020 2 * Copyright (C) 2008-2022
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of the mbsePi-apps 6 * This file is part of the mbsePi-apps
7 * 7 *
1208 free(current->air_address); 1208 free(current->air_address);
1209 current->air_address = NULL; 1209 current->air_address = NULL;
1210 if (current->beer_address) 1210 if (current->beer_address)
1211 free(current->beer_address); 1211 free(current->beer_address);
1212 current->beer_address = NULL; 1212 current->beer_address = NULL;
1213 if (current->beer_address2)
1214 free(current->beer_address2);
1215 current->beer_address2 = NULL;
1213 if (current->chiller_address) 1216 if (current->chiller_address)
1214 free(current->chiller_address); 1217 free(current->chiller_address);
1215 current->chiller_address = NULL; 1218 current->chiller_address = NULL;
1216 if (current->heater_address) 1219 if (current->heater_address)
1217 free(current->heater_address); 1220 free(current->heater_address);
1268 free(current->air_address); 1271 free(current->air_address);
1269 current->air_address = NULL; 1272 current->air_address = NULL;
1270 if (current->beer_address) 1273 if (current->beer_address)
1271 free(current->beer_address); 1274 free(current->beer_address);
1272 current->beer_address = NULL; 1275 current->beer_address = NULL;
1276 if (current->beer_address2)
1277 free(current->beer_address2);
1278 current->beer_address2 = NULL;
1273 if (current->chiller_address) 1279 if (current->chiller_address)
1274 free(current->chiller_address); 1280 free(current->chiller_address);
1275 current->chiller_address = NULL; 1281 current->chiller_address = NULL;
1276 if (current->heater_address) 1282 if (current->heater_address)
1277 free(current->heater_address); 1283 free(current->heater_address);
1391 uuid_unparse(uu, unit->uuid); 1397 uuid_unparse(uu, unit->uuid);
1392 unit->product_uuid = NULL; 1398 unit->product_uuid = NULL;
1393 unit->product_code = xstrcpy((char *)"FAKE0000"); 1399 unit->product_code = xstrcpy((char *)"FAKE0000");
1394 unit->product_name = xstrcpy(param); 1400 unit->product_name = xstrcpy(param);
1395 unit->alias = xstrcpy(an); 1401 unit->alias = xstrcpy(an);
1396 unit->air_address = unit->beer_address = unit->chiller_address = unit->heater_address = unit->cooler_address = \ 1402 unit->air_address = unit->beer_address = unit->beer_address2 = unit->chiller_address = unit->heater_address = unit->cooler_address = \
1397 unit->fan_address = unit->door_address = unit->light_address = \ 1403 unit->fan_address = unit->door_address = unit->light_address = \
1398 unit->psu_address = unit->profile_uuid = unit->profile_name = NULL; 1404 unit->psu_address = unit->profile_uuid = unit->profile_name = NULL;
1399 unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \ 1405 unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \
1400 unit->door_idx = unit->light_idx = unit->psu_idx = unit->profile_fridge_mode = \ 1406 unit->door_idx = unit->light_idx = unit->psu_idx = unit->profile_fridge_mode = \
1401 unit->profile_duration = unit->profile_totalsteps = 0; 1407 unit->profile_duration = unit->profile_totalsteps = 0;
1486 srv_send((char *)"AIR_ADDRESS,%s", unit->air_address); 1492 srv_send((char *)"AIR_ADDRESS,%s", unit->air_address);
1487 srv_send((char *)"AIR_STATE,%s", TEMPSTATE[unit->air_state]); 1493 srv_send((char *)"AIR_STATE,%s", TEMPSTATE[unit->air_state]);
1488 srv_send((char *)"AIR_TEMPERATURE,%.3f", unit->air_temperature / 1000.0); 1494 srv_send((char *)"AIR_TEMPERATURE,%.3f", unit->air_temperature / 1000.0);
1489 srv_send((char *)"AIR_IDX,%d", unit->air_idx); 1495 srv_send((char *)"AIR_IDX,%d", unit->air_idx);
1490 srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address)); 1496 srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address));
1497 srv_send((char *)"BEER_ADDRESS2,%s", MBSE_SS(unit->beer_address2));
1491 srv_send((char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]); 1498 srv_send((char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]);
1492 srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0); 1499 srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0);
1493 srv_send((char *)"BEER_IDX,%d", unit->beer_idx); 1500 srv_send((char *)"BEER_IDX,%d", unit->beer_idx);
1494 srv_send((char *)"CHILLER_ADDRESS,%s", MBSE_SS(unit->chiller_address)); 1501 srv_send((char *)"CHILLER_ADDRESS,%s", MBSE_SS(unit->chiller_address));
1495 srv_send((char *)"CHILLER_STATE,%s", TEMPSTATE[unit->chiller_state]); 1502 srv_send((char *)"CHILLER_STATE,%s", TEMPSTATE[unit->chiller_state]);
1668 device_count(TRUE, unit->beer_address); 1675 device_count(TRUE, unit->beer_address);
1669 } else 1676 } else
1670 unit->beer_address = NULL; 1677 unit->beer_address = NULL;
1671 unit->mqtt_flag |= MQTT_FLAG_DATA; 1678 unit->mqtt_flag |= MQTT_FLAG_DATA;
1672 1679
1680 } else if (strcmp(kwd, (char *)"BEER_ADDRESS2") == 0) {
1681 if (val && unit->beer_address2 && (strcmp(val, unit->beer_address2)))
1682 syslog(LOG_NOTICE, "Fermenter unit %s beer address alt `%s' to `%s'", unit->uuid, unit->beer_address2, val);
1683 if (unit->beer_address2) {
1684 device_count(FALSE, unit->beer_address2);
1685 free(unit->beer_address2);
1686 }
1687 if (val) {
1688 unit->beer_address2 = xstrcpy(val);
1689 device_count(TRUE, unit->beer_address2);
1690 } else
1691 unit->beer_address2 = NULL;
1692 unit->mqtt_flag |= MQTT_FLAG_DATA;
1693
1673 } else if (val && (strcmp(kwd, (char *)"BEER_IDX") == 0)) { 1694 } else if (val && (strcmp(kwd, (char *)"BEER_IDX") == 0)) {
1674 if (sscanf(val, "%d", &ival) == 1) { 1695 if (sscanf(val, "%d", &ival) == 1) {
1675 if (unit->beer_idx != ival) 1696 if (unit->beer_idx != ival)
1676 syslog(LOG_NOTICE, "Fermenter unit %s beer idx %d to %d", unit->uuid, unit->beer_idx, ival); 1697 syslog(LOG_NOTICE, "Fermenter unit %s beer idx %d to %d", unit->uuid, unit->beer_idx, ival);
1677 unit->beer_idx = ival; 1698 unit->beer_idx = ival;

mercurial