op25: pin gr310 to 5b58335; analog defaults to OP25 noise squelch (node-26#46, node-26#29)
- op25-container/Dockerfile: clone gr310 then check out 5b58335 (OP25_COMMIT build arg). That is the gr310 merge tk_drb_conv was verified against for #29 and the first carrying PR #296's NBFM noise/voice squelch. Changing the RUN line also busts CI's cached unpinned clone. - Keys verified from op25_nbfm.py at that commit: nbfm_squelch_mode (power|noise|voice), nbfm_noise_squelch_db, nbfm_squelch_threshold, read from the channel dict. - op25-container: ConfigGenerator.nbfm_squelch_mode (enum, default noise) and nbfm_noise_squelch_db, written onto the analog channel. - edge-node: system config squelch_mode / squelch_db / squelch_threshold -> generate payload (validated, noise when absent); /api/listen and the dashboard's analog pane expose mode and level. #29's CI test of tk_drb_conv against the real tk_p25.py is not done here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6b884d5433
commit
a4a575ec9f
@@ -9,7 +9,11 @@ C2 system documents (the `config` blob is passed through untouched):
|
||||
P25 conventional type "P25", config.mode "conventional",
|
||||
config.channels = [{freq: MHz, name, nac?}, ...] (node-26#24)
|
||||
Analog type "NBFM", config.channels = [{freq, name}] — or, from
|
||||
before #24, config.control_channels[0]
|
||||
before #24, config.control_channels[0]. Optional squelch
|
||||
(node-26#46): config.squelch_mode "noise" (default) |
|
||||
"voice" | "power", config.squelch_db (noise/voice: dB
|
||||
of quieting to open) and config.squelch_threshold
|
||||
(power: absolute dB, OP25 default -60)
|
||||
|
||||
A missing mode is trunked, so every system saved before #24 behaves exactly as
|
||||
it did. Pure functions; main._generate_op25_config does the I/O.
|
||||
@@ -80,6 +84,41 @@ def conventional_channels(config: Dict[str, Any]) -> List[Dict[str, Any]]:
|
||||
return out
|
||||
|
||||
|
||||
SQUELCH_MODES = ("noise", "voice", "power")
|
||||
DEFAULT_SQUELCH_MODE = "noise"
|
||||
|
||||
|
||||
def _optional_float(config: Dict[str, Any], key: str) -> Optional[float]:
|
||||
value = (config or {}).get(key)
|
||||
if value is None or (isinstance(value, str) and not value.strip()):
|
||||
return None
|
||||
try:
|
||||
return float(value)
|
||||
except (TypeError, ValueError):
|
||||
raise ValueError(f"{key} {value!r} isn't a number.")
|
||||
|
||||
|
||||
def analog_squelch(config: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"""config -> the op25-container squelch fields for an analog channel.
|
||||
|
||||
Noise squelch by default (node-26#46): OP25's power squelch compares an
|
||||
absolute level that depends on dongle, gain and antenna, and left analog
|
||||
open on static; noise squelch measures FM quieting and needs no
|
||||
calibration. A config that says nothing gets noise mode.
|
||||
"""
|
||||
mode = str((config or {}).get("squelch_mode") or DEFAULT_SQUELCH_MODE).strip().lower()
|
||||
if mode not in SQUELCH_MODES:
|
||||
raise ValueError(f"Squelch mode {mode!r} isn't one of {', '.join(SQUELCH_MODES)}.")
|
||||
out: Dict[str, Any] = {"nbfm_squelch_mode": mode}
|
||||
db = _optional_float(config, "squelch_db")
|
||||
if db is not None:
|
||||
out["nbfm_noise_squelch_db"] = db
|
||||
threshold = _optional_float(config, "squelch_threshold")
|
||||
if threshold is not None:
|
||||
out["nbfm_squelch"] = threshold
|
||||
return out
|
||||
|
||||
|
||||
def analog_frequency(config: Dict[str, Any]) -> Optional[int]:
|
||||
chans = (config or {}).get("channels") or []
|
||||
if chans and isinstance(chans[0], dict) and chans[0].get("freq") not in (None, ""):
|
||||
@@ -117,6 +156,7 @@ def build_generate_payload(
|
||||
if mode == ANALOG:
|
||||
freq = analog_frequency(config)
|
||||
payload["channels"] = [freq] if freq else []
|
||||
payload.update(analog_squelch(config))
|
||||
return payload
|
||||
|
||||
talkgroups = (config or {}).get("talkgroups", []) or []
|
||||
|
||||
@@ -208,6 +208,12 @@ class ListenBody(BaseModel):
|
||||
frequencies: List[float] = []
|
||||
talkgroups: List[Talkgroup] = [] # p25 only; empty = every talkgroup
|
||||
nac: Optional[str] = None # p25conv only, hex; empty = any NAC
|
||||
# analog only (node-26#46): OP25 squelch. noise (default) needs no
|
||||
# calibration; squelch_db = dB of quieting to open (OP25 default 8);
|
||||
# squelch_threshold = absolute dB for power mode (OP25 default -60).
|
||||
squelch_mode: Optional[Literal["noise", "voice", "power"]] = None
|
||||
squelch_db: Optional[float] = None
|
||||
squelch_threshold: Optional[float] = None
|
||||
|
||||
|
||||
# RTL-SDR (R820T/R828D) tuning range.
|
||||
@@ -242,14 +248,21 @@ async def listen(body: ListenBody):
|
||||
else:
|
||||
is_p25 = body.mode == "p25"
|
||||
label = (body.name or "").strip() or (f"P25 {first} MHz" if is_p25 else f"Analog {first} MHz")
|
||||
sys_config = {
|
||||
"control_channels": freqs,
|
||||
"talkgroups": [tg.model_dump() for tg in body.talkgroups] if is_p25 else [],
|
||||
}
|
||||
if not is_p25:
|
||||
sys_config["squelch_mode"] = body.squelch_mode or "noise"
|
||||
if body.squelch_db is not None:
|
||||
sys_config["squelch_db"] = body.squelch_db
|
||||
if body.squelch_threshold is not None:
|
||||
sys_config["squelch_threshold"] = body.squelch_threshold
|
||||
config = SystemConfig(
|
||||
system_id=f"local-{body.mode}",
|
||||
name=label,
|
||||
type="P25" if is_p25 else "NBFM",
|
||||
config={
|
||||
"control_channels": freqs,
|
||||
"talkgroups": [tg.model_dump() for tg in body.talkgroups] if is_p25 else [],
|
||||
},
|
||||
config=sys_config,
|
||||
)
|
||||
await _apply_override(config)
|
||||
return {"ok": True, "name": config.name}
|
||||
|
||||
@@ -216,6 +216,20 @@
|
||||
<label for="an-name">Name <span class="hint">(optional)</span></label>
|
||||
<input type="text" id="an-name" placeholder="Fire dispatch">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="an-sq-mode">Squelch</label>
|
||||
<select id="an-sq-mode">
|
||||
<option value="noise" selected>Noise (recommended)</option>
|
||||
<option value="voice">Voice (noise + speech detector)</option>
|
||||
<option value="power">Power (old, needs calibration)</option>
|
||||
</select>
|
||||
<span class="hint">Noise squelch opens on a real carrier and needs no tuning per site.</span>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="an-sq-level">Squelch level (dB) <span class="hint">(optional)</span></label>
|
||||
<input type="text" id="an-sq-level" class="mono" placeholder="8" inputmode="decimal">
|
||||
<span class="hint" id="an-sq-hint">Noise/voice: dB of quieting to open — 8 default, 12-15 for strong signals only, ~5 for weak ones.</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pane" data-pane="system" hidden>
|
||||
@@ -396,6 +410,13 @@
|
||||
// ── Listen locally ─────────────────────────────────────────────────────
|
||||
let systems = [];
|
||||
function mode() { return document.querySelector('input[name=mode]:checked').value; }
|
||||
$('an-sq-mode').addEventListener('change', () => {
|
||||
const power = $('an-sq-mode').value === 'power';
|
||||
$('an-sq-level').placeholder = power ? '-60' : '8';
|
||||
$('an-sq-hint').textContent = power
|
||||
? 'Power: absolute signal level in dB to open (-60 default); depends on this SDR, gain and antenna.'
|
||||
: 'Noise/voice: dB of quieting to open — 8 default, 12-15 for strong signals only, ~5 for weak ones.';
|
||||
});
|
||||
document.querySelectorAll('input[name=mode]').forEach(r => r.addEventListener('change', () => {
|
||||
document.querySelectorAll('.pane').forEach(p => { p.hidden = p.dataset.pane !== mode(); });
|
||||
$('listen-msg').textContent = '';
|
||||
@@ -443,7 +464,12 @@
|
||||
} else {
|
||||
const freqs = parseFreqs($('an-freq').value);
|
||||
if (freqs.length !== 1 || isNaN(freqs[0])) { msg.className = 'msg err'; msg.textContent = 'Enter one frequency in MHz, e.g. 154.4300'; return; }
|
||||
body = { mode: 'analog', frequencies: freqs, name: $('an-name').value };
|
||||
const sqMode = $('an-sq-mode').value;
|
||||
const sqRaw = $('an-sq-level').value.trim();
|
||||
const sqLevel = sqRaw === '' ? null : Number(sqRaw);
|
||||
if (sqLevel !== null && isNaN(sqLevel)) { msg.className = 'msg err'; msg.textContent = 'Squelch level must be a number of dB, e.g. 8 (or -60 for power mode).'; return; }
|
||||
body = { mode: 'analog', frequencies: freqs, name: $('an-name').value, squelch_mode: sqMode };
|
||||
if (sqLevel !== null) body[sqMode === 'power' ? 'squelch_threshold' : 'squelch_db'] = sqLevel;
|
||||
}
|
||||
$('listen-btn').disabled = true;
|
||||
msg.className = 'msg';
|
||||
|
||||
@@ -78,6 +78,17 @@ def test_analog_payload_reads_channels_or_legacy(cfg):
|
||||
p = rc.build_generate_payload("NBFM", "Fire", cfg, ICE, "rtl-sdr-v3", None)
|
||||
assert p["channels"] == [154_430_000]
|
||||
assert "p25_mode" not in p
|
||||
assert p["nbfm_squelch_mode"] == "noise" # node-26#46 default
|
||||
|
||||
|
||||
def test_analog_squelch_is_plumbed_and_validated():
|
||||
cfg = {"channels": [{"freq": 154.43}], "squelch_mode": "Power", "squelch_threshold": "-55", "squelch_db": 12}
|
||||
p = rc.build_generate_payload("NBFM", "Fire", cfg, ICE, "rtl-sdr-v3", None)
|
||||
assert p["nbfm_squelch_mode"] == "power" and p["nbfm_squelch"] == -55.0 and p["nbfm_noise_squelch_db"] == 12.0
|
||||
with pytest.raises(ValueError):
|
||||
rc.analog_squelch({"squelch_mode": "loud"})
|
||||
with pytest.raises(ValueError):
|
||||
rc.analog_squelch({"squelch_db": "lots"})
|
||||
|
||||
|
||||
def test_system_mode():
|
||||
|
||||
@@ -229,6 +229,17 @@ def test_listen_analog_single_frequency(client, op25):
|
||||
assert r.status_code == 200, r.text
|
||||
cfg = config_manager.load_node_config().override_config
|
||||
assert (cfg.type, cfg.name, cfg.config["control_channels"]) == ("NBFM", "Fire", [154.43])
|
||||
assert cfg.config["squelch_mode"] == "noise" # node-26#46 default
|
||||
|
||||
|
||||
def test_listen_analog_squelch_is_saved(client, op25):
|
||||
r = client.post("/api/listen", json={"mode": "analog", "frequencies": [154.43],
|
||||
"squelch_mode": "power", "squelch_threshold": -55})
|
||||
assert r.status_code == 200, r.text
|
||||
cfg = config_manager.load_node_config().override_config.config
|
||||
assert (cfg["squelch_mode"], cfg["squelch_threshold"]) == ("power", -55)
|
||||
assert client.post("/api/listen", json={"mode": "analog", "frequencies": [154.43],
|
||||
"squelch_mode": "loud"}).status_code == 422
|
||||
|
||||
|
||||
def test_listen_p25_conventional(client, op25):
|
||||
|
||||
Reference in New Issue
Block a user