bmsd/ispindels.c

changeset 686
ca1fbb3bd3db
parent 684
ccb9f24d0fe9
child 718
59b02b64131b
equal deleted inserted replaced
685:a4fcdf24b5e7 686:ca1fbb3bd3db
200 200
201 void ispindel_set(char *node, char *payload) 201 void ispindel_set(char *node, char *payload)
202 { 202 {
203 sys_ispindel_list *ispindel, *tmpp; 203 sys_ispindel_list *ispindel, *tmpp;
204 struct json_object *jobj, *metric, *val; 204 struct json_object *jobj, *metric, *val;
205 bool new_ispindel = true, report = false; 205 bool new_ispindel = true;
206 char *datetime, buf[65], *line, *logfile; 206 char *datetime, buf[65], *line, *logfile;
207 struct tm *mytime; 207 struct tm *mytime;
208 time_t timestamp; 208 time_t timestamp;
209 FILE *fp; 209 FILE *fp;
210 210
236 ispindel->mode = xstrcpy((char *)"OFF"); 236 ispindel->mode = xstrcpy((char *)"OFF");
237 } 237 }
238 238
239 if (! ispindel->online) { 239 if (! ispindel->online) {
240 ispindel->online = true; 240 ispindel->online = true;
241 report = true;
242 syslog(LOG_NOTICE, "Online ispindel %s mode %s", node, ispindel->mode); 241 syslog(LOG_NOTICE, "Online ispindel %s mode %s", node, ispindel->mode);
243 } 242 }
244 243
245 /* 244 /*
246 * Process the JSON formatted payload. 245 * Process the JSON formatted payload.
293 ispindel_mysql_insert(ispindel); 292 ispindel_mysql_insert(ispindel);
294 } else { 293 } else {
295 ispindel_mysql_update(ispindel); 294 ispindel_mysql_update(ispindel);
296 } 295 }
297 ispindel_ws_send(ispindel); 296 ispindel_ws_send(ispindel);
298 if (report)
299 status_change();
300 297
301 /* 298 /*
302 * The data is complete, see if we can write a log entry. 299 * The data is complete, see if we can write a log entry.
303 */ 300 */
304 if (ispindel->beercode && strlen(ispindel->beercode) && ispindel->beername && strlen(ispindel->beername) && 301 if (ispindel->beercode && strlen(ispindel->beercode) && ispindel->beername && strlen(ispindel->beername) &&

mercurial