aprslib prepare

This commit is contained in:
assada 2023-07-22 04:00:50 +03:00
parent 6fcbdad7c7
commit 9f6481b96a
Signed by: assada
GPG Key ID: 8905E8CE5CC3000D
2 changed files with 8 additions and 2 deletions

View File

@ -66,7 +66,7 @@ or `chmod a+x aprs.sh` and `./aprs.sh`
## Run IRC Gateway ## Run IRC Gateway
```shell ```shell
pip install kiss3 irc pip install kiss3 irc aprslib
KISS_HOST=localhost KISS_PORT=8001 IRC_HOST=irc.example.com IRC_PORT=6697 CHANNEL_NAME="#example" BOT_NICK=aprs python3 aprs.py KISS_HOST=localhost KISS_PORT=8001 IRC_HOST=irc.example.com IRC_PORT=6697 CHANNEL_NAME="#example" BOT_NICK=aprs python3 aprs.py
``` ```

View File

@ -7,6 +7,7 @@ import irc.client_aio
from ax253 import Frame from ax253 import Frame
import kiss import kiss
import aprslib
MYCALL = os.environ.get("MYCALL", "N0CALL") MYCALL = os.environ.get("MYCALL", "N0CALL")
KISS_HOST = os.environ.get("KISS_HOST", "10.10.10.91") KISS_HOST = os.environ.get("KISS_HOST", "10.10.10.91")
@ -18,7 +19,7 @@ channel = os.environ.get('CHANNEL_NAME', "#spau")
nickname = os.environ.get('BOT_NICK', "aprsbot") nickname = os.environ.get('BOT_NICK', "aprsbot")
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG) ## TODO: Make logging level configurable
async def main(): async def main():
logger.info(f"Connecting to {server}:{port} as {nickname}") logger.info(f"Connecting to {server}:{port} as {nickname}")
@ -38,6 +39,11 @@ async def main():
irc_client.privmsg(channel, '[APRS] Starting...') irc_client.privmsg(channel, '[APRS] Starting...')
async for frame in kiss_protocol.read(): async for frame in kiss_protocol.read():
try:
packet = aprslib.parse(str(frame))
except (aprslib.ParseError, aprslib.UnknownFormat) as exp:
pass
## TODO: Build APRS message from packet
logger.debug(f"Received frame: {frame}") logger.debug(f"Received frame: {frame}")
irc_client.privmsg(channel, str(frame)) ## TODO: Parse frame and send to channel irc_client.privmsg(channel, str(frame)) ## TODO: Parse frame and send to channel