Compare commits
No commits in common. "50085de7dba57de380a8798ae091943729aa7c8d" and "307c1fcd860b9011b606b825c4d27c3bce50dca6" have entirely different histories.
50085de7db
...
307c1fcd86
@ -3,7 +3,6 @@ db_frames_fields = ("id",
|
|||||||
"addresse",
|
"addresse",
|
||||||
"alive",
|
"alive",
|
||||||
"altitude",
|
"altitude",
|
||||||
"body",
|
|
||||||
"comment",
|
"comment",
|
||||||
"course",
|
"course",
|
||||||
"created",
|
"created",
|
||||||
@ -12,7 +11,6 @@ db_frames_fields = ("id",
|
|||||||
"frame",
|
"frame",
|
||||||
"from",
|
"from",
|
||||||
"gpsfixstatus",
|
"gpsfixstatus",
|
||||||
"id",
|
|
||||||
"latitude",
|
"latitude",
|
||||||
"longitude",
|
"longitude",
|
||||||
"mbits",
|
"mbits",
|
||||||
@ -46,7 +44,6 @@ db_frames_fields = ("id",
|
|||||||
"tEQNS",
|
"tEQNS",
|
||||||
"tPARM",
|
"tPARM",
|
||||||
"tUNIT",
|
"tUNIT",
|
||||||
"type",
|
|
||||||
"via",
|
"via",
|
||||||
"weather",
|
"weather",
|
||||||
"wx_raw_timestamp")
|
"wx_raw_timestamp")
|
||||||
|
@ -24,10 +24,18 @@ def refresh_kiss_connection(kiss_conn):
|
|||||||
logging.debug("Restarting KISS connection on schedule")
|
logging.debug("Restarting KISS connection on schedule")
|
||||||
logging.debug("Stopping current connection")
|
logging.debug("Stopping current connection")
|
||||||
kiss_conn.stop()
|
kiss_conn.stop()
|
||||||
#logging.debug("Waiting 5 seconds")
|
logging.debug("Waiting 5 seconds")
|
||||||
#time.sleep(5)
|
time.sleep(5)
|
||||||
logging.debug("Starting new connection")
|
logging.debug("Starting new connection")
|
||||||
kiss_conn.start()
|
kiss_conn.start()
|
||||||
|
# alive_frame = aprs.APRSFrame.ui(
|
||||||
|
# destination="TEST",
|
||||||
|
# source=config['Settings']['mycall'],
|
||||||
|
# path=None,
|
||||||
|
# info=b">None",
|
||||||
|
# )
|
||||||
|
# logging.debug("Sending empty frame to keep connection alive")
|
||||||
|
# kiss_conn.write(alive_frame)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
@ -39,45 +47,40 @@ def main():
|
|||||||
|
|
||||||
logging.basicConfig(filename=config['Settings']['log_path'], level=logging.DEBUG, \
|
logging.basicConfig(filename=config['Settings']['log_path'], level=logging.DEBUG, \
|
||||||
format='%(asctime)s - %(message)s')
|
format='%(asctime)s - %(message)s')
|
||||||
logging.debug('============= kiss_and_db.py running =============')
|
logging.debug('kiss_and_db.py running')
|
||||||
|
|
||||||
ki = aprs.TCPKISS(host=config['Settings']['kiss_host'], port=int(config['Settings']['kiss_port']))
|
ki = aprs.TCPKISS(host=config['Settings']['kiss_host'], port=int(config['Settings']['kiss_port']))
|
||||||
ki.start()
|
ki.start()
|
||||||
|
print(str(ki))
|
||||||
|
ki.stop()
|
||||||
|
print(str(ki))
|
||||||
|
|
||||||
#scheduler = AsyncIOScheduler()
|
scheduler = AsyncIOScheduler()
|
||||||
#scheduler.add_job(refresh_kiss_connection, 'interval', hours = 1, args = [ki])
|
scheduler.add_job(refresh_kiss_connection, 'interval', minutes = 1, args = [ki])
|
||||||
#scheduler.start()
|
scheduler.start()
|
||||||
|
|
||||||
# Make a simple frame and send it
|
# Make a simple frame and send it
|
||||||
# frame = aprs.APRSFrame.ui(
|
# frame = aprs.APRSFrame.ui(
|
||||||
# destination="APZ001",
|
# destination="APZ001",
|
||||||
# source=config['Settings']['mycall'],
|
# source=config['Settings']['mycall'],
|
||||||
# path=["WIDE1-1"],
|
# path=['WIDE1-1'],
|
||||||
# info=b">Hello World!",
|
# info=b">Hello World!",
|
||||||
# )
|
# )
|
||||||
#ki.write(frame)
|
|
||||||
|
|
||||||
# Watch for new packets to come in
|
# Watch for new packets to come in
|
||||||
while True:
|
while True:
|
||||||
conn = get_db_connection()
|
conn = get_db_connection()
|
||||||
for frame in ki.read(min_frames=1):
|
for frame in ki.read(min_frames=1):
|
||||||
logging.debug("New packet, trying to parse")
|
logging.debug("New packet, trying to parse")
|
||||||
logging.debug(str(frame))
|
|
||||||
try:
|
try:
|
||||||
try:
|
a = aprslib.parse(str(frame))
|
||||||
a = aprslib.parse(str(frame))
|
|
||||||
except Exception as error:
|
|
||||||
logging.error("Error with aprslib:", error)
|
|
||||||
a['station_call'] = config['Settings']['station_call']
|
a['station_call'] = config['Settings']['station_call']
|
||||||
a['station_lat'] = config['Settings']['station_lat']
|
a['station_lat'] = config['Settings']['station_lat']
|
||||||
a['station_lon'] = config['Settings']['station_lon']
|
a['station_lon'] = config['Settings']['station_lon']
|
||||||
a['created_unix'] = int(time.time())
|
a['created_unix'] = int(time.time())
|
||||||
|
print(a)
|
||||||
# Make this a string and deal with it later (probably a mistake)
|
# Make this a string and deal with it later (probably a mistake)
|
||||||
a['path'] = str(a['path'])
|
a['path'] = str(a['path'])
|
||||||
if 'subpacket' in a:
|
|
||||||
a['subpacket'] = str(a['subpacket'])
|
|
||||||
#logging.debug(a['path'])
|
|
||||||
# Store true/false as 1/0
|
# Store true/false as 1/0
|
||||||
if 'alive' in a:
|
if 'alive' in a:
|
||||||
if a['alive'] == True:
|
if a['alive'] == True:
|
||||||
@ -87,8 +90,6 @@ def main():
|
|||||||
# Build an INSERT statement based on the fields we have from the frame
|
# Build an INSERT statement based on the fields we have from the frame
|
||||||
attrib_names = ', '.join('"%s"' % w for w in a.keys())
|
attrib_names = ', '.join('"%s"' % w for w in a.keys())
|
||||||
attrib_values = ", ".join("?" * len(a.keys()))
|
attrib_values = ", ".join("?" * len(a.keys()))
|
||||||
logging.debug(attrib_names)
|
|
||||||
logging.debug(a.values())
|
|
||||||
|
|
||||||
logging.debug("Inserting into database")
|
logging.debug("Inserting into database")
|
||||||
try:
|
try:
|
||||||
@ -124,9 +125,9 @@ def main():
|
|||||||
except:
|
except:
|
||||||
#print("Error with SQLite!")
|
#print("Error with SQLite!")
|
||||||
logging.error("Error with SQLite!")
|
logging.error("Error with SQLite!")
|
||||||
except Exception as error:
|
except:
|
||||||
#print("Frame could not be parsed.")
|
#print("Frame could not be parsed.")
|
||||||
logging.error("Frame could not be parsed:", error)
|
logging.error("Frame could not be parsed.")
|
||||||
|
|
||||||
|
|
||||||
conn.close()
|
conn.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user