From 758ea432ed75e2e211f38b3bd74eae90708af68f Mon Sep 17 00:00:00 2001 From: Hemna Date: Mon, 15 Apr 2024 10:00:35 -0400 Subject: [PATCH] removed Packet.last_send_attempt and just use send_count --- aprsd/packets/core.py | 1 - aprsd/packets/seen_list.py | 6 ++++++ aprsd/packets/tracker.py | 5 ++--- aprsd/threads/tx.py | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/aprsd/packets/core.py b/aprsd/packets/core.py index 756cbe0..3f8d449 100644 --- a/aprsd/packets/core.py +++ b/aprsd/packets/core.py @@ -102,7 +102,6 @@ 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) diff --git a/aprsd/packets/seen_list.py b/aprsd/packets/seen_list.py index 9b81831..88ab0fd 100644 --- a/aprsd/packets/seen_list.py +++ b/aprsd/packets/seen_list.py @@ -26,10 +26,16 @@ 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 diff --git a/aprsd/packets/tracker.py b/aprsd/packets/tracker.py index 1714557..74dc50c 100644 --- a/aprsd/packets/tracker.py +++ b/aprsd/packets/tracker.py @@ -65,10 +65,9 @@ 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, - "last_send_attempt": last_send_attempt, + "send_count": self.data[key].send_count, "retry_count": self.data[key].retry_count, "message": self.data[key].raw, } @@ -82,7 +81,7 @@ class PacketTrack(objectstore.ObjectStoreMixin): @wrapt.synchronized(lock) def add(self, packet): key = packet.msgNo - packet._last_send_attempt = 0 + packet.send_count = 0 self.data[key] = packet self.total_tracked += 1 diff --git a/aprsd/threads/tx.py b/aprsd/threads/tx.py index ae8c5ba..efd7c2c 100644 --- a/aprsd/threads/tx.py +++ b/aprsd/threads/tx.py @@ -79,6 +79,7 @@ def _send_direct(packet, aprs_client=None): packet_log.log(packet, tx=True) try: cl.send(packet) + packet.send_count += 1 except Exception as e: LOG.error(f"Failed to send packet: {packet}") LOG.error(e)