From 3d38402be241171e92ba8e3b1bf50ee2df5a301e Mon Sep 17 00:00:00 2001 From: Hemna Date: Fri, 16 Jul 2021 12:15:04 -0400 Subject: [PATCH] Fixed small bug with packets get_packet_type This fixes an issue with trying to decode the packet type. Also updated some of the log entries. --- aprsd/packets.py | 1 + aprsd/threads.py | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/aprsd/packets.py b/aprsd/packets.py index 2565236..4320a46 100644 --- a/aprsd/packets.py +++ b/aprsd/packets.py @@ -39,6 +39,7 @@ def get_packet_type(packet): msg_format = packet.get("format", None) msg_response = packet.get("response", None) + packet_type = "unknown" if msg_format == "message": packet_type = PACKET_TYPE_MESSAGE elif msg_response == "ack": diff --git a/aprsd/threads.py b/aprsd/threads.py index 16b6976..36e9b1f 100644 --- a/aprsd/threads.py +++ b/aprsd/threads.py @@ -192,11 +192,15 @@ class APRSDNotifyThread(APRSDThread): LOG.debug("Update last seen from {}".format(packet["from"])) self.last_seen[packet["from"]] = now + self.update_stats() else: - LOG.debug("Ignoring packet from {}".format(packet["from"])) + LOG.debug( + "Ignoring packet from '{}'. Not in watch list.".format( + packet["from"], + ), + ) # Allows stats object to have latest info from the last_seen dict - self.update_stats() LOG.debug("Packet processing complete") except queue.Empty: pass @@ -342,7 +346,6 @@ class APRSDRXThread(APRSDThread): msg_id=msg_id, ) self.msg_queues["tx"].put(ack) - LOG.debug("Packet processing complete") def process_packet(self, packet): """Process a packet recieved from aprs-is server.""" @@ -376,14 +379,16 @@ class APRSDRXThread(APRSDThread): return else: LOG.debug( - "Packet wasn't meant for us '{}'. Ignoring packet to '{}'".format( - self.config["aprs"]["login"], + "Ignoring '{}' packet from '{}' to '{}'".format( + packets.get_packet_type(packet), + packet["from"], tocall, ), ) except (aprslib.ParseError, aprslib.UnknownFormat) as exp: LOG.exception("Failed to parse packet from aprs-is", exp) + LOG.debug("Packet processing complete") class APRSDTXThread(APRSDThread):