mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
Sync scanner range from backend updates
This commit is contained in:
@@ -168,14 +168,16 @@ def scanner_loop():
|
||||
scanner_current_freq = current_freq
|
||||
|
||||
# Notify clients of frequency change
|
||||
try:
|
||||
scanner_queue.put_nowait({
|
||||
'type': 'freq_change',
|
||||
'frequency': current_freq,
|
||||
'scanning': not signal_detected
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
try:
|
||||
scanner_queue.put_nowait({
|
||||
'type': 'freq_change',
|
||||
'frequency': current_freq,
|
||||
'scanning': not signal_detected,
|
||||
'range_start': scanner_config['start_freq'],
|
||||
'range_end': scanner_config['end_freq']
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
|
||||
# Start rtl_fm at this frequency
|
||||
freq_hz = int(current_freq * 1e6)
|
||||
@@ -259,16 +261,18 @@ def scanner_loop():
|
||||
audio_detected = rms > effective_threshold
|
||||
|
||||
# Send level info to clients
|
||||
try:
|
||||
scanner_queue.put_nowait({
|
||||
'type': 'scan_update',
|
||||
'frequency': current_freq,
|
||||
'level': int(rms),
|
||||
try:
|
||||
scanner_queue.put_nowait({
|
||||
'type': 'scan_update',
|
||||
'frequency': current_freq,
|
||||
'level': int(rms),
|
||||
'threshold': int(effective_threshold) if 'effective_threshold' in dir() else 0,
|
||||
'detected': audio_detected
|
||||
'detected': audio_detected,
|
||||
'range_start': scanner_config['start_freq'],
|
||||
'range_end': scanner_config['end_freq']
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
except queue.Full:
|
||||
pass
|
||||
|
||||
if audio_detected and scanner_running:
|
||||
if not signal_detected:
|
||||
@@ -282,17 +286,19 @@ def scanner_loop():
|
||||
# Start audio streaming for user
|
||||
_start_audio_stream(current_freq, mod)
|
||||
|
||||
try:
|
||||
scanner_queue.put_nowait({
|
||||
'type': 'signal_found',
|
||||
'frequency': current_freq,
|
||||
'modulation': mod,
|
||||
'audio_streaming': True,
|
||||
'level': int(rms),
|
||||
'threshold': int(effective_threshold)
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
try:
|
||||
scanner_queue.put_nowait({
|
||||
'type': 'signal_found',
|
||||
'frequency': current_freq,
|
||||
'modulation': mod,
|
||||
'audio_streaming': True,
|
||||
'level': int(rms),
|
||||
'threshold': int(effective_threshold),
|
||||
'range_start': scanner_config['start_freq'],
|
||||
'range_end': scanner_config['end_freq']
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
|
||||
# Check for skip signal
|
||||
if scanner_skip_signal:
|
||||
@@ -328,7 +334,9 @@ def scanner_loop():
|
||||
try:
|
||||
scanner_queue.put_nowait({
|
||||
'type': 'signal_lost',
|
||||
'frequency': current_freq
|
||||
'frequency': current_freq,
|
||||
'range_start': scanner_config['start_freq'],
|
||||
'range_end': scanner_config['end_freq']
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
@@ -446,7 +454,9 @@ def scanner_loop_power():
|
||||
'frequency': end_mhz,
|
||||
'level': 0,
|
||||
'threshold': int(float(scanner_config.get('snr_threshold', 12)) * 100),
|
||||
'detected': False
|
||||
'detected': False,
|
||||
'range_start': scanner_config['start_freq'],
|
||||
'range_end': scanner_config['end_freq']
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
@@ -503,7 +513,9 @@ def scanner_loop_power():
|
||||
'frequency': end_mhz,
|
||||
'level': 0,
|
||||
'threshold': int(float(scanner_config.get('snr_threshold', 12)) * 100),
|
||||
'detected': False
|
||||
'detected': False,
|
||||
'range_start': scanner_config['start_freq'],
|
||||
'range_end': scanner_config['end_freq']
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
@@ -545,7 +557,9 @@ def scanner_loop_power():
|
||||
'level': level,
|
||||
'threshold': threshold,
|
||||
'detected': snr >= snr_threshold,
|
||||
'progress': progress
|
||||
'progress': progress,
|
||||
'range_start': scanner_config['start_freq'],
|
||||
'range_end': scanner_config['end_freq']
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
@@ -591,7 +605,9 @@ def scanner_loop_power():
|
||||
'modulation': mod,
|
||||
'audio_streaming': False,
|
||||
'level': level,
|
||||
'threshold': threshold
|
||||
'threshold': threshold,
|
||||
'range_start': scanner_config['start_freq'],
|
||||
'range_end': scanner_config['end_freq']
|
||||
})
|
||||
except queue.Full:
|
||||
pass
|
||||
|
||||
@@ -616,11 +616,44 @@ function handleScannerEvent(data) {
|
||||
}
|
||||
|
||||
function handleFrequencyUpdate(data) {
|
||||
if (data.range_start !== undefined && data.range_end !== undefined) {
|
||||
const newStart = parseFloat(data.range_start);
|
||||
const newEnd = parseFloat(data.range_end);
|
||||
if (Number.isFinite(newStart) && Number.isFinite(newEnd) && newEnd > newStart) {
|
||||
scannerStartFreq = newStart;
|
||||
scannerEndFreq = newEnd;
|
||||
scannerTotalSteps = Math.max(1, Math.round(((scannerEndFreq - scannerStartFreq) * 1000) / (scannerStepKhz || 1)));
|
||||
|
||||
const rangeStart = document.getElementById('scannerRangeStart');
|
||||
if (rangeStart) rangeStart.textContent = newStart.toFixed(1);
|
||||
const rangeEnd = document.getElementById('scannerRangeEnd');
|
||||
if (rangeEnd) rangeEnd.textContent = newEnd.toFixed(1);
|
||||
const mainRangeStart = document.getElementById('mainRangeStart');
|
||||
if (mainRangeStart) mainRangeStart.textContent = newStart.toFixed(1) + ' MHz';
|
||||
const mainRangeEnd = document.getElementById('mainRangeEnd');
|
||||
if (mainRangeEnd) mainRangeEnd.textContent = newEnd.toFixed(1) + ' MHz';
|
||||
|
||||
const startInput = document.getElementById('radioScanStart');
|
||||
if (startInput && document.activeElement !== startInput) {
|
||||
startInput.value = newStart.toFixed(3);
|
||||
}
|
||||
const endInput = document.getElementById('radioScanEnd');
|
||||
if (endInput && document.activeElement !== endInput) {
|
||||
endInput.value = newEnd.toFixed(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const range = scannerEndFreq - scannerStartFreq;
|
||||
if (range <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const effectiveRange = scannerEndFreq - scannerStartFreq;
|
||||
if (effectiveRange <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const hasProgress = data.progress !== undefined && Number.isFinite(data.progress);
|
||||
const freqValue = (typeof data.frequency === 'number' && Number.isFinite(data.frequency))
|
||||
? data.frequency
|
||||
@@ -648,7 +681,7 @@ function handleFrequencyUpdate(data) {
|
||||
}
|
||||
}
|
||||
lastScanFreq = freqValue;
|
||||
progressValue = (freqValue - scannerStartFreq) / range;
|
||||
progressValue = (freqValue - scannerStartFreq) / effectiveRange;
|
||||
lastScanProgress = Math.max(0, Math.min(1, progressValue));
|
||||
} else {
|
||||
if (scannerMethod === 'power') {
|
||||
@@ -664,7 +697,7 @@ function handleFrequencyUpdate(data) {
|
||||
&& freqValue >= (scannerStartFreq - freqTolerance)
|
||||
&& freqValue <= (scannerEndFreq + freqTolerance))
|
||||
? freqValue
|
||||
: scannerStartFreq + (clampedProgress * range);
|
||||
: scannerStartFreq + (clampedProgress * effectiveRange);
|
||||
const freqStr = displayFreq.toFixed(3);
|
||||
|
||||
const currentFreq = document.getElementById('scannerCurrentFreq');
|
||||
|
||||
Reference in New Issue
Block a user