Implement clean exit

This commit is contained in:
Levente Kovacs 2025-04-28 22:29:56 +02:00
parent bd51c53c87
commit f797b5909a
2 changed files with 26 additions and 1 deletions

View file

@ -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}")