40 lines
959 B
Python
40 lines
959 B
Python
|
#!/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()
|