2023-04-13 21:11:01 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
import sqlite3
|
|
|
|
import aprs
|
|
|
|
import json
|
2023-04-13 21:38:51 -05:00
|
|
|
import aprslib
|
2023-04-13 21:11:01 -05:00
|
|
|
|
|
|
|
|
|
|
|
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):
|
2023-04-13 21:38:51 -05:00
|
|
|
#print(repr(frame))
|
|
|
|
a = aprslib.parse(str(frame))
|
2023-04-13 21:11:01 -05:00
|
|
|
print(a)
|
|
|
|
conn = get_db_connection()
|
2023-04-13 21:38:51 -05:00
|
|
|
# conn.execute('INSERT INTO frames (frame) VALUES (?)',
|
|
|
|
# (a,))
|
2023-04-13 21:11:01 -05:00
|
|
|
conn.commit()
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|