mirror of
https://github.com/smittix/intercept.git
synced 2026-06-08 14:11:54 -07:00
Relax CID=0 filter: allow partially decoded cells with valid MCC/MNC
CID=0 with valid MCC/MNC means the scanner found the cell but didn't decode System Information 3/4 (which carries the Cell ID). These are still valid towers worth displaying. Only filter when MCC=0 AND MNC=0 (truly unidentified signals). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-4
@@ -1130,10 +1130,12 @@ def parse_grgsm_scanner_output(line: str) -> dict[str, Any] | None:
|
||||
if 'ARFCN' in fields and 'CID' in fields:
|
||||
cid = int(fields.get('CID', 0))
|
||||
mcc = int(fields.get('MCC', 0))
|
||||
mnc = int(fields.get('MNC', 0))
|
||||
|
||||
# Skip entries with no decoded cell identity (CID=0 means no cell info)
|
||||
if cid == 0 or mcc == 0:
|
||||
logger.debug(f"Skipping unresolved ARFCN (CID={cid}, MCC={mcc}): {line}")
|
||||
# Only skip entries with no network identity at all (MCC=0 AND MNC=0)
|
||||
# CID=0 with valid MCC/MNC is a partially decoded cell - still useful
|
||||
if mcc == 0 and mnc == 0:
|
||||
logger.debug(f"Skipping unidentified ARFCN (MCC=0, MNC=0): {line}")
|
||||
return None
|
||||
|
||||
# Freq may have 'M' suffix (e.g. "925.2M")
|
||||
@@ -1146,7 +1148,7 @@ def parse_grgsm_scanner_output(line: str) -> dict[str, Any] | None:
|
||||
'cid': cid,
|
||||
'lac': int(fields.get('LAC', 0)),
|
||||
'mcc': mcc,
|
||||
'mnc': int(fields.get('MNC', 0)),
|
||||
'mnc': mnc,
|
||||
'signal_strength': float(fields.get('Pwr', -999)),
|
||||
'timestamp': datetime.now().isoformat()
|
||||
}
|
||||
|
||||
+13
-4
@@ -71,18 +71,27 @@ class TestParseGrgsmScannerOutput:
|
||||
result = parse_grgsm_scanner_output(line)
|
||||
assert result is None
|
||||
|
||||
def test_cid_zero_filtered(self):
|
||||
"""Test that CID=0 entries (no decoded cell) are filtered out."""
|
||||
def test_no_identity_filtered(self):
|
||||
"""Test that MCC=0/MNC=0 entries (no network identity) are filtered out."""
|
||||
line = "ARFCN: 115, Freq: 925.0M, CID: 0, LAC: 0, MCC: 0, MNC: 0, Pwr: -100"
|
||||
result = parse_grgsm_scanner_output(line)
|
||||
assert result is None
|
||||
|
||||
def test_mcc_zero_filtered(self):
|
||||
"""Test that MCC=0 entries (no decoded identity) are filtered out."""
|
||||
def test_mcc_zero_mnc_zero_filtered(self):
|
||||
"""Test that MCC=0/MNC=0 even with valid CID is filtered out."""
|
||||
line = "ARFCN: 113, Freq: 924.6M, CID: 1234, LAC: 5678, MCC: 0, MNC: 0, Pwr: -90"
|
||||
result = parse_grgsm_scanner_output(line)
|
||||
assert result is None
|
||||
|
||||
def test_cid_zero_valid_mcc_passes(self):
|
||||
"""Test that CID=0 with valid MCC/MNC passes (partially decoded cell)."""
|
||||
line = "ARFCN: 115, Freq: 958.0M, CID: 0, LAC: 21864, MCC: 234, MNC: 10, Pwr: -51"
|
||||
result = parse_grgsm_scanner_output(line)
|
||||
assert result is not None
|
||||
assert result['cid'] == 0
|
||||
assert result['mcc'] == 234
|
||||
assert result['signal_strength'] == -51.0
|
||||
|
||||
def test_valid_cid_nonzero(self):
|
||||
"""Test that valid non-zero CID/MCC entries pass through."""
|
||||
line = "ARFCN: 115, Freq: 925.0M, CID: 19088, LAC: 21864, MCC: 234, MNC: 10, Pwr: -58"
|
||||
|
||||
Reference in New Issue
Block a user