mirror of
https://github.com/TheCommsChannel/TC2-APRS-BBS.git
synced 2025-06-28 15:57:15 -04:00
Implement clean exit
This commit is contained in:
parent
bd51c53c87
commit
f797b5909a
2 changed files with 26 additions and 1 deletions
14
aprs_comm.py
14
aprs_comm.py
|
@ -22,9 +22,17 @@ unack_lock = Lock()
|
|||
message_counter = 1
|
||||
message_lock = threading.Lock()
|
||||
|
||||
# Global flag to indicate shutdown
|
||||
shutdown_event = threading.Event()
|
||||
|
||||
|
||||
JSON_URL = "https://aprs-deviceid.aprsfoundation.org/tocalls.pretty.json"
|
||||
|
||||
def shutdown():
|
||||
"""Signal the APRS loop to shut down."""
|
||||
print("Shutdown signal received. Stopping APRS communications...")
|
||||
shutdown_event.set()
|
||||
|
||||
def fetch_device_data():
|
||||
local_file = "tocalls_cache.json"
|
||||
|
||||
|
@ -148,7 +156,11 @@ def start():
|
|||
print(f"BBS Callsign: {my_callsign}")
|
||||
|
||||
while True:
|
||||
for frame in ki.read(min_frames=1):
|
||||
if shutdown_event.is_set():
|
||||
print("Shutdown event set. Exiting APRS loop.")
|
||||
ki.stop()
|
||||
break
|
||||
for frame in ki.read(min_frames=0):
|
||||
try:
|
||||
if config.RAW_PACKET_DISPLAY:
|
||||
print(f"{COLOR_RAW}RAW PACKET:{COLOR_RESET} {frame}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue