summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Sharma <harsh.sharma@multitech.com>2019-09-11 13:02:09 -0500
committerHarsh Sharma <harsh.sharma@multitech.com>2019-09-11 13:02:09 -0500
commita32deb8ba7ce6987a7964958c079f3dc078fa0c8 (patch)
treeae6347dd2d0b58bcdbf5398e31d3995a1c2bd780
parentd7d8d37ed4ece5fa35951a36e4089b5b630d7fb6 (diff)
downloadpacket_forwarder_mtac_full-a32deb8ba7ce6987a7964958c079f3dc078fa0c8.tar.gz
packet_forwarder_mtac_full-a32deb8ba7ce6987a7964958c079f3dc078fa0c8.tar.bz2
packet_forwarder_mtac_full-a32deb8ba7ce6987a7964958c079f3dc078fa0c8.zip
Changed lgw receive to try until reset counter before exiting
-rw-r--r--lora_pkt_fwd/src/lora_pkt_fwd.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c
index 3b92b27..f26a51a 100644
--- a/lora_pkt_fwd/src/lora_pkt_fwd.c
+++ b/lora_pkt_fwd/src/lora_pkt_fwd.c
@@ -141,6 +141,7 @@ Maintainer: Michael Coracin
#define HISTOGRAM_CLEAN_TIMEOUT 10000
#define HISTOGRAM_READY_TIMEOUT 1000
+#define LGW_RECEIVE_TIMEOUT 100
/* -------------------------------------------------------------------------- */
/* --- PRIVATE VARIABLES (GLOBAL) ------------------------------------------- */
@@ -1648,6 +1649,7 @@ void thread_up(void) {
struct lgw_pkt_rx_s rxpkt[NB_PKT_MAX]; /* array containing inbound packets + metadata */
struct lgw_pkt_rx_s *p; /* pointer on a RX packet */
int nb_pkt;
+ uint8_t lgw_receive_counter = 0;
/* local copy of GPS time reference */
bool ref_ok = false; /* determine if GPS time reference must be used or not */
@@ -1694,13 +1696,18 @@ void thread_up(void) {
while (!exit_sig && !quit_sig) {
+ if(lgw_receive_counter > LGW_RECEIVE_TIMEOUT) {
+ MSG("ERROR: [up] lgw_receive_counter limit reached, exiting\n");
+ exit(EXIT_FAILURE);
+ }
/* fetch packets */
pthread_mutex_lock(&mx_concent);
nb_pkt = lgw_receive(NB_PKT_MAX, rxpkt);
pthread_mutex_unlock(&mx_concent);
if (nb_pkt == LGW_HAL_ERROR) {
- MSG("ERROR: [up] failed packet fetch, exiting\n");
- exit(EXIT_FAILURE);
+ MSG("ERROR: [up] failed packet fetch, retrying\n");
+ lgw_receive_counter++;
+ wait_ms(1000);
}
/* check if there are status report to send */