mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
Improve Morse stream startup compatibility and diagnostics
This commit is contained in:
@@ -265,12 +265,10 @@ def start_morse() -> Response:
|
||||
|
||||
_set_state(MORSE_STARTING, 'Starting decoder...')
|
||||
|
||||
sample_rate = 8000
|
||||
# Use pager-proven audio rate for rtl_fm compatibility across builds.
|
||||
sample_rate = 22050
|
||||
bias_t = _bool_value(data.get('bias_t', False), False)
|
||||
|
||||
# RTL-SDR needs direct sampling mode for HF frequencies below 24 MHz
|
||||
direct_sampling = 2 if freq < 24.0 else None
|
||||
|
||||
sdr_type_str = data.get('sdr_type', 'rtlsdr')
|
||||
try:
|
||||
sdr_type = SDRType(sdr_type_str)
|
||||
@@ -280,15 +278,22 @@ def start_morse() -> Response:
|
||||
sdr_device = SDRFactory.create_default_device(sdr_type, index=device)
|
||||
builder = SDRFactory.get_builder(sdr_device.sdr_type)
|
||||
|
||||
fm_kwargs: dict[str, Any] = {
|
||||
'device': sdr_device,
|
||||
'frequency_mhz': freq,
|
||||
'sample_rate': sample_rate,
|
||||
'gain': float(gain) if gain and gain != '0' else None,
|
||||
'ppm': int(ppm) if ppm and ppm != '0' else None,
|
||||
'modulation': 'usb',
|
||||
'bias_t': bias_t,
|
||||
}
|
||||
|
||||
# Only rtl_fm supports direct sampling flags.
|
||||
if sdr_device.sdr_type == SDRType.RTL_SDR and freq < 24.0:
|
||||
fm_kwargs['direct_sampling'] = 2
|
||||
|
||||
rtl_cmd = builder.build_fm_demod_command(
|
||||
device=sdr_device,
|
||||
frequency_mhz=freq,
|
||||
sample_rate=sample_rate,
|
||||
gain=float(gain) if gain and gain != '0' else None,
|
||||
ppm=int(ppm) if ppm and ppm != '0' else None,
|
||||
modulation='usb',
|
||||
bias_t=bias_t,
|
||||
direct_sampling=direct_sampling,
|
||||
**fm_kwargs,
|
||||
)
|
||||
|
||||
full_cmd = ' '.join(rtl_cmd)
|
||||
|
||||
@@ -173,11 +173,18 @@ var MorseMode = (function () {
|
||||
function loadSettings() {
|
||||
try {
|
||||
var raw = localStorage.getItem(SETTINGS_KEY);
|
||||
if (!raw) return;
|
||||
if (!raw) {
|
||||
if (el('morseShowDiag')) el('morseShowDiag').checked = true;
|
||||
toggleDiagPanel();
|
||||
persistSettings();
|
||||
return;
|
||||
}
|
||||
var parsed = JSON.parse(raw);
|
||||
applySettings(parsed);
|
||||
} catch (_) {
|
||||
// Ignore malformed settings.
|
||||
if (el('morseShowDiag')) el('morseShowDiag').checked = true;
|
||||
toggleDiagPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,6 +562,11 @@ var MorseMode = (function () {
|
||||
if (!scopeWaiting) {
|
||||
scopeWaiting = true;
|
||||
waitingStart = Date.now();
|
||||
appendDiagLine('[morse] waiting for PCM stream...');
|
||||
}
|
||||
var waitElapsedMs = waitingStart ? (Date.now() - waitingStart) : 0;
|
||||
if (waitElapsedMs > 10000 && el('morseDiagLog') && el('morseDiagLog').children.length < 6) {
|
||||
appendDiagLine('[hint] No samples after 10s. Check SDR device, frequency, and HF direct sampling path.');
|
||||
}
|
||||
} else if (amps.length > 0) {
|
||||
scopeWaiting = false;
|
||||
@@ -812,6 +824,9 @@ var MorseMode = (function () {
|
||||
if (!log) return;
|
||||
|
||||
var showDiag = !!(el('morseShowDiag') && el('morseShowDiag').checked);
|
||||
if (!showDiag && scopeWaiting) {
|
||||
showDiag = true;
|
||||
}
|
||||
if (!showDiag) return;
|
||||
|
||||
log.style.display = 'block';
|
||||
|
||||
Reference in New Issue
Block a user