Add SNR threshold control for power scan

This commit is contained in:
Smittix
2026-02-04 11:54:56 +00:00
parent 37add84d59
commit c0fa59d10e
3 changed files with 39 additions and 2 deletions
+3 -1
View File
@@ -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',
+29 -1
View File
@@ -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
*/
+7
View File
@@ -1071,6 +1071,13 @@
style="font-size: 8px; color: var(--text-muted); min-width: 40px; text-align: right;">--
dB</span>
</div>
<div style="display: flex; align-items: center; gap: 8px; margin-top: 8px;">
<span style="font-size: 7px; color: var(--text-muted); letter-spacing: 1px;">SNR THRESH</span>
<input type="range" id="snrThresholdSlider" min="6" max="20" step="1" value="12"
style="flex: 1;" />
<span id="snrThresholdValue"
style="font-size: 8px; color: var(--text-muted); min-width: 26px; text-align: right;">12</span>
</div>
<!-- Signal Alert inline -->
<div id="mainSignalAlert"
style="display: none; background: rgba(0, 255, 100, 0.2); border: 1px solid var(--accent-green); border-radius: 4px; padding: 5px; text-align: center; margin-top: 8px;">