diff --git a/aprsd/log.py b/aprsd/log.py index 8029579..339737f 100644 --- a/aprsd/log.py +++ b/aprsd/log.py @@ -25,7 +25,7 @@ def setup_logging(config, loglevel, quiet): log_format = "%(message)s" log_formatter = logging.Formatter(fmt=log_format, datefmt=date_format) rh = aprsd_logging.APRSDRichHandler( - show_thread=True, thread_width=15, + show_thread=True, thread_width=20, rich_tracebacks=True, omit_repeated_times=False, ) rh.setFormatter(log_formatter) diff --git a/aprsd/messaging.py b/aprsd/messaging.py index 7898353..04f6009 100644 --- a/aprsd/messaging.py +++ b/aprsd/messaging.py @@ -190,6 +190,7 @@ class Message(metaclass=abc.ABCMeta): fromcall, tocall, msg_id=None, + allow_delay=True, ): self.fromcall = fromcall self.tocall = tocall @@ -199,6 +200,10 @@ class Message(metaclass=abc.ABCMeta): msg_id = c.value self.id = msg_id + # do we try and save this message for later if we don't get + # an ack? Some messages we don't want to do this ever. + self.allow_delay = allow_delay + @abc.abstractmethod def send(self): """Child class must declare.""" @@ -214,8 +219,8 @@ class RawMessage(Message): message = None - def __init__(self, message): - super().__init__(None, None, msg_id=None) + def __init__(self, message, allow_delay=True): + super().__init__(fromcall=None, tocall=None, msg_id=None, allow_delay=allow_delay) self.message = message def dict(self): @@ -269,11 +274,11 @@ class TextMessage(Message): msg_id=None, allow_delay=True, ): - super().__init__(fromcall, tocall, msg_id) + super().__init__( + fromcall=fromcall, tocall=tocall, + msg_id=msg_id, allow_delay=allow_delay, + ) self.message = message - # do we try and save this message for later if we don't get - # an ack? Some messages we don't want to do this ever. - self.allow_delay = allow_delay def dict(self): now = datetime.datetime.now() @@ -369,6 +374,8 @@ class SendMessageThread(threads.APRSDThread): # we reached the send limit, don't send again # TODO(hemna) - Need to put this in a delayed queue? LOG.info("Message Send Complete. Max attempts reached.") + if not msg.allow_delay: + tracker.remove(msg.id) return False # Message is still outstanding and needs to be acked. diff --git a/aprsd/packets.py b/aprsd/packets.py index edfc86a..b7e6ecc 100644 --- a/aprsd/packets.py +++ b/aprsd/packets.py @@ -86,7 +86,7 @@ class WatchList(objectstore.ObjectStoreMixin): if config: self.config = config - ring_size = config["aprsd"]["watch_list"]["packet_keep_count"] + ring_size = config["aprsd"]["watch_list"].get("packet_keep_count", 10) for callsign in config["aprsd"]["watch_list"].get("callsigns", []): call = callsign.replace("*", "") diff --git a/aprsd/plugin.py b/aprsd/plugin.py index 53acec1..8544d8e 100644 --- a/aprsd/plugin.py +++ b/aprsd/plugin.py @@ -177,7 +177,6 @@ class APRSDWatchListPluginBase(APRSDPluginBase, metaclass=abc.ABCMeta): ) if result: self.tx_inc() - wl.update_seen(packet) else: LOG.warning(f"{self.__class__} plugin is not enabled") diff --git a/aprsd/plugins/notify.py b/aprsd/plugins/notify.py index bb01084..09e4a20 100644 --- a/aprsd/plugins/notify.py +++ b/aprsd/plugins/notify.py @@ -1,6 +1,6 @@ import logging -from aprsd import messaging, packets, plugin +from aprsd import messaging, packets, plugin, trace LOG = logging.getLogger("APRSD") @@ -17,6 +17,7 @@ class NotifySeenPlugin(plugin.APRSDWatchListPluginBase): short_description = "Notify me when a CALLSIGN is recently seen on APRS-IS" + @trace.trace def process(self, packet): LOG.info("NotifySeenPlugin") @@ -46,10 +47,11 @@ class NotifySeenPlugin(plugin.APRSDWatchListPluginBase): ) return msg else: + LOG.debug("fromcall and notify_callsign are the same, not notifying") return messaging.NULL_MESSAGE else: LOG.debug( - "Not old enough to notify callsign '{}' : {} < {}".format( + "Not old enough to notify on callsign '{}' : {} < {}".format( fromcall, age, wl.max_delta(), diff --git a/aprsd/threads.py b/aprsd/threads.py index e8422f3..1bf8aa4 100644 --- a/aprsd/threads.py +++ b/aprsd/threads.py @@ -202,7 +202,7 @@ class APRSDProcessPacketThread(APRSDThread): self.packet = packet self.config = config name = self.packet["raw"][:10] - super().__init__(f"RX_PACKET-{name}") + super().__init__(f"RXPKT-{name}") def process_ack_packet(self, packet): ack_num = packet.get("msgNo") @@ -261,6 +261,8 @@ class APRSDProcessPacketThread(APRSDThread): pm = plugin.PluginManager() try: results = pm.run(packet) + wl = packets.WatchList() + wl.update_seen(packet) replied = False for reply in results: if isinstance(reply, list):