This commit is contained in:
assada 2023-07-22 03:53:20 +03:00
parent b748b0b657
commit 6fcbdad7c7
Signed by: assada
GPG Key ID: 8905E8CE5CC3000D

14
aprs.py
View File

@ -8,8 +8,6 @@ import irc.client_aio
from ax253 import Frame from ax253 import Frame
import kiss import kiss
from functools import partial
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")
KISS_PORT = os.environ.get("KISS_PORT", "8001") KISS_PORT = os.environ.get("KISS_PORT", "8001")
@ -23,11 +21,13 @@ logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
async def main(): async def main():
logger.info(f"Connecting to {server}:{port} as {nickname}")
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()
c = await irc.client_aio.AioReactor(loop=loop).server().connect( irc_client = await irc.client_aio.AioReactor(loop=loop).server().connect(
server, port, nickname, connect_factory=irc.connection.AioFactory(ssl=True) server, port, nickname, connect_factory=irc.connection.AioFactory(ssl=True) ## TODO: Make SSL optional and add password support
) )
logger.info(f"Connected to {server}:{port} as {nickname}")
transport, kiss_protocol = await kiss.create_tcp_connection( transport, kiss_protocol = await kiss.create_tcp_connection(
host=KISS_HOST, host=KISS_HOST,
@ -35,11 +35,11 @@ async def main():
loop=loop, loop=loop,
) )
c.privmsg(channel, '[APRS] Starting...') irc_client.privmsg(channel, '[APRS] Starting...')
async for frame in kiss_protocol.read(): async for frame in kiss_protocol.read():
print('Got frame') logger.debug(f"Received frame: {frame}")
c.privmsg(channel, str(frame)) irc_client.privmsg(channel, str(frame)) ## TODO: Parse frame and send to channel
if __name__ == "__main__": if __name__ == "__main__":