Skip to content

feat: --cell-kv machine-readable cell output + NR serving-cell fixes - #3

Merged
shark-fi merged 4 commits into
masterfrom
feat/cell-kv-output
Sep 4, 2026
Merged

shark-fi merged 4 commits into
masterfrom
feat/cell-kv-output

Conversation

@shark-fi

@shark-fi shark-fi commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Bring the --cell-kv machine-readable LTE/5G-NR cell measurement output into the fork's master (also open upstream as fgsect#150), including the NR serving-cell fixes:

  • --cell-kv flag: LTE+NR serving/neighbor cells as key=value lines, with a stateful RRC↔ML1 identity join.
  • NR SCell-Info version crash-safety — an unlisted rel_maj==0x03 version no longer NameErrors; logs the version + body instead.
  • NR scell 0xffff guard — don't emit an all-zero cell=scell row for a measured carrier the UE isn't camped on (serv_cell_pci == 0xffff); this was making SA-NR captures look like they had no TAC/CID. The real serving cell's identity join works (verified live: n25 PCI 796 → tac/cid).

103 tests pass.

shark-fi and others added 4 commits July 1, 2026 15:08
Add a --cell-kv flag (Qualcomm) that emits LTE and 5G-NR serving and
neighbor cell measurements as single-line key=value records for machine
parsing, instead of the human-readable stdout.

Each record has the form:

  pci=..,earfcn=..,earfcn_ul=..,frequency=..,protocol=lte|nr,cell=scell|ncell,
  plmn=..,mcc=..,mnc=..,tac=..,cid=..,band=..,bwmhzdl=..,bwmhzul=.. rssi=..,rsrp=..,rsrq=..

Details:
- util: dl_earfcn_to_frequency_hz() (3GPP TS 36.101 DL band table) and
  nrarfcn_to_frequency_hz() (TS 38.104 global raster) give center frequency
  in Hz; format_cell_kv()/format_plmn() build the record; real LTE UL-EARFCN
  via calculate_ul_earfcn().
- LTE (diagltelogparser) and NR (diagnrlogparser) serving and neighbor cell
  measurements emit the record; NR beam parsing is preserved (offsets still
  advance) but beams are not emitted as records.
- Stateful join: RRC SCell Info packets populate a per-radio serving-cell
  identity cache (plmn/mcc/mnc/tac/cid/band/bandwidth) that is merged onto the
  matching ML1 serving-cell measurement, guarded on (earfcn, pci) so stale
  identity is never attached to a different cell.

Default (no --cell-kv) output is unchanged; existing tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cover the util helpers (dl_earfcn_to_frequency_hz, nrarfcn_to_frequency_hz,
format_plmn, serving_identity_fields match-guard), LTE/NR serving and neighbor
cell key=value records, the RRC SCell Info -> serving-cell cache population,
and the stateful identity join (hit, mismatch-guard, and neighbor-not-enriched)
using existing real capture vectors. Also asserts default (no --cell-kv) output
is unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
parse_nr_rrc_scell_info handled versions 0.04 / 3.00 / 3.02 / 3.03, but a
rel_maj==0x03 packet with any other rel_min fell through the inner if/elif
with `item` never assigned and then crashed with NameError at the
nr_serving_cell assignment. Flatten the dispatch and add a single
`item is None` guard that logs the version + body and returns cleanly.

This unblocks NR serving-cell identity (TAC/CID/PLMN) for modems whose SCell
Info version isn't listed yet (e.g. the Quectel RG650 in the GL-E5800): the
warning now prints the exact version + raw bytes needed to add its struct,
instead of silently yielding empty NR identity in --cell-kv output.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… 0xffff)

On SA 5G the NR ML1 measurement reports one entry per measured carrier; a
carrier the UE isn't camped on reports serv_cell_pci == 0xffff. SCAT was
emitting an all-zero `protocol=nr,cell=scell` row for each of those
(pci=65535, tac=0, cid=0, rsrp=0), which drowned the real serving cell and
made NR captures look like they had no TAC/CID. The real serving cell's
identity join already works (verified live: n25 PCI 796 -> tac/cid populated
from RRC SCell Info).

Guard the scell kv-row on serv_cell_pci != 0xffff so only actual serving
cells are emitted; neighbors are unaffected. Adds a regression test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shark-fi
shark-fi merged commit 589cf6a into master Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant