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; |
205 bool new_ispindel = true, report = false; |
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; |
241 syslog(LOG_NOTICE, "Online ispindel %s mode %s", node, ispindel->mode); |
242 syslog(LOG_NOTICE, "Online ispindel %s mode %s", node, ispindel->mode); |
242 } |
243 } |
243 |
244 |
244 /* |
245 /* |
245 * Process the JSON formatted payload. |
246 * Process the JSON formatted payload. |
292 ispindel_mysql_insert(ispindel); |
293 ispindel_mysql_insert(ispindel); |
293 } else { |
294 } else { |
294 ispindel_mysql_update(ispindel); |
295 ispindel_mysql_update(ispindel); |
295 } |
296 } |
296 ispindel_ws_send(ispindel); |
297 ispindel_ws_send(ispindel); |
|
298 if (report) |
|
299 status_change(); |
297 |
300 |
298 /* |
301 /* |
299 * The data is complete, see if we can write a log entry. |
302 * The data is complete, see if we can write a log entry. |
300 */ |
303 */ |
301 if (ispindel->beercode && strlen(ispindel->beercode) && ispindel->beername && strlen(ispindel->beername) && |
304 if (ispindel->beercode && strlen(ispindel->beercode) && ispindel->beername && strlen(ispindel->beername) && |