From 0758a581013fe0c3f0b69bb3d8d3087969e20673 Mon Sep 17 00:00:00 2001 From: Hemna Date: Mon, 2 Jan 2023 14:20:13 -0500 Subject: [PATCH] Cleaned up KISS interfaces use of old config --- aprsd/client.py | 11 ++++++----- aprsd/clients/kiss.py | 35 ++++++++++++++--------------------- aprsd/conf/client.py | 4 ++-- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/aprsd/client.py b/aprsd/client.py index bd5ce54..b8bbf82 100644 --- a/aprsd/client.py +++ b/aprsd/client.py @@ -199,16 +199,17 @@ class KISSClient(Client): def decode_packet(self, *args, **kwargs): """We get a frame, which has to be decoded.""" + LOG.debug(f"kwargs {kwargs}") frame = kwargs["frame"] LOG.debug(f"Got an APRS Frame '{frame}'") # try and nuke the * from the fromcall sign. - frame.header._source._ch = False - payload = str(frame.payload.decode()) - msg = f"{str(frame.header)}:{payload}" + # frame.header._source._ch = False + # payload = str(frame.payload.decode()) + # msg = f"{str(frame.header)}:{payload}" # msg = frame.tnc2 - LOG.debug(f"Decoding {msg}") + # LOG.debug(f"Decoding {msg}") - raw = aprslib.parse(msg) + raw = aprslib.parse(str(frame)) return core.Packet.factory(raw) @trace.trace diff --git a/aprsd/clients/kiss.py b/aprsd/clients/kiss.py index 48e4f92..825e118 100644 --- a/aprsd/clients/kiss.py +++ b/aprsd/clients/kiss.py @@ -1,52 +1,47 @@ import logging -import aprslib from ax253 import Frame import kiss +from oslo_config import cfg +from aprsd import conf # noqa from aprsd.packets import core from aprsd.utils import trace +CONF = cfg.CONF LOG = logging.getLogger("APRSD") class KISS3Client: - def __init__(self, config): - self.config = config + def __init__(self): self.setup() def setup(self): # we can be TCP kiss or Serial kiss - if "serial" in self.config["kiss"] and self.config["kiss"]["serial"].get( - "enabled", - False, - ): + if CONF.kiss_serial.enabled: LOG.debug( "KISS({}) Serial connection to {}".format( kiss.__version__, - self.config["kiss"]["serial"]["device"], + CONF.kiss_serial.device, ), ) self.kiss = kiss.SerialKISS( - port=self.config["kiss"]["serial"]["device"], - speed=self.config["kiss"]["serial"].get("baudrate", 9600), + port=CONF.kiss_serial.device, + speed=CONF.kiss_serial.baudrate, strip_df_start=True, ) - elif "tcp" in self.config["kiss"] and self.config["kiss"]["tcp"].get( - "enabled", - False, - ): + elif CONF.kiss_tcp.enabled: LOG.debug( "KISS({}) TCP Connection to {}:{}".format( kiss.__version__, - self.config["kiss"]["tcp"]["host"], - self.config["kiss"]["tcp"]["port"], + CONF.kiss_tcp.host, + CONF.kiss_tcp.port, ), ) self.kiss = kiss.TCPKISS( - host=self.config["kiss"]["tcp"]["host"], - port=int(self.config["kiss"]["tcp"]["port"]), + host=CONF.kiss_tcp.host, + port=CONF.kiss_tcp.port, strip_df_start=True, ) @@ -70,10 +65,8 @@ class KISS3Client: def parse_frame(self, frame_bytes): frame = Frame.from_bytes(frame_bytes) # Now parse it with aprslib - packet = aprslib.parse(str(frame)) kwargs = { - "frame": str(frame), - "packet": packet, + "frame": frame, } self._parse_callback(**kwargs) diff --git a/aprsd/conf/client.py b/aprsd/conf/client.py index e7e85de..c0754df 100644 --- a/aprsd/conf/client.py +++ b/aprsd/conf/client.py @@ -38,7 +38,7 @@ aprs_opts = [ "Get the passcode for your callsign here: " "https://apps.magicbug.co.uk/passcode", ), - cfg.HostnameOpt( + cfg.HostAddressOpt( "host", default="noam.aprs2.net", help="The APRS-IS hostname", @@ -73,7 +73,7 @@ kiss_tcp_opts = [ default=False, help="Enable Serial KISS interface connection.", ), - cfg.HostnameOpt( + cfg.HostAddressOpt( "host", help="The KISS TCP Host to connect to.", ),