doc: the network badge, the cell's registration state, the boot finding

gsm-network.md: what gsm-bts's ms-state records and how the page reads
it (no detach path beyond IMSI DETACH and GMM DETACH: the model never
rejects or times out a registration), when each preset phone registers
(EL71 15.8 s, S75v40 9.8 s, CX70 and SL65 9.3 s, KE800 17 s, KE970
16.5 s; the gate's s75_working image never does) and that none attaches
to GPRS before something on it goes online; the KE800/KE970 "No network"
is history. The owner's "connected during boot": no frame of any kind
reached the relay during any boot, and the old idle glyph read as a live
link; the badge starts at "no network" and is green only while the
gateway's WebSocket is open. architecture.md describes the badge's
states, sizes, name, announcements and cost; diagnostics.md lists
_wasm_gsm_state, __ui.gprs.badge and __ui.gsm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xda8d7rfJjkFSmKVQtcBGh
This commit is contained in:
Konstantin Pereiaslov 2026-11-14 21:11:10 -06:00
parent 0a9ac4f946
commit b1c2a535e2
3 changed files with 117 additions and 35 deletions

View file

@ -222,40 +222,52 @@ thread is using them).
Start/Stop/Cancel there is (`window.__ui` mirrors that state for the
drivers in `tools/`). A capture in progress is a second pill beside it,
ended with **Finish** — "Stop" only ever means the emulator.
- **GPRS indicator** (`#gprs`, `renderGprs()` in app.js). While a run has
the GSM network, a 12px glyph of two arrows takes the place of the
pill's dot, which only repeats the pill's own colour, so it costs the
row no width and "Running · 0:17" stays whole at 390px. A run without
the network (option unticked, a board without a radio, a dist without
`_wasm_net_attach`) shows none and keeps the dot. What it shows:
- **idle**, dim arrows: the phone has not used GPRS, so there is no
link. `gprs-net.js` dials the gateway only when the phone sends its
first frame, and after a close only when it sends again;
- **connecting**, pulsing amber;
- **connected**, green;
- **active**: the up arrow lights while frames go to the gateway, the
down arrow while they come back;
- **offline**, slashed red, with the redial countdown beside it while
the backoff runs. After that the link is dialled when the phone next
sends;
- **refused**, slashed on red: a close that is final for the run
(4003, 4004, 4009).
- **Network badge** (`#gprs`, `renderGprs()` in app.js). While a run has
the GSM network, a boxed **G**, the GPRS mark of a phone's status bar,
takes the place of the pill's dot, which only repeats the pill's own
colour. A run without the network (option unticked, a board without a
radio, a dist without `_wasm_net_attach`) shows none and keeps the dot.
What it shows, the phone's state first, then the gateway link:
- **no network**, faint with a dashed box: the cell has not registered
the phone. Every run starts here;
- **registered**, outlined and dim: the cell sent LOCATION UPDATING
ACCEPT;
- **GPRS attached**, lit and neutral: the cell sent GMM ATTACH ACCEPT.
The phone has not sent an IP packet, so there is no link;
- **connecting**, pulsing amber: the phone sent its first frame and
`gprs-net.js` is dialling the gateway (it dials only for a frame, and
after a close only when the phone sends again);
- **connected**, filled green: the gateway's WebSocket is open. A tiny ▴
shows while frames go to the gateway, ▾ while they come back;
- **offline**, struck through in red, with the redial countdown: beside
the G on desktop, under it in the phone layout, where the pill has no
room beside it;
- **refused**, struck through on a red ground: a close that is final for
the run (4003, 4004, 4009).
The glyph's accessible name (`role="img"`) says the state and the close
reason. Its title adds the frames and bytes each way. `#live-region`
says "GPRS connected" and "GPRS offline: …" or "GPRS refused: …" once
per change: a redial loop that fails the same way says it once, and
traffic says nothing. Advanced ▸ GSM network keeps its caption with the
same reason. `window.__ui.gprs` gives tools the shown state, reason,
close code, `retryIn` and the counts.
At 390x844 "Running · 0:17" keeps 2.5 px (connected, the widest at
16 px) to 7.5 px to spare; the dot left 12.5. The badge's accessible
name (`role="img"`) says the state and the close reason, its title adds
the network line ("Registered, GPRS attached, data context active"),
the link and the frames and bytes each way. `#live-region` says
"Registered on the network", "GPRS attached", "GPRS connected", "GPRS
offline: …" or "GPRS refused: …", and "No network" when registration is
lost, once per change: a redial loop that fails the same way says it
once, and traffic says nothing. Advanced ▸ GSM network keeps its caption
with the close reason. `window.__ui.gprs` gives tools the link `state`,
the `badge`, reason, close code, `retryIn` and the counts;
`window.__ui.gsm` gives `{known, registered, gprsAttached, pdpActive}`.
It costs the hot paths nothing. `GprsNet` (no DOM) keeps `state`,
`reason`, `code`, `retryAt` and `frames`/`bytes` both ways, and calls
`onChange("state")` on each change. From its existing 20 ms poll it
calls `onChange("traffic")` when frames were counted, at most every
250 ms. The page writes the DOM only from those calls, from a 400 ms
timer that puts the arrows out, and from a 1 Hz countdown while a
redial waits. Nothing runs from the paint loop, the key path or audio.
`reason`, `code`, `retryAt`, `frames`/`bytes` both ways and `ms`, the
cell's bits from `_wasm_gsm_state()` (qemu: gsm-bts's read-only
`ms-state`, read under the BQL in a bottom half), which it reads at most
once a second from its existing 20 ms poll. It calls `onChange("state")`
and `onChange("gsm")` on each change and `onChange("traffic")` when
frames were counted, at most every 250 ms. The page writes the DOM only
from those calls, only what changed, from a 400 ms timer that puts the
arrows out, and from a 1 Hz countdown while a redial waits. Nothing runs
from the paint loop, the key path or audio.
- **The phone column is the same view at every size, and it is laid out in
CSS alone.** One `100dvh` page that never scrolls: a single 32px control
row (state/firmware pill, screenshot, record, sound, fullscreen, and the

View file

@ -104,8 +104,11 @@ is open), `_wasm_audio_ring_ptr()` (the ring `audio-worklet.js` reads),
`headset-stereo` or `none` at the buffer, then plug it), `_wasm_net_attach()`,
`_wasm_net_buf()`, `_wasm_net_take()`, `_wasm_net_put(len)` (the GSM cell's
IP side; the page's relay is `window.__gprsNet`, with `frames` and `bytes`
counted both ways, its `state` and the last close's `reason`; what the
pill's GPRS indicator shows is `window.__ui.gprs`), and the runtime's `FS`,
counted both ways, its `state` and the last close's `reason`),
`_wasm_gsm_state()` (the cell's view of the phone: 1 registered, 2 GPRS
attached, 4 PDP context active, as of the last call, which asks for the
next; `window.__gprsNet.ms`; what the pill's network badge shows is
`window.__ui.gprs.badge`, the phone's state `window.__ui.gsm`), and the runtime's `FS`,
`ENV`, `HEAPU8`, `TTY`, `addFunction`/`removeFunction`. A dist built with
`tools/perf/freerun.diff` also has `_wasm_free_run`.

View file

@ -23,6 +23,24 @@ bsp 191612c (2026-11-13). Upstream's cell now defaults to DCS1800 ARFCN 512
| CX70 | boots, no firmware EXIT in 24 runs of 240 s; at 150 s it is in its first-boot "Phone Pilot" (registration not read) |
| KE800, KE970 | boot (bootcheck); registration not read this time. On 2026-11-11 (qemu 47d1ff26aa) both stayed on "No network", native build included |
When the cell registered each phone, read from the cell itself
(`_wasm_gsm_state()`, below) on qemu 133f91266b, bsp 191612c, 2026-11-14,
seconds after Start; the page's badge follows within a second. EL71 and
S75v40 were each the only run on the host, the others ran five at a time:
| image | registered | GPRS attached | the LCD at the end |
|---|---|---|---|
| `EL71v41lg91.bin` | 15.8 s (16.3 s in a second run, 17 s through the gateway run) | only when the browser goes online: 130 s into gprscheck, PDP context 3 s later | idle screen, operator and signal |
| `S75v40lg1.bin` | 9.8 s | not in 150 s | |
| `CX70v56lg3.bin` | 9.3 s | not in 240 s | |
| `SL65v49lg1_TIM.bin` | 9.3 s | not in 240 s | |
| `KE800v11b.bin` | 17 s | not in 240 s | "Test Network", full signal |
| `KE970v10d.bin` | 16.5 s | not in 240 s | "Test Network", full signal |
| `s75_working20060710172101.bin` (the gate's S75) | not in 240 s | | "Поиск сети" (searching) |
So the LG phones register now (the 2026-11-11 "No network" above is
history), and no phone attaches to GPRS until something on it uses it.
## The built-in network
Nothing to start: press Start. About 23 s later (EL71,
@ -129,7 +147,9 @@ Two things the check had to get past:
- **qemu.** The page adds `-object gsm-bts,id=gsm0` and
`-machine pmb887x,gsm-network=gsm0`. The fork's qemu has no GSM code of
its own: `hw/gsm` is upstream's with one fix, the uplink LLC buffer (GPRS
data, above).
data, above), and the registration state below, which the owner
approved for the page's badge: twelve lines, each marked
`WASM PORT (removable)`.
- **The board.** A board gets the cell when its config chain has a
transceiver of a type qemu models (`RADIO_TYPE_RE` in `site/app.js`:
hd155153np, hd155155npeb, hd155165bp, pmb6270, pmb6272, bright-6pla). Since
@ -139,6 +159,49 @@ Two things the check had to get past:
data cable; see the deep-sleep entry below. Picking another accessory in
the control still works and is the user's choice.
### The page's network badge, and the phone's registration
The status pill shows a boxed G while a run has the network
(doc/architecture.md, "Network badge"): no network, registered, GPRS
attached, then the gateway link (connecting, connected with ▴/▾ for
traffic, offline, refused).
- **What the cell records** (qemu 133f91266b). `gsm-bts` keeps a byte,
the read-only property `ms-state` (`GSM_BTS_MS_*` in gsm-bts.h): bit 0
set when it sends LOCATION UPDATING ACCEPT and cleared by an IMSI DETACH
INDICATION; bit 1 set when it sends GMM ATTACH ACCEPT and cleared by a
GMM DETACH REQUEST (power-off or not); bit 2 a PDP context, set with
ACTIVATE PDP CONTEXT ACCEPT and cleared by DEACTIVATE PDP CONTEXT or a
new attach or detach, as the model's own `pdp_active`. Those are all
the model's ways out: it never rejects a location update, has no
periodic-update timer and no network-side detach, so nothing else
clears a bit. It is "the cell answered", not "the phone took it": a
phone that loses the accept would still read registered.
- **How the page reads it.** `ui/wasm.c`'s `wasm_gsm_state()` returns the
bits as of the last call and schedules a bottom half that reads the
property under the BQL for the next, at most one pending. `gprs-net.js`
calls it at most once a second from its existing 20 ms poll, so a change
shows within about a second (0.5 s in the timings above).
**The "connected during boot" report (2026-11-14).** The owner saw the
old two-arrow GPRS glyph go to "connected" while the phone booted. No
frame causes it: a trace of every frame the relay took from qemu and
handed back, from Start on, with the real gateway behind serve.mjs, found
none on EL71 or S75 in 150 s, nor on CX70, SL65, S75v40, KE800 and KE970
in 240 s; the page opened no WebSocket and `__ui.gprs` stayed "idle". The
cell itself never sends a frame on its own (its only frames are the
phone's uplink IP packets, which need a PDP context, and ARP replies to
the gateway's requests, which need a link), the hub adds none, and the
phones above do not even attach to GPRS at boot. What the owner saw was
the "idle" glyph: two dim arrows on a dark chip, appearing the moment the
run starts, which read as a data link. The badge that replaced it starts
at "no network", moves to "registered" when the cell says so, and turns
green only while the gateway's WebSocket is open, which the phone's first
IP frame dials. ui-acceptance records every badge of its GSM boot with
the frames the phone had handed the relay and fails a link state
reached before the phone sent one. Real traffic is relayed and shown as
it was.
### Where it runs, and why not in a worker
`gsm-bts` is not a process with a clock of its own. It is a passive object
@ -223,7 +286,11 @@ So the built-in cell stays where upstream runs it.
firmware `>>EXIT<<` from `l1bbcsg` (layer 1); with the page's clock
(`ICOUNT=vt`) it registers. Seen once on `d5421c70af`, not looked into.
- **LG boards**: KE800 and KE970 stayed on "No network" at qemu
47d1ff26aa, native build included; not read again since.
47d1ff26aa, native build included. At 133f91266b (bsp 191612c) both
register and show "Test Network" (table above).
- **The gate's S75 image** (`s75_working20060710172101.bin`) does not
register: after 240 s it still searches. S75v40lg1.bin registers in
10 s. Not looked into.
- **Deep sleep.** With the radio enabled and an accessory that lets the
firmware deep-sleep (music cable, or none) EL71 hangs about a minute after
boot: the firmware waits for `SCCUCLKSTA.GSMCLK` to clear after writing