bmsd/fermenters.c

changeset 677
6e82fece1f8f
parent 674
c865e3cdee04
child 679
48f8f3fce7c0
equal deleted inserted replaced
676:b0718965dcb1 677:6e82fece1f8f
318 fermenter->yeast_hi = 24; 318 fermenter->yeast_hi = 24;
319 } 319 }
320 } 320 }
321 json_object_put(jobj); 321 json_object_put(jobj);
322 322
323 msg = xstrcpy((char *)"{\"device\":\"fermenter\",\"node\":\""); 323 msg = xstrcpy((char *)"{\"device\":\"fermenters\",\"node\":\"");
324 msg = xstrcat(msg, edge_node); 324 msg = xstrcat(msg, edge_node);
325 msg = xstrcat(msg, (char *)"\",\"unit\":\""); 325 msg = xstrcat(msg, (char *)"\",\"unit\":\"");
326 msg = xstrcat(msg, alias); 326 msg = xstrcat(msg, alias);
327 msg = xstrcat(msg, (char *)"\",\"online\":"); 327 msg = xstrcat(msg, (char *)"\",\"online\":");
328 msg = xstrcat(msg, fermenter->online ? (char *)"1":(char *)"0"); 328 msg = xstrcat(msg, fermenter->online ? (char *)"1":(char *)"0");
759 for (tmpp = fermenters; tmpp; tmpp = tmpp->next) { 759 for (tmpp = fermenters; tmpp; tmpp = tmpp->next) {
760 if ((strcmp(tmpp->node, edge_node) == 0) && (strcmp(tmpp->alias, alias) == 0)) { 760 if ((strcmp(tmpp->node, edge_node) == 0) && (strcmp(tmpp->alias, alias) == 0)) {
761 if (tmpp->online) { 761 if (tmpp->online) {
762 syslog(LOG_NOTICE, "Offline fermenter %s/%s", tmpp->node, tmpp->alias); 762 syslog(LOG_NOTICE, "Offline fermenter %s/%s", tmpp->node, tmpp->alias);
763 tmpp->online = false; 763 tmpp->online = false;
764 msg = xstrcpy((char *)"{\"device\":\"fermenter\",\"node\":\""); 764 msg = xstrcpy((char *)"{\"device\":\"fermenters\",\"node\":\"");
765 msg = xstrcat(msg, edge_node); 765 msg = xstrcat(msg, edge_node);
766 msg = xstrcat(msg, (char *)"\",\"unit\":\""); 766 msg = xstrcat(msg, (char *)"\",\"unit\":\"");
767 msg = xstrcat(msg, alias); 767 msg = xstrcat(msg, alias);
768 msg = xstrcat(msg, (char *)"\",\"online\":0}"); 768 msg = xstrcat(msg, (char *)"\",\"online\":0}");
769 ws_broadcast(msg); 769 ws_broadcast(msg);
777 for (tmpp = fermenters; tmpp; tmpp = tmpp->next) { 777 for (tmpp = fermenters; tmpp; tmpp = tmpp->next) {
778 if (strcmp(tmpp->node, edge_node) == 0) { 778 if (strcmp(tmpp->node, edge_node) == 0) {
779 if (tmpp->online) { 779 if (tmpp->online) {
780 syslog(LOG_NOTICE, "Offline fermenter %s/%s", tmpp->node, tmpp->alias); 780 syslog(LOG_NOTICE, "Offline fermenter %s/%s", tmpp->node, tmpp->alias);
781 tmpp->online = false; 781 tmpp->online = false;
782 msg = xstrcpy((char *)"{\"device\":\"fermenter\",\"node\":\""); 782 msg = xstrcpy((char *)"{\"device\":\"fermenters\",\"node\":\"");
783 msg = xstrcat(msg, edge_node); 783 msg = xstrcat(msg, edge_node);
784 msg = xstrcat(msg, (char *)"\",\"unit\":\""); 784 msg = xstrcat(msg, (char *)"\",\"unit\":\"");
785 msg = xstrcat(msg, tmpp->alias); 785 msg = xstrcat(msg, tmpp->alias);
786 msg = xstrcat(msg, (char *)"\",\"online\":0}"); 786 msg = xstrcat(msg, (char *)"\",\"online\":0}");
787 ws_broadcast(msg); 787 ws_broadcast(msg);

mercurial