From 40c028c84411680df80a4d8782342e02aa865ff5 Mon Sep 17 00:00:00 2001 From: Hemna Date: Fri, 12 Apr 2024 14:36:27 -0400 Subject: [PATCH] Added new default_ack_send_count config option There may be applications where the admin might not want a hard coded 3 acks sent for every RX'd packet. This patch adds the ability to change the number of acks sent per RX'd packet. The default is still 3. --- aprsd/conf/common.py | 5 +++++ aprsd/threads/tx.py | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/aprsd/conf/common.py b/aprsd/conf/common.py index 2a119b5..24a4022 100644 --- a/aprsd/conf/common.py +++ b/aprsd/conf/common.py @@ -105,6 +105,11 @@ aprsd_opts = [ "'multiline' will use multiple lines for each packet and is the traditional format." "both will log both compact and multiline.", ), + cfg.IntOpt( + "default_ack_send_count", + default=3, + help="The number of times to send an ack packet in response to recieving a packet.", + ), ] watch_list_opts = [ diff --git a/aprsd/threads/tx.py b/aprsd/threads/tx.py index 63d2b5d..ae8c5ba 100644 --- a/aprsd/threads/tx.py +++ b/aprsd/threads/tx.py @@ -157,22 +157,24 @@ class SendPacketThread(aprsd_threads.APRSDThread): class SendAckThread(aprsd_threads.APRSDThread): loop_count: int = 1 + max_retries = 3 def __init__(self, packet): self.packet = packet super().__init__(f"SendAck-{self.packet.msgNo}") + self.max_retries = CONF.default_ack_send_count def loop(self): """Separate thread to send acks with retries.""" send_now = False - if self.packet.send_count == self.packet.retry_count: + if self.packet.send_count == self.max_retries: # we reached the send limit, don't send again # TODO(hemna) - Need to put this in a delayed queue? LOG.debug( f"{self.packet.__class__.__name__}" f"({self.packet.msgNo}) " "Send Complete. Max attempts reached" - f" {self.packet.retry_count}", + f" {self.max_retries}", ) return False