mirror of
https://github.com/TheCommsChannel/TC2-APRS-BBS.git
synced 2025-06-28 07:47:26 -04:00
Merge f797b5909a
into 3fea62db14
This commit is contained in:
commit
37bbf38ee4
3 changed files with 66 additions and 41 deletions
|
@ -57,7 +57,7 @@ coming soon. This software is experimental and could have bugs. Bug reports and
|
||||||
5. Rename `example_config.ini`:
|
5. Rename `example_config.ini`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
mv example_config.ini config.ini
|
cp example_config.ini config.ini
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Set up the configuration in `config.ini`:
|
6. Set up the configuration in `config.ini`:
|
||||||
|
|
14
aprs_comm.py
14
aprs_comm.py
|
@ -22,9 +22,17 @@ unack_lock = Lock()
|
||||||
message_counter = 1
|
message_counter = 1
|
||||||
message_lock = threading.Lock()
|
message_lock = threading.Lock()
|
||||||
|
|
||||||
|
# Global flag to indicate shutdown
|
||||||
|
shutdown_event = threading.Event()
|
||||||
|
|
||||||
|
|
||||||
JSON_URL = "https://aprs-deviceid.aprsfoundation.org/tocalls.pretty.json"
|
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():
|
def fetch_device_data():
|
||||||
local_file = "tocalls_cache.json"
|
local_file = "tocalls_cache.json"
|
||||||
|
|
||||||
|
@ -148,7 +156,11 @@ def start():
|
||||||
print(f"BBS Callsign: {my_callsign}")
|
print(f"BBS Callsign: {my_callsign}")
|
||||||
|
|
||||||
while True:
|
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:
|
try:
|
||||||
if config.RAW_PACKET_DISPLAY:
|
if config.RAW_PACKET_DISPLAY:
|
||||||
print(f"{COLOR_RAW}RAW PACKET:{COLOR_RESET} {frame}")
|
print(f"{COLOR_RAW}RAW PACKET:{COLOR_RESET} {frame}")
|
||||||
|
|
13
main.py
13
main.py
|
@ -3,6 +3,9 @@ import aprs_comm
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import signal
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def scheduled_cleanup():
|
def scheduled_cleanup():
|
||||||
"""Periodically run cleanup of expired bulletins."""
|
"""Periodically run cleanup of expired bulletins."""
|
||||||
|
@ -14,6 +17,11 @@ def scheduled_cleanup():
|
||||||
print(f"Error during cleanup: {e}")
|
print(f"Error during cleanup: {e}")
|
||||||
time.sleep(24 * 60 * 60) # Run cleanup every 24 hours
|
time.sleep(24 * 60 * 60) # Run cleanup every 24 hours
|
||||||
|
|
||||||
|
def signal_handler(signum, frame):
|
||||||
|
print(f"Received signal {signum}. Shutting down...")
|
||||||
|
aprs_comm.shutdown()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
banner = """
|
banner = """
|
||||||
\033[96m
|
\033[96m
|
||||||
|
@ -34,8 +42,13 @@ def main():
|
||||||
cleanup_thread = threading.Thread(target=scheduled_cleanup, daemon=True)
|
cleanup_thread = threading.Thread(target=scheduled_cleanup, daemon=True)
|
||||||
cleanup_thread.start()
|
cleanup_thread.start()
|
||||||
|
|
||||||
|
print("Setting up signal handlers...")
|
||||||
|
signal.signal(signal.SIGINT, signal_handler) # Ctrl+C
|
||||||
|
signal.signal(signal.SIGTERM, signal_handler) # kill command
|
||||||
|
|
||||||
print("Starting APRS communications...")
|
print("Starting APRS communications...")
|
||||||
aprs_comm.start()
|
aprs_comm.start()
|
||||||
|
return 0
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue