From 4f83f76bf571ed3fdaddb665e9cb3a26f26021a6 Mon Sep 17 00:00:00 2001 From: W1CDN Date: Thu, 13 Apr 2023 21:11:01 -0500 Subject: [PATCH] Switch to aprs3 package. --- tcp_kiss_send_recv.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tcp_kiss_send_recv.py diff --git a/tcp_kiss_send_recv.py b/tcp_kiss_send_recv.py new file mode 100644 index 0000000..4280f7a --- /dev/null +++ b/tcp_kiss_send_recv.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +import os +import sqlite3 +import aprs +import json + + +MYCALL = os.environ.get("MYCALL", "W1CDN") +KISS_HOST = os.environ.get("KISS_HOST", "192.168.0.30") +KISS_PORT = os.environ.get("KISS_PORT", "8001") + +def get_db_connection(): + conn = sqlite3.connect('database.db') + conn.row_factory = sqlite3.Row + return conn + +def main(): + ki = aprs.TCPKISS(host=KISS_HOST, port=int(KISS_PORT)) + ki.start() + frame = aprs.APRSFrame.ui( + destination="APZ001", + source=MYCALL, + path=["WIDE1-1"], + info=b">Hello World!", + ) + ki.write(frame) + while True: + for frame in ki.read(min_frames=1): + print(repr(frame)) + a = str(frame) + print(a) + conn = get_db_connection() + conn.execute('INSERT INTO frames (frame) VALUES (?)', + (a,)) + conn.commit() + conn.close() + +if __name__ == "__main__": + main()