1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-02-03 09:44:15 -05:00

Compare commits

..

No commits in common. "3e8716365ecd2553e6ad3d1d057947a032fdb0bc" and "7c935345e50678265be4345984a8749cf12259b1" have entirely different histories.

5 changed files with 8 additions and 13 deletions

View File

@ -102,6 +102,7 @@ class Packet:
send_count: int = field(repr=False, default=0, compare=False, hash=False)
retry_count: int = field(repr=False, default=3, compare=False, hash=False)
last_send_time: float = field(repr=False, default=0, compare=False, hash=False)
last_send_attempt: int = field(repr=False, default=0, compare=False, hash=False)
# Do we allow this packet to be saved to send later?
allow_delay: bool = field(repr=False, default=True, compare=False, hash=False)

View File

@ -18,13 +18,12 @@ class PacketList(objectstore.ObjectStoreMixin):
lock = threading.Lock()
_total_rx: int = 0
_total_tx: int = 0
_maxlen: int = 100
def __new__(cls, *args, **kwargs):
if cls._instance is None:
cls._instance = super().__new__(cls)
cls._instance._maxlen = CONF.packet_list_maxlen
cls._instance.data = {
cls._maxlen = CONF.packet_list_maxlen
cls.data = {
"types": {},
"packets": OrderedDict(),
}
@ -59,7 +58,7 @@ class PacketList(objectstore.ObjectStoreMixin):
def _add(self, packet):
if packet.key in self.data["packets"]:
self.data["packets"].move_to_end(packet.key)
elif len(self.data["packets"]) == self._maxlen:
elif len(self.data["packets"]) == self.maxlen:
self.data["packets"].popitem(last=False)
self.data["packets"][packet.key] = packet

View File

@ -26,16 +26,10 @@ class SeenList(objectstore.ObjectStoreMixin):
cls._instance.data = {}
return cls._instance
@wrapt.synchronized(lock)
def stats(self, serializable=False):
"""Return the stats for the PacketTrack class."""
return self.data
@wrapt.synchronized(lock)
def copy(self):
"""Return a copy of the data."""
return self.data.copy()
@wrapt.synchronized(lock)
def update_seen(self, packet):
callsign = None

View File

@ -65,9 +65,10 @@ class PacketTrack(objectstore.ObjectStoreMixin):
pkts = {}
for key in self.data:
last_send_time = self.data[key].last_send_time
last_send_attempt = self.data[key]._last_send_attempt
pkts[key] = {
"last_send_time": last_send_time,
"send_count": self.data[key].send_count,
"last_send_attempt": last_send_attempt,
"retry_count": self.data[key].retry_count,
"message": self.data[key].raw,
}
@ -81,7 +82,7 @@ class PacketTrack(objectstore.ObjectStoreMixin):
@wrapt.synchronized(lock)
def add(self, packet):
key = packet.msgNo
packet.send_count = 0
packet._last_send_attempt = 0
self.data[key] = packet
self.total_tracked += 1

View File

@ -118,7 +118,7 @@ class SendPacketThread(aprsd_threads.APRSDThread):
return False
else:
send_now = False
if packet.send_count >= packet.retry_count:
if packet.send_count == packet.retry_count:
# we reached the send limit, don't send again
# TODO(hemna) - Need to put this in a delayed queue?
LOG.info(