bmsd/co2meters.c

changeset 558
a8e065a9f851
parent 547
4d9c96545246
child 673
9924b1218d39
equal deleted inserted replaced
557:ee76d0bfcdaf 558:a8e065a9f851
233 log->node = xstrcpy(edge_node); 233 log->node = xstrcpy(edge_node);
234 log->alias = xstrcpy(alias); 234 log->alias = xstrcpy(alias);
235 jobj = json_tokener_parse(payload); 235 jobj = json_tokener_parse(payload);
236 236
237 timestamp = time(NULL); 237 timestamp = time(NULL);
238 log->datetime = malloc(21); 238 log->datetime = malloc(73);
239 mytime = localtime(&timestamp); 239 mytime = localtime(&timestamp);
240 snprintf(log->datetime, 20, "%04d-%02d-%02d %02d:%02d:%02d", 240 snprintf(log->datetime, 72, "%04d-%02d-%02d %02d:%02d:%02d",
241 mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec); 241 mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec);
242 242
243 if (json_object_object_get_ex(jobj, "metric", &metric)) { 243 if (json_object_object_get_ex(jobj, "metric", &metric)) {
244 if (json_object_object_get_ex(metric, "uuid", &val)) { 244 if (json_object_object_get_ex(metric, "uuid", &val)) {
245 if (strcmp((char *)"(null)", json_object_get_string(val))) 245 if (strcmp((char *)"(null)", json_object_get_string(val)))

mercurial