diff --git a/AGENTS.md b/AGENTS.md index 216170d..2a8715b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -436,6 +436,15 @@ configures the muxed netdev. Idempotent; a non-zero exit fails the unit. - Waits up to 120 s for a modem, then gates the connect attempts on network registration (`IMS_REG_TIMEOUT`, default 300 s): some carriers attach ~2 min after boot. +- Never creates or connects a bearer while the modem is `disabled` — its + radio is off (airplane mode): a modem still disabled after the wait, or + disabled when an attempt is due, makes the script exit non-zero (`modem … + disabled … (radio off): not connecting`) and systemd retries. A bearer + connect on a disabled modem fails with `no-service` and leaves + ModemManager's state `enabled` with the modem in low power; switching the + radio back on then no longer brings it up (dev phone 2026-10-06: not + registered after 150 s, against 5 s without the attempt; a ModemManager + disable/enable recovered it). - Connects by **3GPP profile index** (`IMS_PROFILE_ID`, default: looked up by APN in `qmicli --wds-get-profile-list=3gpp`), not by APN string: a profile-indexed request is exempt from the modem's attach-family forcing diff --git a/packaging/ims-pdn-up.sh b/packaging/ims-pdn-up.sh index a20068e..191c2b5 100644 --- a/packaging/ims-pdn-up.sh +++ b/packaging/ims-pdn-up.sh @@ -39,6 +39,12 @@ bearer_paths() { kv -m "$MODEM" | sed -n 's/^modem\.generic\.bearers\.value\[[0-9]*\] *: *//p' } +# A disabled modem has its radio off (airplane mode): leave it alone. A bearer +# connect on it fails with no-service and leaves ModemManager's state +# `enabled` with the modem still in low power; switching the radio back on +# then no longer brings the modem up (dev phone 2026-10-06). +radio_off() { [ "$(modem_state)" = disabled ]; } + envval() { # $1 = key — for manual runs; under systemd the vars are inherited sed -n "s/^$1=//p" /etc/imsd.env 2>/dev/null | tail -n1 | tr -d '"' } @@ -165,6 +171,10 @@ if [ -z "$BEARER" ]; then [ "$STATE" != "$last" ] && log "waiting for registration (state: ${STATE:-unknown})" last=$STATE if [ "$waited" -ge "$REG_TIMEOUT" ]; then + if [ "$STATE" = disabled ]; then + log "modem still disabled after $REG_TIMEOUT s (radio off): not connecting" + exit 1 + fi log "not registered after $REG_TIMEOUT s — attempting anyway" break fi @@ -193,6 +203,7 @@ n=0 while [ -z "$BEARER" ]; do n=$((n + 1)) [ "$n" -gt 10 ] && { log "bearer connect failed after 10 attempts"; exit 1; } + radio_off && { log "modem disabled (radio off): not connecting"; exit 1; } B=$(find_ims_bearer no) # reuse a stale disconnected ims bearer of this run's shape if [ -z "$B" ]; then if [ -n "$PROFILE_ID" ]; then