diff -r b4bfed3684d0 -r e75ce5bbda73 bmsd/nodes.c --- a/bmsd/nodes.c Fri Jan 03 15:21:22 2020 +0100 +++ b/bmsd/nodes.c Sun Jan 05 11:42:02 2020 +0100 @@ -3,7 +3,7 @@ * @brief Handle nodes status * @author Michiel Broek * - * Copyright (C) 2018-2019 + * Copyright (C) 2018-2020 * * This file is part of the bms (Brewery Management System) * @@ -82,6 +82,7 @@ node->gps_latitude = node->gps_longitude = node->gps_altitude = 0.0; node->net_address = node->net_ifname = NULL; node->net_rssi = 0; + node->interval = 300; } /* @@ -111,6 +112,9 @@ free(node->uuid); node->uuid = xstrcpy((char *)json_object_get_string(val)); } + if (json_object_object_get_ex(metric, "interval", &val)) { + node->interval = json_object_get_int(val); + } if (json_object_object_get_ex(metric, "properties", &metric2)) { if (json_object_object_get_ex(metric2, "hardwaremake", &val)) { if (node->hardwaremake) @@ -214,6 +218,7 @@ printf("GPS %.5f %.5f %.5f\n", node->gps_latitude, node->gps_longitude, node->gps_altitude); printf("net %s:%s\n", node->net_ifname, node->net_address); printf("rssi %d\n", node->net_rssi); + printf("interval %d\n", node->interval); } } @@ -251,8 +256,8 @@ time_t now = time(NULL); for (tmpn = nodes; tmpn; tmpn = tmpn->next) { - if (debug) - printf("%-20s online %s %ld %d\n", tmpn->node, tmpn->online ? "yes":"no ", tmpn->lastseen, tmpn->interval); +// if (debug) +// printf("%-20s online %s %ld %d\n", tmpn->node, tmpn->online ? "yes":"no ", tmpn->lastseen, tmpn->interval); if (tmpn->online && ((now - tmpn->lastseen) > (tmpn->interval * 2 + 5))) { // 2 times interval + 5 seconds syslog(LOG_NOTICE, "Timeout node `%s/%s' after %ld seconds", tmpn->group_id, tmpn->node, (now - tmpn->lastseen)); tmpn->online = false;