diff --git a/AGENTS.md b/AGENTS.md index 316d237..32d1d41 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -14,7 +14,7 @@ Canonical branch: `main`. Sole remote: `origin` → `https://github.com/CERALIVE |-----------|----------|------| | `control/` | `@ceralive/modem-control` (npm) | TypeScript control library — domain model, ModemManager D-Bus backend, NetworkManager adapter, desired-state reconciler, injected admission/ownership/USB-hub ports, USB composition-mode model + evidence-bundle **ingestion seam**, data-usage sampler + the **usage-policy write surface**, capability-module **support-claim taxonomy + detection**, and the **band-lock** vocabulary + certification catalog (see §§ below). Published to public npm under `@ceralive` as **built ESM + `.d.ts`** across seven entry points (see § PUBLISHED PACKAGE SURFACE). | | `cli/` | `modem-control` (bench CLI) | The iteration surface: `probe`/`watch`/`apply`/`set-usb-mode`/`usage`/`certify`/`hil-cycle`, compiled `arm64`+`amd64`, run against real modems. Not published to npm. | -| `packaging/` | ModemManager stack `.deb`s **+ the first-party companion** | Trixie rebuilds of ModemManager + libmbim + libqmi + libqrtr-glib — packaging only, not a fork. libmbim/libqmi/libqrtr-glib remain source-unmodified; ModemManager carries exactly three owner-approved, BELABOX-derived FM350-GL patches, hardware-validated on the carrier-mediated USB topology after restoring the original `ATZ0` first-enable override (see `POLICY.md` and `docs/adr/ADR-FM350-RNDIS-BEARER.md`) — PLUS `ceralive-modem-support`, the `Architecture: all` first-party companion that owns CeraLive's generic modem system assets. | +| `packaging/` | ModemManager stack `.deb`s **+ the first-party companion** | Trixie rebuilds of ModemManager + libmbim + libqmi + libqrtr-glib — packaging only, not a fork. libmbim/libqmi/libqrtr-glib remain source-unmodified; ModemManager carries three owner-approved, BELABOX-derived FM350-GL patches, hardware-validated on the carrier-mediated USB topology after restoring the original `ATZ0` first-enable override (see `POLICY.md` and `docs/adr/ADR-FM350-RNDIS-BEARER.md`), plus one generic registration-parser fix on the openstreambox release line (`0004`, two-digit AcT values in `+CREG`/`+CGREG`/`+CEREG`) — PLUS `ceralive-modem-support`, the `Architecture: all` first-party companion that owns CeraLive's generic modem system assets. | `control/` + `cli/` are one **Bun** workspace. `packaging/` builds in a **trixie** container — the suite the device image runs; `build-stack.sh` refuses a container whose suite disagrees. @@ -1592,6 +1592,9 @@ own-number blocks in `control/src/redact.test.ts`. patch later is an architecture gate (rationale + filed upstream MR + review). The sole current exception is the exact three-patch BELABOX-derived FM350-GL series approved by the project owner on 2026-08-22; its MR is still drafted, not filed, and its hardware drill remains open. +The openstreambox release line additionally carries patch `0004` (two-digit AcT values in +`+CREG`/`+CGREG`/`+CEREG`) under a separate release-line waiver in `POLICY.md` §1; it is not +upstream yet. This narrow exception does not weaken the default that udev/plugin/device-support improvements go **upstream first**. The Phase A → Phase B scope boundary is **version-gated at `v1.0.0`**: CeraUI / device-image / apt integration is out of scope through `v0.2.0` and @@ -1640,8 +1643,8 @@ bun run verify:consumers # install the tarball into standalone Node 26 + Bun pr `packaging/` runs in a `debian:$TARGET_SUITE` container (default `trixie`); its contract/verification scripts live under `packaging/ci/`. The four sources' `debian/` recipes are checked in at `packaging//debian/` (`ModemManager`, `libmbim`, `libqmi`, `libqrtr-glib` — matching -their pinned salsa commits except the suite adaptations and the approved ModemManager -FM350-GL series documented in `packaging/SUITE-ADAPTATIONS.md`). +their pinned salsa commits except the suite adaptations and the ModemManager patch series +(the approved FM350-GL patches and the fork's `0004`) documented in `packaging/SUITE-ADAPTATIONS.md`). `packaging/ci/build-stack.sh ` (suite-parameterized: `TARGET_SUITE`, default `trixie`) rebuilds them from source in the mandatory bootstrap order (`libqrtr-glib → libmbim → libqmi → diff --git a/POLICY.md b/POLICY.md index 43cd070..a237100 100644 --- a/POLICY.md +++ b/POLICY.md @@ -35,11 +35,24 @@ the BELABOX author, originating commit SHA(s), rationale, and `Forwarded: no` st series is hardware-verified on the carrier-mediated USB topology and must be retired when upstream ships equivalent support. +**Fork release-line waiver, registration parser, 2026-11-25.** The openstreambox release line +(`osb/release/*`) also carries `0004-modem-helpers-accept-two-digit-act-in-creg.patch`: the +generic `+CREG`/`+CGREG`/`+CEREG` patterns accept the two-digit AcT values 10 to 13, without +which a modem that registers on 5G SA after ModemManager's registration attempt (the FM350-GL) +stays at `searching`. It is a second, separate waiver of §1, held by the openstreambox fork and +limited to its release line; it is not part of the CeraLive owner exception above, and `main` +does not carry it. Against §1: requirement 1 is the rationale in the ADR, section 2.4; +requirement 2 is **not met** (not offered upstream yet; the patch records `Forwarded: no`); +requirement 3 is an independent review of the change, with the fork owner's merge into the +release line as the sign-off. Until that merge the patch is not carried. It is retired when +upstream ModemManager accepts two-digit AcT values in these patterns. + ## 2. Upstream-contribution-first For anything that is genuinely a modem-support improvement — udev rules, ModemManager plugins, device quirks, port-type hints — **the contribution goes upstream first**, except -for the single dated FM350-GL owner exception recorded in §1. +for the dated FM350-GL owner exception and the openstreambox release-line waiver for patch +`0004`, both recorded in §1. - New device support, mode-switch quirks, and plugin changes are proposed to upstream ModemManager / the Debian packaging, not accreted as local carry. diff --git a/README.md b/README.md index f91a205..a78147d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ straight from CI artifacts; nothing is published to `apt.ceralive.tv` yet. |-----------|----------|------------| | [`control/`](control/) | **`@ceralive/modem-control`** (npm package) | The TypeScript control library: the [frozen v1.1 domain contracts](docs/DOMAIN-CONTRACTS.md), [provider registry and evidence-scored matcher](docs/PROVIDER-MATCHING.md), concrete typed-D-Bus [`ModemManagerProvider`](docs/MODEMMANAGER-PROVIDER.md) (runtime-discovered generic controls; no CLI subprocess), NetworkManager adapter, desired-state reconciler, injected mutation-admission and exclusive-ownership ports, USB composition-mode model + the [evidence-bundle ingestion seam](docs/CATALOG-INGESTION.md), data-usage sampler plus its `setUsagePolicy` write surface (`control/src/backend/usage/policy-write.ts` — a local 0600 policy file, because ModemManager exposes no data-usage API at all), and the **read-only SMS port** (`control/src/ports/sms.ts` + `control/src/sms/` — LIST/READ plus `Added`/`Deleted` observation, never a send or a delete, locked by `sms/readonly-gate.test.ts`). The USB-hub actuator is port-only here; the bench CLI owns its HIL adapter. Published to the public npm registry under the `@ceralive` scope as **built ESM + `.d.ts`** across seven entry points — see [`control/README.md`](control/README.md). | | [`cli/`](cli/) | **`modem-control`** (bench CLI) | The iteration surface: `probe`, `watch`, `apply`, `set-usb-mode`, `usage`, `certify`, `hil-cycle`. Compiled for `arm64` + `amd64` and run against real modems on a bench device to mature the package, capture per-SKU certification bundles, and prove hub VBUS port-cycling ([RB-10](docs/BENCH.md#rb-10--hub-vbus-verification-partial)). | -| [`packaging/`](packaging/) | **ModemManager stack `.deb`s** | Trixie rebuilds of ModemManager + libmbim + libqmi + libqrtr-glib — **packaging only, not a fork**. libmbim, libqmi, and libqrtr-glib remain source-unmodified; ModemManager carries one owner-approved, three-patch BELABOX-derived FM350-GL series, hardware-validated on the carrier-mounted USB composition after restoring BELABOX's `ATZ0` first-enable override (see [`POLICY.md`](POLICY.md) and the [ADR](docs/adr/ADR-FM350-RNDIS-BEARER.md)). Provenance-verified upstream pins; installed on the bench from CI artifacts. | +| [`packaging/`](packaging/) | **ModemManager stack `.deb`s** | Trixie rebuilds of ModemManager + libmbim + libqmi + libqrtr-glib — **packaging only, not a fork**. libmbim, libqmi, and libqrtr-glib remain source-unmodified; ModemManager carries one owner-approved, three-patch BELABOX-derived FM350-GL series, hardware-validated on the carrier-mounted USB composition after restoring BELABOX's `ATZ0` first-enable override (see [`POLICY.md`](POLICY.md) and the [ADR](docs/adr/ADR-FM350-RNDIS-BEARER.md)), plus one generic registration-parser fix on the openstreambox release line (`0004`, two-digit AcT values in `+CREG`/`+CGREG`/`+CEREG`). Provenance-verified upstream pins; installed on the bench from CI artifacts. | The control package's existing `./hardware` entry point also exposes transport-free SIM-presence and Huawei/ZTE/UFI response normalization. Device I/O, sessions, retries, diff --git a/docs/adr/ADR-FM350-RNDIS-BEARER.md b/docs/adr/ADR-FM350-RNDIS-BEARER.md index bf9a679..8f9ac57 100644 --- a/docs/adr/ADR-FM350-RNDIS-BEARER.md +++ b/docs/adr/ADR-FM350-RNDIS-BEARER.md @@ -140,6 +140,60 @@ T-Mobile and Verizon answers as captured (documentation-range addresses), the ol layout including a short mask, a bare address followed by a gateway, and a malformed line next to a good one. Hardware confirmation on T-Mobile is pending. +### 2.4 Follow-up: registration on 5G SA is missed after a replug (2026-11-25) + +After a replug on T-Mobile US 5G SA (n41, firmware `81600.0000.00.29.18.01`) the module +registered (`AT+CEREG?` read `2,1,…,11`, `+COPS` AcT 11), but ModemManager reported +`searching` for four minutes and sent no registration query in a 50 s debug capture. One +`mmcli -m --3gpp-register-home` made it read the registration, and the bearer connected +16 s later. + +The cause is in the generic layer, not in the `fm350gl` plugin, which overrides no 3GPP +registration step. The parser defect is confirmed from source and recorded answers; how it +played out in the field is inferred, because the capture holds no URC from the module: + +- The firmware reports 5GS registration through the legacy `+CREG`, `+CGREG` and `+CEREG` + with AcT 11 (NR connected to a 5GCN). Recorded answers, with synthetic TAC and cell id: + `+CREG: 2,1,"1F00","12345A00B",11`, `+CGREG: 2,1,"1F00","12345A00B",11,"FF"`, + `+CEREG: 2,1,"1F00","12345A00B",11`. While searching it answers + `+CEREG: 2,2,"FFFF","0FFFFFFF",0`. +- In `src/mm-modem-helpers.c` (`creg_regex[]`, entries 5, 6, 7, 9, 10 and 11) every pattern + that captures an AcT field accepts one digit only. So the searching answers (AcT 0) parse and + the registered ones (AcT 11) match nothing, URCs included. The only registered line that + parses is the solicited `+CGREG` with its trailing RAC, which falls through to the six-field + pattern 8; that is why any fresh poll (the nudge, or another one-shot check such as enabling + 3GPP location) reads the modem as registered. The AcT-to-access-technology mapping already + handles 10 to 13. Upstream main has the same one-digit AcT in these patterns. +- `+C5GREG` is not used for this module: 1.24.2's generic code enables only `+CREG`, `+CGREG` + and `+CEREG` reports, and since the module lists no 5G mode in `AT+WS46=?` + (`12,22,25,28,29,30,31`) it gets no 5GNR capability, so 5GS registration is never polled + either. That is harmless here because the firmware mirrors the registration into the legacy + reports. +- `src/mm-iface-modem-3gpp.c` starts periodic registration checks only when setting up or + enabling unsolicited registration reports fails. They succeed on this module. Without them, + the registration is read again only by event-driven checks: a registration attempt (every + 3 s, bounded, 60 s for a register request) or a one-shot check such as enabling 3GPP + location. Nothing schedules one while the modem sits at `searching`, so once the attempt + has ended the dropped URCs are the only signal, and a module that registers after that + stays at `searching` until something triggers a check. + +Patch `0004` accepts AcT 10 to 13, unpadded, in those six fields, and only where the line +has no competing reading: the AT port tries URC patterns in reverse order (handlers are +prepended) and responses in forward order, so a padded ``, a padded or two-digit cell id +or an unquoted RAC could otherwise pass for an AcT. In patterns 5, 9 and 10 the field after +`` must not be a (padded) digit; in pattern 7 the `` must not be a value 0 to 13. It also reads the `+CREG`/`+CGREG` `` as a TAC on NR, +so the three reports agree on the location. Tests in `src/tests/test-modem-helpers.c` cover the +module's layouts solicited and unsolicited, AcT 10 and 13, the radio-on sequence +(`2,4` → `2,2` → `2,1,…,11`), a searching-then-URC sequence (a plausible model of the field +event, built from the recorded answers in their 27.007 unsolicited form) and five layouts a +looser pattern misreads, each in both orders. Over the strings in the 1.24.2 tests plus a +generated set of about 52,000 `+CREG`/`+CGREG`/`+CEREG` lines (padded and unpadded fields, 4- to +6-field layouts), each parsed as response and as URC in both orders, no line that parsed +before changes its result, the set of order-dependent lines is the same as before, and every +newly parsed line carries an unpadded 10 to 13. There is +no hardware confirmation yet. Until a build with `0004` runs on a box, the field fallback stays +the `--3gpp-register-home` nudge above. + --- ## 3. Upstream 1.24 does not cover this device (POLICY §1.1 — "why a rebuild cannot") diff --git a/packaging/ModemManager/debian/patches/0004-modem-helpers-accept-two-digit-act-in-creg.patch b/packaging/ModemManager/debian/patches/0004-modem-helpers-accept-two-digit-act-in-creg.patch new file mode 100644 index 0000000..96ec881 --- /dev/null +++ b/packaging/ModemManager/debian/patches/0004-modem-helpers-accept-two-digit-act-in-creg.patch @@ -0,0 +1,540 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Paul Golmann +Date: Wed, 25 Nov 2026 07:38:14 +0100 +Subject: [PATCH] modem-helpers: accept two-digit AcT values in +CREG, +CGREG + and +CEREG + +Description: Accept two-digit AcT values in +CREG, +CGREG and +CEREG + The registration patterns only accepted a one-digit AcT field, so AcT 10-13 + (5G core and NR) lines matched nothing. A modem that registers on 5G SA after + ModemManager's registration attempt has stopped polling stays in 'searching', + because its registered URCs are dropped and no periodic check runs while + unsolicited registration reports are enabled. Only the unpadded values 10-13 + are added, and only where the line has no competing reading, so every line + that parsed before parses the same way. Also reads the +CREG/+CGREG as + a TAC on NR. + . + Not offered upstream yet. The same change applies to upstream main, which + still accepts one AcT digit in these patterns. +Author: Paul Golmann +Forwarded: no +Last-Update: 2026-11-25 + +27.007 defines AcT 10 (E-UTRA connected to a 5GCN), 11 (NR connected to a +5GCN), 12 (NG-RAN) and 13 (E-UTRA-NR dual connectivity), and +get_mm_access_tech_from_etsi_access_tech() already maps them. The +CREG, ++CGREG and +CEREG patterns that carry an AcT field only accept one digit +there, so a line such as + + +CEREG: 1,"1F00","12345A00B",11 + +matches none of them. Only +C5GREG and the six-field +CGREG layout with a +trailing RAC accepted two digits. + +The Fibocom FM350-GL reports its 5G SA registration this way. Its +searching answers (AcT 0) parse and its registered ones (AcT 11) don't, +so registered URCs are dropped. Periodic registration checks only run +when unsolicited reports can't be enabled, so once ModemManager's own +registration attempt has stopped polling, nothing reads the registration +again. After a replug on a US 5G SA network the module had registered on +NR while ModemManager reported 'searching' for four minutes; one +--3gpp-register-home made it read the registration. + +Accept the four two-digit values, unpadded, in the AcT field of those +patterns, and only where the line can't also be read in a competing +layout: the AT port tries the URC patterns in reverse order and the +responses in forward order, so a padded , a padded or two-digit +cell id or an unquoted RAC could otherwise pass for an AcT. In [5], [9] +and [10] the field after must not be a (padded) digit; in [7] the + must not be a value 0 to 13. Every line that parsed before parses +the same way in both orders. +Also take the of +CREG and +CGREG as a TAC on NR, where there are +no location areas, so the three reports agree on the TAC. + +The tests cover the FM350-GL layouts (quoted TAC, 36-bit NR cell id, the +RAC field in +CGREG), AcT 10 and 13, two replayed sequences and five +layouts a looser pattern would misread, each in forward order and in the +reverse order the AT port tries URC handlers. TAC and cell id values are +synthetic. +--- + src/mm-broadband-modem.c | 18 +- + src/mm-modem-helpers.c | 38 +++- + src/mm-modem-helpers.h | 5 + + src/tests/test-modem-helpers.c | 314 +++++++++++++++++++++++++++++++++ + 4 files changed, 365 insertions(+), 10 deletions(-) + +diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c +index c14bce3f..e561008b 100644 +--- a/src/mm-broadband-modem.c ++++ b/src/mm-broadband-modem.c +@@ -5259,10 +5259,15 @@ registration_state_changed (MMPortSerialAt *port, + * According to 3GPP TS 27.007: + * - If CREG reports 7 (LTE) then the field contains TAC + * - CEREG/C5GREG always reports TAC ++ * - On NR, CREG/CGREG report the TAC in the field + */ +- if (cgreg) ++ if (cgreg) { ++ if (mm_3gpp_creg_lac_is_tac (TRUE, act)) { ++ tac = lac; ++ lac = 0; ++ } + mm_iface_modem_3gpp_update_ps_registration_state (MM_IFACE_MODEM_3GPP (self), state, FALSE); +- else if (cereg) { ++ } else if (cereg) { + tac = lac; + lac = 0; + mm_iface_modem_3gpp_update_eps_registration_state (MM_IFACE_MODEM_3GPP (self), state, FALSE); +@@ -5271,7 +5276,7 @@ registration_state_changed (MMPortSerialAt *port, + lac = 0; + mm_iface_modem_3gpp_update_5gs_registration_state (MM_IFACE_MODEM_3GPP (self), state, FALSE); + } else { +- if (act == MM_MODEM_ACCESS_TECHNOLOGY_LTE) { ++ if (mm_3gpp_creg_lac_is_tac (FALSE, act)) { + tac = lac; + lac = 0; + } +@@ -5717,8 +5722,13 @@ registration_status_check_ready (MMBroadbandModem *self, + * According to 3GPP TS 27.007: + * - If CREG reports 7 (LTE) then the field contains TAC + * - CEREG always reports TAC ++ * - On NR, CREG/CGREG report the TAC in the field + */ + if (cgreg) { ++ if (mm_3gpp_creg_lac_is_tac (TRUE, act)) { ++ tac = lac; ++ lac = 0; ++ } + if (ctx->running_cs) + mm_obj_dbg (self, "got PS registration state when checking CS registration state"); + else if (ctx->running_eps) +@@ -5747,7 +5757,7 @@ registration_status_check_ready (MMBroadbandModem *self, + mm_obj_dbg (self, "got 5GS registration state when checking EPS registration state"); + mm_iface_modem_3gpp_update_5gs_registration_state (MM_IFACE_MODEM_3GPP (self), state, FALSE); + } else { +- if (act == MM_MODEM_ACCESS_TECHNOLOGY_LTE) { ++ if (mm_3gpp_creg_lac_is_tac (FALSE, act)) { + tac = lac; + lac = 0; + } +diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c +index 8687196e..508457ff 100644 +--- a/src/mm-modem-helpers.c ++++ b/src/mm-modem-helpers.c +@@ -851,6 +851,18 @@ mm_modem_3gpp_registration_state_is_registered (MMModem3gppRegistrationState sta + + /*************************************************************************/ + ++/* The field may take two digits: 27.007 defines 10 (E-UTRA connected to ++ * a 5GCN), 11 (NR connected to a 5GCN), 12 (NG-RAN) and 13 (E-UTRA-NR dual ++ * connectivity), which modems on 5G standalone networks report in +CREG, ++ * +CGREG and +CEREG as well as in +C5GREG. Only those four values are ++ * accepted as two digits, without zero padding, and only where the line can't ++ * also be read in a competing layout, since the AT port tries the URC ++ * patterns in reverse order and the responses in forward order: ++ * - in [5], [9] and [10] the field after must not be a (padded) ++ * digit, which would make it the of [3] or [7]; ++ * - in [7] the must not be a value 0 to 13, which would make it the ++ * of [9] ("+CGREG: 1,0005,2816,3,11" keeps matching [9]). ++ * Lines that match neither way keep their one-digit parse or no parse. */ + static const gchar *creg_regex[] = { + /* +CREG: (GSM 07.07 CREG=1 unsolicited) */ + [0] = "\\+(CREG|CGREG|CEREG|C5GREG):\\s*0*([0-9])", +@@ -862,19 +874,19 @@ static const gchar *creg_regex[] = { + [3] = "\\+(CREG|CGREG|CEREG):\\s*([0-9]),\\s*([0-9])\\s*,\\s*([^,]*)\\s*,\\s*([^,\\s]*)", + [4] = "\\+(CREG|CGREG|CEREG):\\s*0*([0-9]),\\s*0*([0-9])\\s*,\\s*(\"[^,]*\")\\s*,\\s*(\"[^,\\s]*\")", + /* +CREG: ,,, (ETSI 27.007 CREG=2 unsolicited) */ +- [5] = "\\+(CREG|CGREG|CEREG):\\s*([0-9])\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([0-9])", +- [6] = "\\+(CREG|CGREG|CEREG):\\s*0*([0-9])\\s*,\\s*(\"[^,\\s]*\")\\s*,\\s*(\"[^,\\s]*\")\\s*,\\s*0*([0-9])", ++ [5] = "\\+(CREG|CGREG|CEREG):\\s*([0-9])\\s*,\\s*(?|([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([0-9])|(?!0*[0-9]\\s*,)([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(1[0-3]))", ++ [6] = "\\+(CREG|CGREG|CEREG):\\s*0*([0-9])\\s*,\\s*(\"[^,\\s]*\")\\s*,\\s*(\"[^,\\s]*\")\\s*,\\s*(?|0*([0-9])|(1[0-3]))", + /* +CREG: ,,,, (ETSI 27.007 solicited and some CREG=2 unsolicited) */ +- [7] = "\\+(CREG|CGREG|CEREG):\\s*0*([0-9]),\\s*0*([0-9])\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*0*([0-9])", ++ [7] = "\\+(CREG|CGREG|CEREG):\\s*0*([0-9]),\\s*(?|0*([0-9])\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*0*([0-9])|0*([0-9])\\s*,\\s*([^,\\s]*)\\s*,\\s*(?!(?:0*[0-9]|1[0-3])\\s*,)([^,\\s]*)\\s*,\\s*(1[0-3]))", + /* +CREG: ,,,,, (Samsung Wave S8500) */ + /* '+CREG: 2,1,000B,2816, B, C2816OK' */ + [8] = "\\+(CREG|CGREG):\\s*0*([0-9]),\\s*0*([0-9])\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*[^,\\s]*", + /* +CREG: ,,,, (ETSI 27.007 v9.20 CREG=2 unsolicited with RAC) */ +- [9] = "\\+(CREG|CGREG):\\s*0*([0-9])\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*0*([0-9])\\s*,\\s*([^,\\s]*)", ++ [9] = "\\+(CREG|CGREG):\\s*0*([0-9])\\s*,\\s*(?|([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*0*([0-9])|(?!0*[0-9]\\s*,)([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(1[0-3]))\\s*,\\s*([^,\\s]*)", + /* +CEREG: ,,,, (ETSI 27.007 v8.6 CREG=2 unsolicited with RAC) */ +- [10] = "\\+(CEREG):\\s*0*([0-9])\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*0*([0-9])", ++ [10] = "\\+(CEREG):\\s*0*([0-9])\\s*,\\s*(?|([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*0*([0-9])|(?!0*[0-9]\\s*,)([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(1[0-3]))", + /* +CEREG: ,,,,, (ETSI 27.007 v8.6 CREG=2 solicited with RAC) */ +- [11] = "\\+(CEREG):\\s*0*([0-9]),\\s*0*([0-9])\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*0*([0-9])", ++ [11] = "\\+(CEREG):\\s*0*([0-9]),\\s*0*([0-9])\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(?|0*([0-9])|(1[0-3]))", + /* +C5GREG: ,,,,, (ETSI 27.007 CREG=2 unsolicited) */ + [12] = "\\+(C5GREG):\\s*([0-9]+)\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([0-9]+)\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)", + /* +C5GREG: ,,,,,, (ETSI 27.007 solicited) */ +@@ -2169,6 +2181,20 @@ mm_3gpp_parse_creg_response (GMatchInfo *info, + + /*************************************************************************/ + ++gboolean ++mm_3gpp_creg_lac_is_tac (gboolean cgreg, ++ MMModemAccessTechnology act) ++{ ++ /* 27.007: the +CREG holds the TAC when is E-UTRAN or NR. ++ * NR has no location areas at all, so a +CGREG reported on NR ++ * (AcT 11 to 13) is a TAC as well. */ ++ if (act & MM_MODEM_ACCESS_TECHNOLOGY_5GNR) ++ return TRUE; ++ return (!cgreg && act == MM_MODEM_ACCESS_TECHNOLOGY_LTE); ++} ++ ++/*************************************************************************/ ++ + #define CMGF_TAG "+CMGF:" + + gboolean +diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h +index 133c7006..8f3bec1b 100644 +--- a/src/mm-modem-helpers.h ++++ b/src/mm-modem-helpers.h +@@ -225,6 +225,11 @@ gboolean mm_3gpp_parse_creg_response (GMatchInfo *info, + gboolean *out_c5greg, + GError **error); + ++/* Whether the of a +CREG (cgreg FALSE) or +CGREG (cgreg TRUE) answer ++ * holds a TAC, given the access technology parsed from it */ ++gboolean mm_3gpp_creg_lac_is_tac (gboolean cgreg, ++ MMModemAccessTechnology act); ++ + /* AT+CMGF=? (SMS message format) response parser */ + gboolean mm_3gpp_parse_cmgf_test_response (const gchar *reply, + gboolean *sms_pdu_supported, +diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c +index b4dcda2b..5027da93 100644 +--- a/src/tests/test-modem-helpers.c ++++ b/src/tests/test-modem-helpers.c +@@ -1638,6 +1638,305 @@ test_c5greg2_unsolicited (void *f, gpointer d) + test_creg_match ("C5GREG=2", FALSE, reply, data, &result); + } + ++/* ++ * 27.007 AcT values 10 to 13 (E-UTRA connected to a 5GCN, NR connected to a ++ * 5GCN, NG-RAN, E-UTRA-NR dual connectivity) take two digits. Modems on a 5G ++ * standalone network report them in +CREG, +CGREG and +CEREG, e.g. the ++ * Fibocom FM350-GL. TAC and cell ID values below are synthetic; the layout, ++ * the 36-bit NR cell ID and the trailing "FF" RAC in +CGREG are as the module ++ * sends them. ++ */ ++ ++static void ++test_creg2_5gsa_solicited (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const char *reply = "+CREG: 2,1,\"1F00\",\"12345A00B\",11"; ++ const CregResult result = { MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, (gulong) G_GUINT64_CONSTANT (0x12345A00B), MM_MODEM_ACCESS_TECHNOLOGY_5GNR, 7, FALSE, FALSE, FALSE }; ++ ++ test_creg_match ("FM350-GL CREG=2 on 5G SA", TRUE, reply, data, &result); ++} ++ ++static void ++test_creg2_5gsa_unsolicited (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const char *reply = "\r\n+CREG: 1,\"1F00\",\"12345A00B\",11\r\n"; ++ const CregResult result = { MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, (gulong) G_GUINT64_CONSTANT (0x12345A00B), MM_MODEM_ACCESS_TECHNOLOGY_5GNR, 5, FALSE, FALSE, FALSE }; ++ ++ test_creg_match ("FM350-GL CREG=2 on 5G SA", FALSE, reply, data, &result); ++} ++ ++static void ++test_cgreg2_5gsa_solicited (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const char *reply = "+CGREG: 2,1,\"1F00\",\"12345A00B\",11,\"FF\""; ++ const CregResult result = { MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, (gulong) G_GUINT64_CONSTANT (0x12345A00B), MM_MODEM_ACCESS_TECHNOLOGY_5GNR, 8, TRUE, FALSE, FALSE }; ++ ++ test_creg_match ("FM350-GL CGREG=2 on 5G SA", TRUE, reply, data, &result); ++} ++ ++static void ++test_cgreg2_5gsa_unsolicited (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const char *reply = "\r\n+CGREG: 1,\"1F00\",\"12345A00B\",11,\"FF\"\r\n"; ++ const CregResult result = { MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, (gulong) G_GUINT64_CONSTANT (0x12345A00B), MM_MODEM_ACCESS_TECHNOLOGY_5GNR, 9, TRUE, FALSE, FALSE }; ++ ++ test_creg_match ("FM350-GL CGREG=2 on 5G SA", FALSE, reply, data, &result); ++} ++ ++static void ++test_cereg2_5gsa_solicited (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const char *reply = "+CEREG: 2,1,\"1F00\",\"12345A00B\",11"; ++ const CregResult result = { MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, (gulong) G_GUINT64_CONSTANT (0x12345A00B), MM_MODEM_ACCESS_TECHNOLOGY_5GNR, 7, FALSE, TRUE, FALSE }; ++ ++ test_creg_match ("FM350-GL CEREG=2 on 5G SA", TRUE, reply, data, &result); ++} ++ ++static void ++test_cereg2_5gsa_unsolicited (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const char *reply = "\r\n+CEREG: 1,\"1F00\",\"12345A00B\",11\r\n"; ++ const CregResult result = { MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, (gulong) G_GUINT64_CONSTANT (0x12345A00B), MM_MODEM_ACCESS_TECHNOLOGY_5GNR, 5, FALSE, TRUE, FALSE }; ++ ++ test_creg_match ("FM350-GL CEREG=2 on 5G SA", FALSE, reply, data, &result); ++} ++ ++static void ++test_cereg2_searching_solicited (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const char *reply = "+CEREG: 2,2,\"FFFF\",\"0FFFFFFF\",0"; ++ const CregResult result = { MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, 0xFFFF, 0x0FFFFFFF, MM_MODEM_ACCESS_TECHNOLOGY_GSM, 7, FALSE, TRUE, FALSE }; ++ ++ test_creg_match ("FM350-GL CEREG=2 while searching", TRUE, reply, data, &result); ++} ++ ++static void ++test_cereg2_eutra_5gcn_unsolicited (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const char *reply = "\r\n+CEREG: 5,\"1F00\",\"79D903\",10\r\n"; ++ const CregResult result = { MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING, 0x1F00, 0x79D903, MM_MODEM_ACCESS_TECHNOLOGY_LTE, 5, FALSE, TRUE, FALSE }; ++ ++ test_creg_match ("CEREG=2 on E-UTRA connected to a 5GCN", FALSE, reply, data, &result); ++} ++ ++static void ++test_cereg2_endc_rac_unsolicited (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const char *reply = "\r\n+CEREG: 1, 1F00, 20 ,79D903 ,13\r\n"; ++ const CregResult result = { MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, 0x79D903, MM_MODEM_ACCESS_TECHNOLOGY_LTE | MM_MODEM_ACCESS_TECHNOLOGY_5GNR, 10, FALSE, TRUE, FALSE }; ++ ++ test_creg_match ("CEREG=2 with RAC on E-UTRA-NR dual connectivity", FALSE, reply, data, &result); ++} ++ ++/* ++ * Replays what ModemManager reads from an FM350-GL around a 5G SA ++ * registration, and checks that the last line leaves it registered. Before ++ * two-digit AcT values were accepted, every registered line of the module ++ * failed to match while the searching ones matched, so a modem that was ++ * still searching when the unsolicited reports were enabled stayed in ++ * 'searching' for good: the registered URCs were dropped and no periodic ++ * registration check runs once unsolicited reports are enabled. ++ */ ++ ++typedef struct { ++ gboolean solicited; ++ const gchar *line; ++} CregReplayStep; ++ ++/* The AT port tries unsolicited handlers in the reverse order of their ++ * registration (each new one is prepended), so URCs meet the regex array ++ * from its end. Check both orders. */ ++static gboolean ++creg_parse_in_order (RegTestData *data, ++ gboolean solicited, ++ gboolean reverse, ++ const gchar *line, ++ MMModem3gppRegistrationState *out_state, ++ gulong *out_lac, ++ gulong *out_ci, ++ MMModemAccessTechnology *out_act) ++{ ++ g_autoptr(GMatchInfo) info = NULL; ++ g_autoptr(GError) error = NULL; ++ GPtrArray *array; ++ guint i; ++ gboolean cgreg = FALSE; ++ gboolean cereg = FALSE; ++ gboolean c5greg = FALSE; ++ ++ array = solicited ? data->solicited_creg : data->unsolicited_creg; ++ for (i = 0; i < array->len; i++) { ++ guint j = reverse ? array->len - 1 - i : i; ++ ++ if (g_regex_match (g_ptr_array_index (array, j), line, 0, &info)) ++ break; ++ g_clear_pointer (&info, g_match_info_free); ++ } ++ if (!info) ++ return FALSE; ++ ++ g_assert_true (mm_3gpp_parse_creg_response (info, NULL, out_state, out_lac, out_ci, out_act, &cgreg, &cereg, &c5greg, &error)); ++ g_assert_no_error (error); ++ return TRUE; ++} ++ ++static void ++test_creg_both_orders (RegTestData *data, ++ gboolean solicited, ++ const gchar *line, ++ MMModem3gppRegistrationState state, ++ gulong lac, ++ gulong ci, ++ MMModemAccessTechnology act) ++{ ++ guint reverse; ++ ++ for (reverse = 0; reverse < 2; reverse++) { ++ MMModem3gppRegistrationState parsed_state = MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN; ++ MMModemAccessTechnology parsed_act = MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN; ++ gulong parsed_lac = 0; ++ gulong parsed_ci = 0; ++ ++ g_debug ("Testing '%s' in %s order...", line, reverse ? "reverse" : "forward"); ++ g_assert_true (creg_parse_in_order (data, solicited, reverse, line, &parsed_state, &parsed_lac, &parsed_ci, &parsed_act)); ++ g_assert_cmpuint (parsed_state, ==, state); ++ g_assert_cmpuint (parsed_lac, ==, lac); ++ g_assert_cmpuint (parsed_ci, ==, ci); ++ g_assert_cmpuint (parsed_act, ==, act); ++ } ++} ++ ++static void ++replay_creg_sequence (RegTestData *data, ++ const CregReplayStep *steps, ++ guint n_steps, ++ gboolean reverse, ++ MMModem3gppRegistrationState *out_state, ++ MMModemAccessTechnology *out_act) ++{ ++ guint i; ++ ++ for (i = 0; i < n_steps; i++) { ++ gulong lac = 0; ++ gulong ci = 0; ++ ++ g_debug ("Replaying %s '%s'...", steps[i].solicited ? "response" : "URC", steps[i].line); ++ g_assert_true (creg_parse_in_order (data, steps[i].solicited, reverse, steps[i].line, out_state, &lac, &ci, out_act)); ++ } ++} ++ ++static void ++test_creg_5gsa_radio_on_sequence (void *f, gpointer d) ++{ ++ /* Polled answers after AT+CFUN=1, in the order the module gave them */ ++ static const CregReplayStep steps[] = { ++ { TRUE, "+CEREG: 2,4,\"FFFF\",\"0FFFFFFF\",0" }, ++ { TRUE, "+CEREG: 2,2,\"FFFF\",\"0FFFFFFF\",0" }, ++ { TRUE, "+CEREG: 2,2,\"FFFF\",\"0FFFFFFF\",0" }, ++ { TRUE, "+CEREG: 2,1,\"1F00\",\"12345A00B\",11" }, ++ }; ++ guint reverse; ++ ++ for (reverse = 0; reverse < 2; reverse++) { ++ MMModem3gppRegistrationState state = MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN; ++ MMModemAccessTechnology act = MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN; ++ ++ replay_creg_sequence ((RegTestData *) d, steps, G_N_ELEMENTS (steps), reverse, &state, &act); ++ g_assert_cmpuint (state, ==, MM_MODEM_3GPP_REGISTRATION_STATE_HOME); ++ g_assert_cmpuint (act, ==, MM_MODEM_ACCESS_TECHNOLOGY_5GNR); ++ } ++} ++ ++static void ++test_creg_5gsa_registered_after_enable_sequence (void *f, gpointer d) ++{ ++ /* Searching at the initial registration check, then registered on NR ++ * reported by URCs only */ ++ static const CregReplayStep steps[] = { ++ { TRUE, "+CREG: 2,2" }, ++ { TRUE, "+CGREG: 2,2" }, ++ { TRUE, "+CEREG: 2,2,\"FFFF\",\"0FFFFFFF\",0" }, ++ { FALSE, "\r\n+CREG: 1,\"1F00\",\"12345A00B\",11\r\n" }, ++ { FALSE, "\r\n+CGREG: 1,\"1F00\",\"12345A00B\",11,\"FF\"\r\n" }, ++ { FALSE, "\r\n+CEREG: 1,\"1F00\",\"12345A00B\",11\r\n" }, ++ }; ++ guint reverse; ++ ++ for (reverse = 0; reverse < 2; reverse++) { ++ MMModem3gppRegistrationState state = MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN; ++ MMModemAccessTechnology act = MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN; ++ ++ replay_creg_sequence ((RegTestData *) d, steps, G_N_ELEMENTS (steps), reverse, &state, &act); ++ g_assert_cmpuint (state, ==, MM_MODEM_3GPP_REGISTRATION_STATE_HOME); ++ g_assert_cmpuint (act, ==, MM_MODEM_ACCESS_TECHNOLOGY_5GNR); ++ } ++} ++ ++static void ++test_creg_5gsa_urcs_both_orders (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ const gulong ci = (gulong) G_GUINT64_CONSTANT (0x12345A00B); ++ ++ test_creg_both_orders (data, FALSE, "\r\n+CREG: 1,\"1F00\",\"12345A00B\",11\r\n", ++ MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, ci, MM_MODEM_ACCESS_TECHNOLOGY_5GNR); ++ test_creg_both_orders (data, FALSE, "\r\n+CGREG: 1,\"1F00\",\"12345A00B\",11,\"FF\"\r\n", ++ MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, ci, MM_MODEM_ACCESS_TECHNOLOGY_5GNR); ++ test_creg_both_orders (data, FALSE, "\r\n+CEREG: 1,\"1F00\",\"12345A00B\",11\r\n", ++ MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, ci, MM_MODEM_ACCESS_TECHNOLOGY_5GNR); ++ test_creg_both_orders (data, TRUE, "+CEREG: 2,1,\"1F00\",\"12345A00B\",11", ++ MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, ci, MM_MODEM_ACCESS_TECHNOLOGY_5GNR); ++} ++ ++/* Layouts that a looser two-digit AcT would misread: a padded next to a ++ * padded or two-digit cell id, an unquoted two-digit RAC after a padded LAC, ++ * and a padded before a two-digit AcT. Each must keep the parse it had ++ * with one-digit AcT patterns, or get the right one, in either order. */ ++static void ++test_creg_two_digit_act_no_collision (void *f, gpointer d) ++{ ++ RegTestData *data = (RegTestData *) d; ++ ++ /* ,,,, sent as a URC */ ++ test_creg_both_orders (data, FALSE, "\r\n+CGREG: 2,05,000B,0011,3\r\n", ++ MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING, 0x000B, 0x0011, MM_MODEM_ACCESS_TECHNOLOGY_EDGE); ++ /* ,,,, sent as a response */ ++ test_creg_both_orders (data, TRUE, "+CGREG: 1,0005,2816,3,11", ++ MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x0005, 0x2816, MM_MODEM_ACCESS_TECHNOLOGY_EDGE); ++ /* ,,, with a padded cell id that is not an AcT */ ++ test_creg_both_orders (data, FALSE, "\r\n+CREG: 2,1,0001,0010\r\n", ++ MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x0001, 0x0010, MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN); ++ /* ,,,, with a padded and an unpadded cell id 11 */ ++ test_creg_both_orders (data, FALSE, "\r\n+CGREG: 2,05,000B,11,3\r\n", ++ MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING, 0x000B, 0x11, MM_MODEM_ACCESS_TECHNOLOGY_EDGE); ++ /* A padded before a two-digit AcT is still a , not a TAC */ ++ test_creg_both_orders (data, TRUE, "+CEREG: 2,01,\"1F00\",\"12345A00B\",11", ++ MM_MODEM_3GPP_REGISTRATION_STATE_HOME, 0x1F00, (gulong) G_GUINT64_CONSTANT (0x12345A00B), MM_MODEM_ACCESS_TECHNOLOGY_5GNR); ++} ++ ++static void ++test_creg_lac_is_tac (void *f, gpointer d) ++{ ++ g_assert_false (mm_3gpp_creg_lac_is_tac (FALSE, MM_MODEM_ACCESS_TECHNOLOGY_UMTS)); ++ g_assert_true (mm_3gpp_creg_lac_is_tac (FALSE, MM_MODEM_ACCESS_TECHNOLOGY_LTE)); ++ g_assert_true (mm_3gpp_creg_lac_is_tac (FALSE, MM_MODEM_ACCESS_TECHNOLOGY_5GNR)); ++ g_assert_true (mm_3gpp_creg_lac_is_tac (FALSE, MM_MODEM_ACCESS_TECHNOLOGY_LTE | MM_MODEM_ACCESS_TECHNOLOGY_5GNR)); ++ /* +CGREG keeps its LAC on E-UTRAN, as before; on NR there is only a TAC */ ++ g_assert_false (mm_3gpp_creg_lac_is_tac (TRUE, MM_MODEM_ACCESS_TECHNOLOGY_LTE)); ++ g_assert_false (mm_3gpp_creg_lac_is_tac (TRUE, MM_MODEM_ACCESS_TECHNOLOGY_EDGE)); ++ g_assert_true (mm_3gpp_creg_lac_is_tac (TRUE, MM_MODEM_ACCESS_TECHNOLOGY_5GNR)); ++ g_assert_true (mm_3gpp_creg_lac_is_tac (TRUE, MM_MODEM_ACCESS_TECHNOLOGY_LTE | MM_MODEM_ACCESS_TECHNOLOGY_5GNR)); ++} ++ + /*****************************************************************************/ + /* Test CSCS responses */ + +@@ -5019,6 +5318,21 @@ int main (int argc, char **argv) + g_test_suite_add (suite, TESTCASE (test_c5greg2_solicited, reg_data)); + g_test_suite_add (suite, TESTCASE (test_c5greg2_unsolicited, reg_data)); + ++ g_test_suite_add (suite, TESTCASE (test_creg2_5gsa_solicited, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_creg2_5gsa_unsolicited, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_cgreg2_5gsa_solicited, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_cgreg2_5gsa_unsolicited, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_cereg2_5gsa_solicited, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_cereg2_5gsa_unsolicited, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_cereg2_searching_solicited, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_cereg2_eutra_5gcn_unsolicited, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_cereg2_endc_rac_unsolicited, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_creg_5gsa_radio_on_sequence, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_creg_5gsa_registered_after_enable_sequence, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_creg_5gsa_urcs_both_orders, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_creg_two_digit_act_no_collision, reg_data)); ++ g_test_suite_add (suite, TESTCASE (test_creg_lac_is_tac, NULL)); ++ + g_test_suite_add (suite, TESTCASE (test_creg_cgreg_multi_unsolicited, reg_data)); + g_test_suite_add (suite, TESTCASE (test_creg_cgreg_multi2_unsolicited, reg_data)); + +-- +2.53.0 + diff --git a/packaging/ModemManager/debian/patches/series b/packaging/ModemManager/debian/patches/series index b6dede5..ab67418 100644 --- a/packaging/ModemManager/debian/patches/series +++ b/packaging/ModemManager/debian/patches/series @@ -1,3 +1,4 @@ 0001-fm350gl-forward-port-rndis-bearer-and-modes.patch 0002-fm350gl-disable-crashing-cpol-commands.patch 0003-fm350gl-accept-extended-cops-scan-format.patch +0004-modem-helpers-accept-two-digit-act-in-creg.patch diff --git a/packaging/README.md b/packaging/README.md index 1cf2d12..1fdded4 100644 --- a/packaging/README.md +++ b/packaging/README.md @@ -11,7 +11,7 @@ publication is part of Phase B adoption, authorized from the `v1.0.0` release ta ## Sources (4 upstream rebuilds + 1 first-party companion) The four sources below remain pinned upstream rebuilds. Three carry no source patch; -ModemManager carries only the reviewed FM350-GL series described below. The first-party +ModemManager carries only the reviewed FM350-GL series and the registration-parser fix described below. The first-party [`ceralive-modem-support`](ceralive-modem-support/) companion keeps CeraLive-owned generic system assets out of every upstream recipe — see [First-party companion](#first-party-companion-ceralive-modem-support). @@ -41,9 +41,9 @@ re-verified end-to-end by [`ci/verify-upstream-pins.sh`](ci/verify-upstream-pins Each source's `debian/` dir is checked in at `/debian/` (`ModemManager`, `libmbim`, `libqmi`, `libqrtr-glib`), based on its pinned salsa commit ([`upstream-pins.yaml`](upstream-pins.yaml) `salsa_commit_sha`). libmbim, libqmi, and -libqrtr-glib carry no source patches. ModemManager adds only the three entries in -`ModemManager/debian/patches/series`, each attributed to exact BELABOX commits and governed -by the accepted FM350 ADR. +libqrtr-glib carry no source patches. ModemManager adds only the four entries in +`ModemManager/debian/patches/series`: three attributed to exact BELABOX commits and governed +by the accepted FM350 ADR, and the fork's generic registration-parser fix `0004`. All four sources carry one shared suite adaptation — the GObject-introspection build-deps are swapped from the sid GI-1.80 set (`gir1.2-*-2.0-dev` + `gobject-introspection (>= 1.80)`) to the older `gobject-introspection` + `libgirepository1.0-dev` spelling, which remains a real @@ -54,8 +54,8 @@ documented, with rationale, per-suite re-measurement, and diff shape, in ### Approved ModemManager source series -`ModemManager/debian/patches/series` is intentionally non-empty and contains exactly three -logical changes: the 1.24-native FM350-GL RNDIS bearer plus `+GTACT` mode support, the CPOL +`ModemManager/debian/patches/series` is intentionally non-empty. Its first three entries are +the approved FM350-GL logical changes: the 1.24-native FM350-GL RNDIS bearer plus `+GTACT` mode support, the CPOL crash-disable device row, and the standalone extended-`+COPS` parser fix with its regression test. Each DEP-3-style header credits `rationalsa `, names the exact BELABOX origin SHA(s), and records `Forwarded: no` because the upstream MR is drafted but not @@ -64,6 +64,17 @@ is build-tested and hardware-validated on the carrier-mediated USB topology; no claim exists until the production-topology board drill proves plugin binding, bearer activation, and routable IPv4. +The fourth entry, `0004-modem-helpers-accept-two-digit-act-in-creg.patch`, is a generic +ModemManager fix carried on the openstreambox release line: the `+CREG`/`+CGREG`/`+CEREG` +patterns accept the two-digit AcT values 10 to 13 (5G core and NR) where a line has no +competing reading, and the `+CREG`/`+CGREG` +`` is read as a TAC on NR. Without it a modem that registers on 5G SA after +ModemManager's registration attempt has stopped polling, such as the FM350-GL, stays at +`searching`. It is authored for this fork, records `Forwarded: no` (not offered upstream yet), +and is covered by replay and collision tests in `src/tests/test-modem-helpers.c`, run in both +the forward order and the reverse order the AT port tries URC handlers. See the ADR, +section 2.4, and the fork carry in `POLICY.md` §1. + [`ci/build-stack.sh`](ci/build-stack.sh) `` rebuilds the **selected** sources in a `debian:$TARGET_SUITE` container (default `trixie`) in the mandatory bootstrap order `libqrtr-glib → libmbim → libqmi → modemmanager`. Each source's freshly built `.deb`s feed a @@ -293,6 +304,6 @@ closed naming that source. The migration-continuity chain | [`ci/suffix-contract.sh`](ci/suffix-contract.sh) | SOURCED library — the `~ceralive` suffix contract in ONE place. `assert_group_coherence =…` groups packages by owning source (derived from `expected-packages.txt`, never a second frozen list) and asserts each source's OWN internal coherence, so differing counters ACROSS sources pass while a source disagreeing with itself fails closed naming it. `prove_chain_ordered ` runs the **migration-continuity chain** — `~ceralive0.2.0 < ~ceralive1.0.0 < ~ceralive1.1.0 < ~ceralive.1 < ~ceralive.2 < ~ceralive.10 < -` — through real `dpkg --compare-versions`; its legacy members are every version that exists as a published artifact today, so the chain is the proof that every fleet device upgrades cleanly into the counter scheme. Sourced by `test-package-contract.sh` (CHECK 5/6) and `test-suffix-coherence-manifest.sh` so the container lane and the host lane cannot prove different rules. | | [`ci/test-suffix-coherence-manifest.sh`](ci/test-suffix-coherence-manifest.sh) | The per-source-suffix + mixed-version-manifest contract — host-runnable, offline, **no docker**. Proves: sources at differing counters are accepted while an internally-mixed source fails closed naming itself; the full migration chain under real `dpkg` (with a non-vacuity control showing a lexical compare inverts `.2` vs `.10`); `generate-release-manifest.sh` over a MIXED staged set emits the new header, no `deb_version_suffix:`, and a row per staged deb at each source's own version; and a ZERO-UPSTREAM-BUILD set (only the companion fresh) keeps every upstream row at its carried counter with only the companion at the bare tag version. Every expected count is COUNTED from the fixture that produced it — no total is written down. | | [`ci/test-release-workflow-wiring.sh`](ci/test-release-workflow-wiring.sh) | The **static** proof that `release.yml`'s `build-deb` is wired the way the differential pipeline needs. It reads the workflow text and never dispatches a run: step presence, the ordering chain (previous-release resolution → detection → carry-forward staging → **every** executable `build-stack.sh` mention, comment lines excluded), `fetch-depth: 0` inside the `build-deb` slice specifically, and an awk detector for any `${{ }}` interpolated into a `run:` body. It exists because the invariant it guards fails SILENTLY — staging after the build still produces a green release, built against stock suite dependencies. `RELEASE_WORKFLOW_FILE` points it at a scratch copy for failure demonstrations, so the tracked workflow is never mutated. | -| [`ci/test-fm350-patch-contract.sh`](ci/test-fm350-patch-contract.sh) | Static regression gate for the hardware-required FM350 first-enable override: the carried patch must install `enabling_modem_init`, send `Z0`, and never regress that override to core `Z` (which firmware `81600.0000.00.19.17.10` rejects with CME 59). It also requires the bearer's own `+CGCONTRDP` parser and its empty-bearer-id test, so the generic parser (which fails on T-Mobile US answers) does not come back. | +| [`ci/test-fm350-patch-contract.sh`](ci/test-fm350-patch-contract.sh) | Static regression gate for the hardware-required FM350 first-enable override: the carried patch must install `enabling_modem_init`, send `Z0`, and never regress that override to core `Z` (which firmware `81600.0000.00.19.17.10` rejects with CME 59). It also requires the bearer's own `+CGCONTRDP` parser and its empty-bearer-id test, so the generic parser (which fails on T-Mobile US answers) does not come back, and keeps patch `0004` in the series with AcT captures for exactly 10 to 13 and its registration replay and collision tests. | | [`ci/resolve-tag.sh`](ci/resolve-tag.sh) | The **shared tag → peeled-commit-SHA resolver** used by `release.yml`. `resolve-tag.sh ` asks the remote (`git ls-remote`, no clone) for both `refs/tags/` and `refs/tags/^{}`, prefers the **peeled** commit SHA (an annotated tag otherwise resolves to its tag object), prints it, and fails closed if the tag is absent or ambiguous. ONE script, called from tag-guard (pin every checkout), publish-npm (last-instant pre-publish TOCTOU re-check), and create-release (pre-create re-check) — no divergent copies. A caller detects a moved tag by comparing the output against the pinned SHA. | | [`ci/reconcile-release-assets.sh`](ci/reconcile-release-assets.sh) | The **immutable, manifest-complete release-asset reconciler** used by `release.yml`'s `create-release`. `reconcile-release-assets.sh ` takes a flat dir of the raw built debs + the manifest and: verifies the deb set equals the manifest sha256-exactly (missing/extra/corrupt ⇒ fail closed); stages each asset under its **own sanitized basename** (`~` → `.`, never relying on GitHub's upload mapping) and rejects any name **collision**; creates the release if absent; then for each staged asset uploads it if MISSING or integrity-compares (download + sha256) if it already EXISTS — matching ⇒ skip (idempotent), differing ⇒ fail closed (published assets are never overwritten); and finally verifies the live asset set equals the staged set. `RECONCILE_RELEASE_DIR=` selects a local mock backend for standalone testing. | diff --git a/packaging/SUITE-ADAPTATIONS.md b/packaging/SUITE-ADAPTATIONS.md index 7a0ccd6..c4ffd65 100644 --- a/packaging/SUITE-ADAPTATIONS.md +++ b/packaging/SUITE-ADAPTATIONS.md @@ -13,7 +13,7 @@ The four sources are rebuilt from their **pinned sid `debian/-` packag libqrtr-glib carry zero source patches. ModemManager carries only the project-owner-approved, three-patch BELABOX-derived FM350-GL series documented in [`ADR-FM350-RNDIS-BEARER.md`](../docs/adr/ADR-FM350-RNDIS-BEARER.md) and -[`POLICY.md`](../POLICY.md). +[`POLICY.md`](../POLICY.md), plus the fork's generic registration-parser fix `0004`. That pinned packaging is **sid packaging, and sid is ahead of trixie** — so it does not build unmodified here either. A small set of **packaging-metadata** adaptations is applied, limited @@ -149,8 +149,8 @@ Two meson flags in `override_dh_auto_configure` (companions to adaptation 2): ## ModemManager — approved FM350-GL source patch series -`ModemManager/debian/patches/series` carries exactly three patches against the pinned -ModemManager 1.24.2 source: +`ModemManager/debian/patches/series` carries four patches against the pinned +ModemManager 1.24.2 source, the first three of them BELABOX-derived: 1. A 1.24-native forward-port of BELABOX's FM350-GL USB/RNDIS bearer and `+GTACT` mode handling, derived from commits `da01610c46c581b0c6f2acd0ac50f5bba666efdf`, @@ -162,12 +162,19 @@ ModemManager 1.24.2 source: `b4377c5028a0de4435b86f7aad9114e9443d69e4`. 3. The extended `+COPS` parser fix and regression test from `43e09a768e3855f3afb93e517902c1e0e25ed676`. +4. Two-digit AcT values (10 to 13) in the `+CREG`/`+CGREG`/`+CEREG` patterns and the NR TAC + in `+CREG`/`+CGREG`, with replay and collision tests (openstreambox fork carry, see below). All three retain BELABOX author `rationalsa ` and record `Forwarded: no`. The project owner approved this exact carry on 2026-08-22 under the narrow POLICY exception. Builds prove source compatibility only; the real-board bearer drill remains required before any hardware support claim. +Patch 4 is the fork's own change, not BELABOX-derived and not covered by the 2026-08-22 owner +approval; it is carried under the openstreambox release-line waiver in `POLICY.md` §1. It +records `Forwarded: no` and is retired once upstream ModemManager accepts two-digit AcT values +in these patterns. + ## One CI-side trixie change that is NOT a packaging adaptation `ci/daemon-smoke.sh` installed `policykit-1`, which **does not exist on trixie** — it was a @@ -178,7 +185,7 @@ This is test-harness plumbing, not a `debian/` deviation, and no source recipe r | Source | `debian/control` | `debian/rules` | Source patches | |---------------|----------------------------------------------------|---------------------------|----------------| -| ModemManager | GI swap; debhelper `13.11.6`→`13.11.4`; `systemd-dev`→`udev` | +2 meson install-dir pins | 3-patch FM350-GL series above | +| ModemManager | GI swap; debhelper `13.11.6`→`13.11.4`; `systemd-dev`→`udev` | +2 meson install-dir pins | 3-patch FM350-GL series + `0004` above | | libmbim | GI swap | (pristine) | none | | libqmi | GI swap | (pristine) | none | | libqrtr-glib | GI swap | (pristine) | none | diff --git a/packaging/ci/test-fm350-patch-contract.sh b/packaging/ci/test-fm350-patch-contract.sh index d614ab3..b725b91 100755 --- a/packaging/ci/test-fm350-patch-contract.sh +++ b/packaging/ci/test-fm350-patch-contract.sh @@ -3,6 +3,9 @@ set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PATCH="$HERE/../ModemManager/debian/patches/0001-fm350gl-forward-port-rndis-bearer-and-modes.patch" +CREG_PATCH_NAME="0004-modem-helpers-accept-two-digit-act-in-creg.patch" +CREG_PATCH="$HERE/../ModemManager/debian/patches/$CREG_PATCH_NAME" +SERIES="$HERE/../ModemManager/debian/patches/series" fail() { printf 'FAIL: %s\n' "$1" >&2 @@ -28,6 +31,30 @@ fi grep -Fq '+ g_test_add_func ("/MM/fm350gl/cgcontrdp/tmobile", test_cgcontrdp_tmobile);' "$PATCH" || fail 'FM350 patch lost the empty-bearer-id +CGCONTRDP regression test' +grep -Fxq "$CREG_PATCH_NAME" "$SERIES" || + fail 'series lost the two-digit AcT +CREG/+CGREG/+CEREG fix the FM350 needs on 5G SA' +[ -f "$CREG_PATCH" ] || fail "missing $CREG_PATCH_NAME" +# The AcT capture of each of these patterns must accept 10 to 13 (11 = NR on a 5GCN), and only +# those: an open-ended [0-9]+ reads padded cell ids and unquoted RACs as an AcT. +for idx in 5 6 7 9 10 11; do + line=$(grep -E "^\+ \[$idx\] = " "$CREG_PATCH") || + fail "registration patch no longer rewrites creg_regex[$idx]" + case "$line" in + *'1[0-3]'*) ;; + *) fail "creg_regex[$idx] in the registration patch does not accept AcT 10 to 13" ;; + esac + case "$line" in + *'[0-9]+'*) fail "creg_regex[$idx] in the registration patch takes an open-ended number" ;; + esac +done +for t in test_creg_5gsa_registered_after_enable_sequence test_creg_5gsa_radio_on_sequence \ + test_creg_5gsa_urcs_both_orders test_creg_two_digit_act_no_collision; do + grep -Fq "+ g_test_suite_add (suite, TESTCASE ($t, reg_data));" "$CREG_PATCH" || + fail "registration patch lost its replay test $t" +done + printf 'PASS: FM350 patch preserves the hardware-required Z0 first-enable override\n' printf 'PASS: FM350 patch keeps the lenient +CGCONTRDP parser and its regression test\n' + +printf 'PASS: series keeps the two-digit AcT registration fix, its replay and collision tests\n'