craigerl / aprsd

Amateur radio APRS daemon which listens for messages and responds. By KM6LYW.
Apache License 2.0
124 stars 19 forks source link

Added the ability to use direwolf KISS socket #50

Closed hemna closed 2 years ago

hemna commented 3 years ago

This patch adds APRS KISS connectivity. I have tested this with a running Direwolf install via either a serial KISS connection or the optional new TCPKISS connection, both to Direwolf.

This adds the new required aioax25 python library for the underlying
KISS and AX25 support.

NOTE: For the TCPKISS connection, this patch requires a pull request
patch the aioax25 library to include a TCP Based KISS TNC client to
enable the TCPKISS client  So you will need to pull down this PR
https://github.com/sjlongland/aioax25/pull/7

To enable this,
  Edit your aprsd.yml file and enable one of the 2 KISS connections.
  Only one is supported at a time.

  kiss:
     serial:
         enabled: True
         device: /dev/ttyS1
         baudrate: 9600

  or

  kiss:
      tcp:
          enabled: True
          host: "ip address/hostname of direwolf"
          port: "direwolf configured kiss port"

This patch alters the Message object classes to be able to send messages out via the aprslib socket connection to the APRS-IS network on the internet, or via the direwolf KISS TCP socket, depending on the origination of the initial message coming in.

If an APRS message comes in via APRS-IS, then replies will go out APRS-IS. IF an APRS message comes in via direwolf, then replies will go out via direwolf KISS TCP socket. Both can work at the same time.

TODO: I need some real APRS message packets to verify that the new thread is processing packets correctly through the plugins and able to send the resulting messages back out to direwolf.

Have a hard coded callsign for now in the kissclient consumer call, just so I can see messages coming in from direwolf. I dont' have an APRS capable radio at the moment to send messages directly to direwolf. Might need to write a simple python socket server to send fake APRS messages to aprsd kiss, just for finishing up development.

sjlongland commented 3 years ago

For what it's worth, direwolf also supports a Pseudo TTY interface (at least on Unix-like platforms). In my code I have a stanza like the following in my configuration file (YAML):

kiss:
        device: /tmp/kisstnc
        baudrate: 9600
        port: 1

and I start direwolf inside supervisord with this:

[program:direwolf]
command=/usr/bin/direwolf -c /etc/direwolf.conf -p -t 0
user=root
redirect_stderr=true
stdout_logfile=/var/log/direwolf.log
stdout_logfile_maxbytes=104857600
stdout_logfile_backups=5
autostart=true
autorestart=true

The -p opens that pseudo TTY, which aioax25 can connect to. (port: 1 selects the second port, which with the NWDR UDRC-II is the Mini-DIN port. On the NWDR DRAWS, I think it's the "right" hand port with left being port 0.) I'm not sure if this works on Microsoft Windows though, and as much as it's a legacy OS to me, others like to use it and there's no reason the proposed TCP KISS interface wouldn't work for that OS.

To that end, I'm open to ideas as to a configuration file stanza that might be read from a configuration file (such as JSON, YAML, INI-style, whatever) that would "instantiate" a KISS or AX.25 socket.

It'd be convenient if a developer can call makeport(**myconfig), and have it return them a configured port, then all applications, aprsd included, could benefit if someone writes other port interfaces (e.g. maybe kissattach as a child process).