diff --git a/config.ini b/config.ini index b4f65fe..647b245 100644 --- a/config.ini +++ b/config.ini @@ -10,3 +10,10 @@ station_lon = -97.027000 # How long to keep packets (frames) e.g., "2 days", "5 minutes" keep_time = "2 days" + +# KISS settings +kiss_host = 192.168.0.30 +kiss_port = 8001 + +# Development settings (not operational yet) +mycall = W1CDN-15 diff --git a/kiss_and_db.py b/kiss_and_db.py index b84d421..a8c7072 100644 --- a/kiss_and_db.py +++ b/kiss_and_db.py @@ -6,10 +6,6 @@ import json import aprslib import configparser -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") - db_fields = ("id", "addresse", "alive", @@ -44,6 +40,7 @@ db_fields = ("id", "station_lat", "station_lon", "status", +"subpacket", "symbol", "symbol_table", "telemetry", @@ -70,18 +67,22 @@ def main(): # Add the call and location of this station to the packet info config = read_config() + # 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") - ki = aprs.TCPKISS(host=KISS_HOST, port=int(KISS_PORT)) + + ki = aprs.TCPKISS(host=config['Settings']['kiss_host'], port=int(config['Settings']['kiss_port'])) ki.start() # Make a simple frame and send it frame = aprs.APRSFrame.ui( destination="APZ001", - source=MYCALL, + source=config['Settings']['mycall'], path=["WIDE1-1"], info=b">Hello World!", ) - #ki.write(frame) + ki.write(frame) # Watch for new packets to come in while True: @@ -94,11 +95,15 @@ def main(): print(a) # Make this a string and deal with it later (probably a mistake) a['path'] = str(a['path']) + # Store true/false as 1/0 + if 'alive' in a: + if a['alive'] == True: + a['alive'] = 1 + else: + a['alive'] = 0 # Build an INSERT statement based on the fields we have from the frame - #attrib_names = ', '.join(f'"{w}"' for w in a.keys()) attrib_names = ', '.join('"%s"' % w for w in a.keys()) attrib_values = ", ".join("?" * len(a.keys())) - #sql = f"INSERT INTO frames ({attrib_names}) VALUES ({attrib_values})" sql = "INSERT INTO frames ("+attrib_names+") VALUES ("+attrib_values+")" try: # Insert data diff --git a/schema.sql b/schema.sql index 6027d4c..91e5b43 100644 --- a/schema.sql +++ b/schema.sql @@ -35,6 +35,7 @@ CREATE TABLE frames ( station_lat REAL, station_lon REAL, status TEXT, + subpacket TEXT, symbol TEXT, symbol_table TEXT, telemetry TEXT,