1862 free(current->air_address); |
1862 free(current->air_address); |
1863 current->air_address = NULL; |
1863 current->air_address = NULL; |
1864 if (current->beer_address) |
1864 if (current->beer_address) |
1865 free(current->beer_address); |
1865 free(current->beer_address); |
1866 current->beer_address = NULL; |
1866 current->beer_address = NULL; |
|
1867 if (current->chiller_address) |
|
1868 free(current->chiller_address); |
|
1869 current->chiller_address = NULL; |
1867 if (current->heater_address) |
1870 if (current->heater_address) |
1868 free(current->heater_address); |
1871 free(current->heater_address); |
1869 current->heater_address = NULL; |
1872 current->heater_address = NULL; |
1870 if (current->cooler_address) |
1873 if (current->cooler_address) |
1871 free(current->cooler_address); |
1874 free(current->cooler_address); |
1902 free(current->air_address); |
1905 free(current->air_address); |
1903 current->air_address = NULL; |
1906 current->air_address = NULL; |
1904 if (current->beer_address) |
1907 if (current->beer_address) |
1905 free(current->beer_address); |
1908 free(current->beer_address); |
1906 current->beer_address = NULL; |
1909 current->beer_address = NULL; |
|
1910 if (current->chiller_address) |
|
1911 free(current->chiller_address); |
|
1912 current->chiller_address = NULL; |
1907 if (current->heater_address) |
1913 if (current->heater_address) |
1908 free(current->heater_address); |
1914 free(current->heater_address); |
1909 current->heater_address = NULL; |
1915 current->heater_address = NULL; |
1910 if (current->cooler_address) |
1916 if (current->cooler_address) |
1911 free(current->cooler_address); |
1917 free(current->cooler_address); |
2007 unit->uuid = malloc(37); |
2013 unit->uuid = malloc(37); |
2008 uuid_generate(uu); |
2014 uuid_generate(uu); |
2009 uuid_unparse(uu, unit->uuid); |
2015 uuid_unparse(uu, unit->uuid); |
2010 unit->name = xstrcpy(param); |
2016 unit->name = xstrcpy(param); |
2011 unit->alias = xstrcpy(an); |
2017 unit->alias = xstrcpy(an); |
2012 unit->air_address = unit->beer_address = unit->heater_address = unit->cooler_address = \ |
2018 unit->air_address = unit->beer_address = unit->chiller_address = unit->heater_address = unit->cooler_address = \ |
2013 unit->fan_address = unit->door_address = unit->light_address = \ |
2019 unit->fan_address = unit->door_address = unit->light_address = \ |
2014 unit->psu_address = unit->profile = NULL; |
2020 unit->psu_address = unit->profile = NULL; |
2015 unit->air_idx = unit->beer_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \ |
2021 unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \ |
2016 unit->door_idx = unit->light_idx = unit->psu_idx = 0; |
2022 unit->door_idx = unit->light_idx = unit->psu_idx = 0; |
2017 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
2023 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
2018 unit->air_state = unit->beer_state = 1; |
2024 unit->air_state = unit->beer_state = unit->chiller_state = 1; |
2019 unit->air_temperature = unit->beer_temperature = 20000; |
2025 unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = 20000; |
2020 unit->beer_set = unit->fridge_set = 20.0; |
2026 unit->beer_set = unit->fridge_set = 20.0; |
2021 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = \ |
2027 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = \ |
2022 unit->light_state = unit->psu_state = unit->prof_state = 0; |
2028 unit->light_state = unit->psu_state = unit->prof_state = 0; |
2023 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ |
2029 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ |
2024 unit->light_delay = 1; /* 15 seconds delay */ |
2030 unit->light_delay = 1; /* 15 seconds delay */ |
2100 srv_send((char *)"AIR_IDX,%d", unit->air_idx); |
2106 srv_send((char *)"AIR_IDX,%d", unit->air_idx); |
2101 srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address)); |
2107 srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address)); |
2102 srv_send((char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]); |
2108 srv_send((char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]); |
2103 srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0); |
2109 srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0); |
2104 srv_send((char *)"BEER_IDX,%d", unit->beer_idx); |
2110 srv_send((char *)"BEER_IDX,%d", unit->beer_idx); |
|
2111 srv_send((char *)"CHILLER_ADDRESS,%s", MBSE_SS(unit->chiller_address)); |
|
2112 srv_send((char *)"CHILLER_STATE,%s", TEMPSTATE[unit->chiller_state]); |
|
2113 srv_send((char *)"CHILLER_TEMPERATURE,%.3f", unit->chiller_temperature / 1000.0); |
|
2114 srv_send((char *)"CHILLER_IDX,%d", unit->chiller_idx); |
2105 srv_send((char *)"HEATER_ADDRESS,%s", unit->heater_address); |
2115 srv_send((char *)"HEATER_ADDRESS,%s", unit->heater_address); |
2106 srv_send((char *)"HEATER_STATE,%d", unit->heater_state); |
2116 srv_send((char *)"HEATER_STATE,%d", unit->heater_state); |
2107 srv_send((char *)"HEATER_DELAY,%d", unit->heater_delay); |
2117 srv_send((char *)"HEATER_DELAY,%d", unit->heater_delay); |
2108 srv_send((char *)"HEATER_USAGE,%d", unit->heater_usage); |
2118 srv_send((char *)"HEATER_USAGE,%d", unit->heater_usage); |
2109 srv_send((char *)"HEATER_IDX,%d", unit->heater_idx); |
2119 srv_send((char *)"HEATER_IDX,%d", unit->heater_idx); |
2262 if (unit->beer_idx != ival) |
2272 if (unit->beer_idx != ival) |
2263 syslog(LOG_NOTICE, "Fermenter unit %s beer idx %d to %d", unit->uuid, unit->beer_idx, ival); |
2273 syslog(LOG_NOTICE, "Fermenter unit %s beer idx %d to %d", unit->uuid, unit->beer_idx, ival); |
2264 unit->beer_idx = ival; |
2274 unit->beer_idx = ival; |
2265 } |
2275 } |
2266 |
2276 |
|
2277 } else if (strcmp(kwd, (char *)"CHILLER_ADDRESS") == 0) { |
|
2278 if (val && unit->chiller_address && (strcmp(val, unit->chiller_address))) |
|
2279 syslog(LOG_NOTICE, "Fermenter unit %s chiller address `%s' to `%s'", unit->uuid, unit->chiller_address, val); |
|
2280 if (unit->chiller_address) { |
|
2281 device_count(FALSE, unit->chiller_address); |
|
2282 free(unit->chiller_address); |
|
2283 } |
|
2284 if (val) { |
|
2285 unit->chiller_address = xstrcpy(val); |
|
2286 device_count(TRUE, unit->chiller_address); |
|
2287 } else |
|
2288 unit->chiller_address = NULL; |
|
2289 unit->mqtt_flag |= MQTT_FLAG_DATA; |
|
2290 |
|
2291 } else if (val && (strcmp(kwd, (char *)"CHILLER_IDX") == 0)) { |
|
2292 if (sscanf(val, "%d", &ival) == 1) { |
|
2293 if (unit->chiller_idx != ival) |
|
2294 syslog(LOG_NOTICE, "Fermenter unit %s chiller idx %d to %d", unit->uuid, unit->chiller_idx, ival); |
|
2295 unit->beer_idx = ival; |
|
2296 } |
|
2297 |
2267 } else if (strcmp(kwd, (char *)"HEATER_ADDRESS") == 0) { |
2298 } else if (strcmp(kwd, (char *)"HEATER_ADDRESS") == 0) { |
2268 if (val && unit->heater_address && (strcmp(val, unit->heater_address))) |
2299 if (val && unit->heater_address && (strcmp(val, unit->heater_address))) |
2269 syslog(LOG_NOTICE, "Fermenter unit %s heater address `%s' to `%s'", unit->uuid, unit->heater_address, val); |
2300 syslog(LOG_NOTICE, "Fermenter unit %s heater address `%s' to `%s'", unit->uuid, unit->heater_address, val); |
2270 if (unit->heater_address) { |
2301 if (unit->heater_address) { |
2271 device_count(FALSE, unit->heater_address); |
2302 device_count(FALSE, unit->heater_address); |