diff -r 897bf2a43253 -r 29e7223e37ae bmsd/ispindels.c --- a/bmsd/ispindels.c Sat Jan 14 11:25:20 2023 +0100 +++ b/bmsd/ispindels.c Sat Feb 11 15:53:16 2023 +0100 @@ -3,7 +3,7 @@ * @brief Handle ispindels data * @author Michiel Broek * - * Copyright (C) 2019-2022 + * Copyright (C) 2019-2023 * * This file is part of the bms (Brewery Management System) * @@ -58,7 +58,13 @@ msg = xstrcat(msg, ispindel->beercode); msg = xstrcat(msg, (char *)"\",\"beername\":\""); msg = xstrcat(msg, ispindel->beername); - msg = xstrcat(msg, (char *)"\",\"temperature\":"); + msg = xstrcat(msg, (char *)"\",\"yeast_lo\":"); + snprintf(buf, 64, "%.3f", ispindel->yeast_lo); + msg = xstrcat(msg, buf); + msg = xstrcat(msg, (char *)",\"yeast_hi\":"); + snprintf(buf, 64, "%.3f", ispindel->yeast_hi); + msg = xstrcat(msg, buf); + msg = xstrcat(msg, (char *)",\"temperature\":"); snprintf(buf, 64, "%.4f", ispindel->temperature); msg = xstrcat(msg, buf); msg = xstrcat(msg, (char *)",\"angle\":"); @@ -89,7 +95,8 @@ struct json_object *jobj, *val; sys_ispindel_list *tmpp; char *node = NULL, *alias = NULL, *mode = NULL, *beeruuid = NULL, *beercode = NULL, *beername = NULL; - char query[512], *end; + float yeast_lo = 20, yeast_hi = 25; + char query[512], buf[65], *end; MYSQL *con2 = NULL; /* @@ -106,6 +113,10 @@ beercode = xstrcpy((char *)json_object_get_string(val)); if (json_object_object_get_ex(jobj, "beername", &val)) beername = xstrcpy((char *)json_object_get_string(val)); + if (json_object_object_get_ex(jobj, "yeast_lo", &val)) + yeast_lo = json_object_get_double(val); + if (json_object_object_get_ex(jobj, "yeast_hi", &val)) + yeast_hi = json_object_get_double(val); if (json_object_object_get_ex(jobj, "mode", &val)) mode = xstrcpy((char *)json_object_get_string(val)); json_object_put(jobj); @@ -130,7 +141,13 @@ end += mysql_real_escape_string(con2, end, beercode, strlen(beercode)); end = stpcpy(end, "', beername='"); end += mysql_real_escape_string(con2, end, beername, strlen(beername)); - end = stpcpy(end, "', og_gravity='0.0' WHERE node='"); + end = stpcpy(end, "', og_gravity='0.0', yeast_lo='"); + snprintf(buf, 64, "%.3f", yeast_lo); + end = stpcpy(end, buf); + end = stpcpy(end, "', yeast_hi='"); + snprintf(buf, 64, "%.3f", yeast_hi); + end = stpcpy(end, buf); + end = stpcpy(end, "' WHERE node='"); end += mysql_real_escape_string(con2, end, node, strlen(node)); end = stpcpy(end, "'"); @@ -148,6 +165,8 @@ free(tmpp->beeruuid); tmpp->beeruuid = xstrcpy(beeruuid); tmpp->og_gravity = 0.0; + tmpp->yeast_lo = yeast_lo; + tmpp->yeast_hi = yeast_hi; /* Report new state to the client */ ispindel_ws_send(tmpp); syslog(LOG_NOTICE, "Set ispindel %s/%s new beer %s %s", node, alias, beercode, beername);