#!/bin/sh # Beeline P2+P3: modem-up -> READ-ONLY SIM/NAS detect -> (gated) ONE dms online -> passive wait for automatic registration # -> RF/signal GETs -> mm-up. No scan / manual register / band / RAT / PIN ops / bearer. IMSI/ICCID/IMEI masked on-device. O=/tmp/bee23; mkdir -p $O; Q="qmicli -p -d /dev/wwan0qmi0"; t() { cut -d' ' -f1 /proc/uptime; } mask() { sed -E 's/([0-9]{6,})([0-9]{4})/******\2/g'; } B=/sys/bus/platform/devices/4080000.remoteproc:bam-dmux pm() { echo "### $(t) PM=$(cat $B/power/runtime_status 2>/dev/null) rproc=$(cat /sys/class/remoteproc/remoteproc0/state)"; } nv() { for want in modemst1 modemst2 fsg fsc persist; do for p in /sys/class/block/mmcblk0p*; do [ "$(sed -n 's/^PARTNAME=//p' $p/uevent)" = "$want" ] && echo "$want $(sha256sum /dev/$(basename $p) | cut -d' ' -f1)"; done; done; } nv > $O/nv-before.txt; cat /sys/block/mmcblk0/stat > $O/stat-before.txt /bin/modem-up > $O/modem-up.txt 2>&1 for i in $(seq 1 30); do [ -e /dev/wwan0qmi0 ] && [ -e /sys/class/net/wwan0 ] && break; sleep 1; done { pm; ls /dev/wwan0* ; ip -br link | grep wwan; } > $O/ports.txt 2>&1 # --- P2 read-only detect (qmi-b3 masks ICCID to last 4, IMSI to MCC+MNC(5)+last 3) /bin/qmi-b3 > $O/p2-detect.txt 2>&1 M=$(timeout 30 $Q --dms-get-operating-mode 2>&1); echo "$M" > $O/mode-before.txt grep -q "Card state: 'present'" $O/p2-detect.txt && grep -qE "Application state: 'ready'" $O/p2-detect.txt \ || { echo "SIM NOT PRESENT/READY - STOP (no online)"; tar -C /tmp -cf /tmp/bee23.tar bee23; echo BEE23-STOPPED; exit 1; } # --- P3 one gated SET if echo "$M" | grep -q "Mode: 'online'"; then echo "already online - no SET" > $O/set.txt else { echo "### $(t) $Q --dms-set-operating-mode=online"; timeout 30 $Q --dms-set-operating-mode=online 2>&1; echo "### rc=$?"; } > $O/set.txt; fi timeout 30 $Q --dms-get-operating-mode > $O/mode-after.txt 2>&1 # --- passive wait (GET only), up to ~120 s : > $O/reg-timeline.txt for i in $(seq 1 40); do R=$(timeout 30 $Q --nas-get-serving-system 2>&1) echo "### $(t) $(echo "$R" | grep -E "Registration state|PS:|Radio interfaces" -A1 | tr -s ' \t\n' ' ')" >> $O/reg-timeline.txt echo "$R" | grep -q "Registration state: 'registered'" && echo "$R" | grep -q "PS: 'attached'" && break; sleep 3 done sleep 5 for c in --nas-get-serving-system --nas-get-system-info --nas-get-home-network --nas-get-operator-name --nas-get-signal-info \ --nas-get-rf-band-info --nas-get-cell-location-info --dms-get-operating-mode --uim-get-card-status; do echo "### $(t) $c"; timeout 30 $Q $c 2>&1; echo "### rc=$?"; done 2>&1 | mask > $O/p3-reg.txt pm >> $O/p3-reg.txt killall qmi-proxy 2>/dev/null; sleep 1 # MM starts its own proxy (as prep-mm) /bin/mm-up > $O/mm-up.txt 2>&1 { mmcli --version; mmcli -L; mmcli -m 0; mmcli -m 0 --3gpp-profile-manager-list 2>&1; mmcli -m 0 --list-bearers; } 2>&1 | mask > $O/mmcli.txt grep -iE "initial|profile|apn|bearer" /tmp/mm.log | tail -40 | mask > $O/mm-apn.txt { pm; ip -br link | grep wwan0; ip route; ip rule; dmesg | grep -iE "bam|dmux|resume|-110|-22|Resource temporarily|Oops|panic|fatal|watchdog|crash"; } > $O/state.txt 2>&1 cat /tmp/rmtfs.log > $O/rmtfs.log tar -C /tmp -cf /tmp/bee23.tar bee23; echo BEE23-FINISHED