diff --git a/modules/radio.py b/modules/radio.py index 3a13d47..7e37b64 100644 --- a/modules/radio.py +++ b/modules/radio.py @@ -7,13 +7,6 @@ import socket import asyncio from modules.settings import * -SIGNAL_DETECTION_THRESHOLD = -10 # dBm -SIGNAL_HOLD_TIME = 10 # seconds to hold on to signal before checking again -SIGNAL_COOLDOWN = 5 # seconds to wait between signal checks -SIGNAL_CYCLE_LIMIT = 4 # multiply by SIGNAL_COOLDOWN to get total time to wait before resetting signal strength - -ERROR_FETCHING_DATA = "error fetching data" - def get_hamlib(msg="f"): try: rigControlSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) @@ -115,18 +108,18 @@ async def signalWatcher(): global signalCycle try: signalStrength = int(get_sig_strength()) - if signalStrength >= previousStrength and signalStrength > SIGNAL_DETECTION_THRESHOLD: + if signalStrength >= previousStrength and signalStrength > signalDetectionThreshold: message = f"Detected {get_freq_common_name(get_hamlib('f'))} active use S-Meter:{signalStrength}dBm" previousStrength = signalStrength signalCycle = 0 - await asyncio.sleep(SIGNAL_HOLD_TIME) + await asyncio.sleep(signalHoldTime) return message else: signalCycle += 1 - if signalCycle >= SIGNAL_CYCLE_LIMIT: + if signalCycle >= signalCycleLimit: signalCycle = 0 previousStrength = -40 - await asyncio.sleep(SIGNAL_COOLDOWN) + await asyncio.sleep(signalCooldown) return None except Exception as e: signalStrength = -40 diff --git a/modules/settings.py b/modules/settings.py index 97cb78d..25e796d 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -74,8 +74,12 @@ try: repeater_enabled = config['repeater'].getboolean('enabled', False) repeater_channels = config['repeater'].get('repeater_channels', '').split(',') radio_dectection_enabled = config['radioMon'].getboolean('enabled', False) - rigControlServerAddress = config['radioMon'].get('rigControlServerAddress', 'localhost:4532') - sigWatchBrodcastCh = config['radioMon'].get('sigWatchBrodcastCh', '2').split(',') + rigControlServerAddress = config['radioMon'].get('rigControlServerAddress', 'localhost:4532') # default localhost:4532 + sigWatchBrodcastCh = config['radioMon'].get('sigWatchBrodcastCh', '2').split(',') # default Channel 2 + signalDetectionThreshold = config['radioMon'].getint('signalDetectionThreshold', -10) # default -10 dBm + signalHoldTime = config['radioMon'].getint('signalHoldTime', 10) # default 10 seconds + signalCooldown = config['radioMon'].getint('signalCooldown', 5) # default 1 second + signalCycleLimit = config['radioMon'].getint('signalCycleLimit', 5) # default 5 cycles, used with SIGNAL_COOLDOWN except KeyError as e: print(f"System: Error reading config file: {e}") print(f"System: Check the config.ini against config.template file for missing sections or values.")