1003 srv_send((char *)"HUM_ADDRESS,%s", Config.hum_address); |
1003 srv_send((char *)"HUM_ADDRESS,%s", Config.hum_address); |
1004 srv_send((char *)"HUM_STATE,%s", TEMPSTATE[Config.hum_state]); |
1004 srv_send((char *)"HUM_STATE,%s", TEMPSTATE[Config.hum_state]); |
1005 srv_send((char *)"HUM_VALUE,%.0f", Config.hum_value / 1000.0); |
1005 srv_send((char *)"HUM_VALUE,%.0f", Config.hum_value / 1000.0); |
1006 srv_send((char *)"LCD_COLS,%d", Config.lcd_cols); |
1006 srv_send((char *)"LCD_COLS,%d", Config.lcd_cols); |
1007 srv_send((char *)"LCD_ROWS,%d", Config.lcd_rows); |
1007 srv_send((char *)"LCD_ROWS,%d", Config.lcd_rows); |
|
1008 srv_send((char *)"NEXT_UNIT,%d", Config.next_unit); |
|
1009 #ifdef HAVE_MOSQUITTO_H |
|
1010 srv_send((char *)"MQTT_HOST,%s", Config.mqtt_host); |
|
1011 srv_send((char *)"MQTT_PORT,%d", Config.mqtt_port); |
|
1012 #endif |
1008 srv_send((char *)"."); |
1013 srv_send((char *)"."); |
1009 return 0; |
1014 return 0; |
1010 } |
1015 } |
1011 |
1016 |
1012 if (strcmp(opt, (char *)"PUT") == 0) { |
1017 if (strcmp(opt, (char *)"PUT") == 0) { |
1982 srv_send((char *)"502 Parameter missing"); |
1987 srv_send((char *)"502 Parameter missing"); |
1983 return 0; |
1988 return 0; |
1984 } |
1989 } |
1985 |
1990 |
1986 if (strcmp(opt, (char *)"ADD") == 0) { |
1991 if (strcmp(opt, (char *)"ADD") == 0) { |
|
1992 char an[128]; |
|
1993 |
|
1994 sprintf(an, "unit%d", Config.next_unit); |
|
1995 Config.next_unit++; |
1987 unit = (units_list *)malloc(sizeof(units_list)); |
1996 unit = (units_list *)malloc(sizeof(units_list)); |
1988 unit->next = NULL; |
1997 unit->next = NULL; |
1989 unit->version = 1; |
1998 unit->version = 1; |
1990 unit->uuid = malloc(37); |
1999 unit->uuid = malloc(37); |
1991 uuid_generate(uu); |
2000 uuid_generate(uu); |
1992 uuid_unparse(uu, unit->uuid); |
2001 uuid_unparse(uu, unit->uuid); |
1993 unit->name = xstrcpy(param); |
2002 unit->name = xstrcpy(param); |
|
2003 unit->alias = xstrcpy(an); |
1994 unit->air_address = unit->beer_address = unit->heater_address = unit->cooler_address = \ |
2004 unit->air_address = unit->beer_address = unit->heater_address = unit->cooler_address = \ |
1995 unit->fan_address = unit->door_address = unit->light_address = \ |
2005 unit->fan_address = unit->door_address = unit->light_address = \ |
1996 unit->psu_address = unit->profile = NULL; |
2006 unit->psu_address = unit->profile = NULL; |
1997 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
2007 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
1998 unit->air_state = unit->beer_state = 1; |
2008 unit->air_state = unit->beer_state = 1; |
2070 for (unit = Config.units; unit; unit = unit->next) { |
2080 for (unit = Config.units; unit; unit = unit->next) { |
2071 if (strcmp(param, unit->uuid) == 0) { |
2081 if (strcmp(param, unit->uuid) == 0) { |
2072 srv_send((char *)"213 Unit listing follows:"); |
2082 srv_send((char *)"213 Unit listing follows:"); |
2073 srv_send((char *)"NAME,%s", unit->name); |
2083 srv_send((char *)"NAME,%s", unit->name); |
2074 srv_send((char *)"UUID,%s", unit->uuid); |
2084 srv_send((char *)"UUID,%s", unit->uuid); |
|
2085 srv_send((char *)"ALIAS,%s", unit->alias); |
2075 srv_send((char *)"VOLUME,%2f", unit->volume); |
2086 srv_send((char *)"VOLUME,%2f", unit->volume); |
2076 srv_send((char *)"AIR_ADDRESS,%s", unit->air_address); |
2087 srv_send((char *)"AIR_ADDRESS,%s", unit->air_address); |
2077 srv_send((char *)"AIR_STATE,%s", TEMPSTATE[unit->air_state]); |
2088 srv_send((char *)"AIR_STATE,%s", TEMPSTATE[unit->air_state]); |
2078 srv_send((char *)"AIR_TEMPERATURE,%.3f", unit->air_temperature / 1000.0); |
2089 srv_send((char *)"AIR_TEMPERATURE,%.3f", unit->air_temperature / 1000.0); |
2079 srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address)); |
2090 srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address)); |