mirror of
https://github.com/craigerl/aprsd.git
synced 2024-11-15 21:01:47 -05:00
Cleaned up KISS interfaces use of old config
This commit is contained in:
parent
a5520b2cd3
commit
0758a58101
@ -199,16 +199,17 @@ class KISSClient(Client):
|
|||||||
|
|
||||||
def decode_packet(self, *args, **kwargs):
|
def decode_packet(self, *args, **kwargs):
|
||||||
"""We get a frame, which has to be decoded."""
|
"""We get a frame, which has to be decoded."""
|
||||||
|
LOG.debug(f"kwargs {kwargs}")
|
||||||
frame = kwargs["frame"]
|
frame = kwargs["frame"]
|
||||||
LOG.debug(f"Got an APRS Frame '{frame}'")
|
LOG.debug(f"Got an APRS Frame '{frame}'")
|
||||||
# try and nuke the * from the fromcall sign.
|
# try and nuke the * from the fromcall sign.
|
||||||
frame.header._source._ch = False
|
# frame.header._source._ch = False
|
||||||
payload = str(frame.payload.decode())
|
# payload = str(frame.payload.decode())
|
||||||
msg = f"{str(frame.header)}:{payload}"
|
# msg = f"{str(frame.header)}:{payload}"
|
||||||
# msg = frame.tnc2
|
# 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)
|
return core.Packet.factory(raw)
|
||||||
|
|
||||||
@trace.trace
|
@trace.trace
|
||||||
|
@ -1,52 +1,47 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import aprslib
|
|
||||||
from ax253 import Frame
|
from ax253 import Frame
|
||||||
import kiss
|
import kiss
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
from aprsd import conf # noqa
|
||||||
from aprsd.packets import core
|
from aprsd.packets import core
|
||||||
from aprsd.utils import trace
|
from aprsd.utils import trace
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
LOG = logging.getLogger("APRSD")
|
LOG = logging.getLogger("APRSD")
|
||||||
|
|
||||||
|
|
||||||
class KISS3Client:
|
class KISS3Client:
|
||||||
def __init__(self, config):
|
def __init__(self):
|
||||||
self.config = config
|
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
# we can be TCP kiss or Serial kiss
|
# we can be TCP kiss or Serial kiss
|
||||||
if "serial" in self.config["kiss"] and self.config["kiss"]["serial"].get(
|
if CONF.kiss_serial.enabled:
|
||||||
"enabled",
|
|
||||||
False,
|
|
||||||
):
|
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"KISS({}) Serial connection to {}".format(
|
"KISS({}) Serial connection to {}".format(
|
||||||
kiss.__version__,
|
kiss.__version__,
|
||||||
self.config["kiss"]["serial"]["device"],
|
CONF.kiss_serial.device,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.kiss = kiss.SerialKISS(
|
self.kiss = kiss.SerialKISS(
|
||||||
port=self.config["kiss"]["serial"]["device"],
|
port=CONF.kiss_serial.device,
|
||||||
speed=self.config["kiss"]["serial"].get("baudrate", 9600),
|
speed=CONF.kiss_serial.baudrate,
|
||||||
strip_df_start=True,
|
strip_df_start=True,
|
||||||
)
|
)
|
||||||
elif "tcp" in self.config["kiss"] and self.config["kiss"]["tcp"].get(
|
elif CONF.kiss_tcp.enabled:
|
||||||
"enabled",
|
|
||||||
False,
|
|
||||||
):
|
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
"KISS({}) TCP Connection to {}:{}".format(
|
"KISS({}) TCP Connection to {}:{}".format(
|
||||||
kiss.__version__,
|
kiss.__version__,
|
||||||
self.config["kiss"]["tcp"]["host"],
|
CONF.kiss_tcp.host,
|
||||||
self.config["kiss"]["tcp"]["port"],
|
CONF.kiss_tcp.port,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.kiss = kiss.TCPKISS(
|
self.kiss = kiss.TCPKISS(
|
||||||
host=self.config["kiss"]["tcp"]["host"],
|
host=CONF.kiss_tcp.host,
|
||||||
port=int(self.config["kiss"]["tcp"]["port"]),
|
port=CONF.kiss_tcp.port,
|
||||||
strip_df_start=True,
|
strip_df_start=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -70,10 +65,8 @@ class KISS3Client:
|
|||||||
def parse_frame(self, frame_bytes):
|
def parse_frame(self, frame_bytes):
|
||||||
frame = Frame.from_bytes(frame_bytes)
|
frame = Frame.from_bytes(frame_bytes)
|
||||||
# Now parse it with aprslib
|
# Now parse it with aprslib
|
||||||
packet = aprslib.parse(str(frame))
|
|
||||||
kwargs = {
|
kwargs = {
|
||||||
"frame": str(frame),
|
"frame": frame,
|
||||||
"packet": packet,
|
|
||||||
}
|
}
|
||||||
self._parse_callback(**kwargs)
|
self._parse_callback(**kwargs)
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ aprs_opts = [
|
|||||||
"Get the passcode for your callsign here: "
|
"Get the passcode for your callsign here: "
|
||||||
"https://apps.magicbug.co.uk/passcode",
|
"https://apps.magicbug.co.uk/passcode",
|
||||||
),
|
),
|
||||||
cfg.HostnameOpt(
|
cfg.HostAddressOpt(
|
||||||
"host",
|
"host",
|
||||||
default="noam.aprs2.net",
|
default="noam.aprs2.net",
|
||||||
help="The APRS-IS hostname",
|
help="The APRS-IS hostname",
|
||||||
@ -73,7 +73,7 @@ kiss_tcp_opts = [
|
|||||||
default=False,
|
default=False,
|
||||||
help="Enable Serial KISS interface connection.",
|
help="Enable Serial KISS interface connection.",
|
||||||
),
|
),
|
||||||
cfg.HostnameOpt(
|
cfg.HostAddressOpt(
|
||||||
"host",
|
"host",
|
||||||
help="The KISS TCP Host to connect to.",
|
help="The KISS TCP Host to connect to.",
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user