From 02f1d26596cb6c194f4e717470c3ea60c1b431fd Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Tue, 7 Dec 2021 11:40:06 -0600 Subject: Add restart interval config --- lora_pkt_fwd/src/lora_pkt_fwd.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lora_pkt_fwd/src/lora_pkt_fwd.c') diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index d59b59e..da65907 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -177,6 +177,7 @@ static uint32_t duty_cycle_period = 3600; // seconds in one hour static double duty_cycle_ratio = 0.10; // 10% static uint32_t duty_cycle_time_max = 3600 * 0.10 * 1000u; // max time-on-air in window +static uint32_t restart_interval_minutes = 10 * 60; static int max_tx_power = -99; // limit tx power sent from a network server /* statistics collection configuration variables */ @@ -704,6 +705,7 @@ static int parse_SX1301_configuration(const char * conf_file) { MSG("WARNING: Data type for clksrc seems wrong, please check\n"); boardconf.clksrc = 0; } + MSG("INFO: lorawan_public %d, clksrc %d\n", boardconf.lorawan_public, boardconf.clksrc); /* all parameters parsed, submitting configuration to the HAL */ if (lgw_board_setconf(boardconf) != LGW_HAL_SUCCESS) { @@ -1194,6 +1196,13 @@ static int parse_gateway_configuration(const char * conf_file) { MSG("INFO: statistics display interval is configured to %u seconds\n", stat_interval); } + /* get interval (in minutes) for periodic restart (optional) */ + val = json_object_get_value(conf_obj, "restart_interval"); + if (val != NULL) { + restart_interval_minutes = (unsigned)json_value_get_number(val); + } + MSG("INFO: restart interval is configured to %u minutes\n", restart_interval_minutes); + /* get time-out value (in ms) for upstream datagrams (optional) */ val = json_object_get_value(conf_obj, "push_timeout_ms"); if (val != NULL) { @@ -1201,7 +1210,6 @@ static int parse_gateway_configuration(const char * conf_file) { MSG("INFO: upstream PUSH_DATA time-out is configured to %u ms\n", (unsigned)(push_timeout_half.tv_usec / 500)); } - /* duty-cycle limiting */ val = json_object_get_value(conf_obj, "duty_cycle_enabled"); if (json_value_get_type(val) == JSONBoolean) { @@ -2013,7 +2021,7 @@ int main(int argc, char** argv) clock_gettime(CLOCK_MONOTONIC, &check_time); - if ((int)(difftimespec(check_time, start_time)) > (10 * 60 * 60)) { // allow forwarder to run a maximum of 10 hours before forcing a restart + if (restart_interval_minutes > 0 && (int)(difftimespec(check_time, start_time)) > (restart_interval_minutes * 60)) { // forcing a periodic restart MSG("INFO: periodic restart, process is exiting.\n"); exit(1); } -- cgit v1.2.3