diff --git a/routes/listening_post.py b/routes/listening_post.py index d0bf594..50dbef6 100644 --- a/routes/listening_post.py +++ b/routes/listening_post.py @@ -467,7 +467,7 @@ def scanner_loop_power(): noise_floor = sorted_vals[mid] # SNR threshold (dB) based on squelch - snr_threshold = 8 + (squelch * 0.3) + snr_threshold = float(scanner_config.get('snr_threshold', 12)) # Emit progress updates (throttled) emit_stride = max(1, len(bin_values) // 60) @@ -800,6 +800,8 @@ def start_scanner() -> Response: scanner_config['bias_t'] = bool(data.get('bias_t', False)) scanner_config['sdr_type'] = str(data.get('sdr_type', 'rtlsdr')).lower() scanner_config['scan_method'] = str(data.get('scan_method', '')).lower().strip() + if data.get('snr_threshold') is not None: + scanner_config['snr_threshold'] = float(data.get('snr_threshold')) except (ValueError, TypeError) as e: return jsonify({ 'status': 'error', diff --git a/static/js/modes/listening-post.js b/static/js/modes/listening-post.js index 2a1ee34..8fd1dc5 100644 --- a/static/js/modes/listening-post.js +++ b/static/js/modes/listening-post.js @@ -28,6 +28,7 @@ let audioQueue = []; let isWebSocketAudio = false; let audioFetchController = null; let audioUnlockRequested = false; +let scannerSnrThreshold = 12; // Visualizer state let visualizerContext = null; @@ -154,6 +155,7 @@ function startScanner() { const dwellSelect = document.getElementById('radioScanDwell'); const dwell = dwellSelect ? parseInt(dwellSelect.value) : 10; const device = getSelectedDevice(); + const snrThreshold = scannerSnrThreshold || 12; // Check if using agent mode const isAgentMode = typeof currentAgent !== 'undefined' && currentAgent !== 'local'; @@ -215,7 +217,9 @@ function startScanner() { gain: gain, dwell_time: dwell, device: device, - bias_t: typeof getBiasTEnabled === 'function' ? getBiasTEnabled() : false + bias_t: typeof getBiasTEnabled === 'function' ? getBiasTEnabled() : false, + snr_threshold: snrThreshold, + scan_method: 'power' }) }) .then(r => r.json()) @@ -1721,6 +1725,7 @@ function getStreamUrl(freq, mod) { function initListeningPost() { checkScannerTools(); checkAudioTools(); + initSnrThresholdControl(); // WebSocket audio disabled for now - using HTTP streaming // initWebSocketAudio(); @@ -1824,6 +1829,29 @@ function initListeningPost() { checkIncomingTuneRequest(); } +function initSnrThresholdControl() { + const slider = document.getElementById('snrThresholdSlider'); + const valueEl = document.getElementById('snrThresholdValue'); + if (!slider || !valueEl) return; + + const stored = localStorage.getItem('scannerSnrThreshold'); + if (stored) { + const parsed = parseInt(stored, 10); + if (!Number.isNaN(parsed)) { + scannerSnrThreshold = parsed; + } + } + + slider.value = scannerSnrThreshold; + valueEl.textContent = String(scannerSnrThreshold); + + slider.addEventListener('input', () => { + scannerSnrThreshold = parseInt(slider.value, 10); + valueEl.textContent = String(scannerSnrThreshold); + localStorage.setItem('scannerSnrThreshold', String(scannerSnrThreshold)); + }); +} + /** * Check for incoming tune request from Spy Stations or other pages */ diff --git a/templates/index.html b/templates/index.html index 7d6fa07..8e0190a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1071,6 +1071,13 @@ style="font-size: 8px; color: var(--text-muted); min-width: 40px; text-align: right;">-- dB +
+ SNR THRESH + + 12 +