Port Wallace Toolbox and Project Lycan Qualcomm features to engmenu
This commit is contained in:
1 parent
8ae2dd3b39
commit
6d31efd796
20 files changed
+2021
-132
No files matched your search
@@ -1130,14 +1130,85 @@ PY
|
||||
imei1=""
|
||||
imei2=""
|
||||
imei_sv=""
|
||||
if [ -s /tmp/bananarchy_imei_override ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /tmp/bananarchy_imei_override 2>/dev/null || true
|
||||
imei1="${IMEI1:-}"
|
||||
imei2="${IMEI2:-}"
|
||||
elif [ -s /var/lib/bananarchy/imei_override ]; then
|
||||
# shellcheck disable=SC1091
|
||||
. /var/lib/bananarchy/imei_override 2>/dev/null || true
|
||||
imei1="${IMEI1:-}"
|
||||
imei2="${IMEI2:-}"
|
||||
fi
|
||||
if detect_qmicli_modem; then
|
||||
dms_ids="$($QMICLI_MODEM --dms-get-ids 2>/dev/null || true)"
|
||||
imei1="$(printf "%s\n" "$dms_ids" | sed -n "s/.*IMEI: '\([0-9]\{14,16\}\)'/\1/p" | head -n1)"
|
||||
[ -z "$imei1" ] && imei1="$(printf "%s\n" "$dms_ids" | sed -n "s/.*IMEI: '\([0-9]\{14,16\}\)'/\1/p" | head -n1)"
|
||||
imei_sv="$(printf "%s\n" "$dms_ids" | sed -n "s/.*IMEI SV: '\([^']*\)'/\1/p" | head -n1)"
|
||||
fi
|
||||
if [ -z "$imei1" ]; then
|
||||
imei1="$(mmcli -m any -K 2>/dev/null | awk -F': ' '/modem\.3gpp\.imei/ {print $2; exit}')"
|
||||
fi
|
||||
# Decode NV 550 (SIM1) and context1/550 (SIM2) from tunning tar partition if present
|
||||
if { [ -z "$imei1" ] || [ -z "$imei2" ]; } && [ -e /dev/disk/by-partlabel/tunning ] && command -v python3 >/dev/null 2>&1; then
|
||||
eval "$(python3 - /dev/disk/by-partlabel/tunning << 'PY' 2>/dev/null || true
|
||||
import sys, tarfile
|
||||
def dec(d):
|
||||
if not d or len(d) < 9 or d[0] != 0x08 or (d[1] & 0x0F) != 0x0A: return ""
|
||||
s = str((d[1] >> 4) & 0x0F) + "".join(f"{b & 0x0F}{(b >> 4) & 0x0F}" for b in d[2:9])
|
||||
return s if s.isdigit() and len(s) == 15 else ""
|
||||
try:
|
||||
with tarfile.open(sys.argv[1], "r:*") as tf:
|
||||
for m in tf.getmembers():
|
||||
n = m.name.lstrip("./")
|
||||
if n == "nvm/num/550":
|
||||
v = dec(tf.extractfile(m).read())
|
||||
if v: print(f"TUN1={v}")
|
||||
elif n == "nvm/context1/550":
|
||||
v = dec(tf.extractfile(m).read())
|
||||
if v: print(f"TUN2={v}")
|
||||
except Exception:
|
||||
pass
|
||||
PY
|
||||
)"
|
||||
[ -z "$imei1" ] && [ -n "${TUN1:-}" ] && imei1="$TUN1"
|
||||
[ -z "$imei2" ] && [ -n "${TUN2:-}" ] && imei2="$TUN2"
|
||||
fi
|
||||
# Decode IMEI1 (0x88) and IMEI2 (0x108) from rf_nv partition (nokia-sparkler, nokia-leo, etc.)
|
||||
if { [ -z "$imei1" ] || [ -z "$imei2" ]; } && { [ -e /dev/disk/by-partlabel/rf_nv ] || [ -e /dev/disk/by-partlabel/rfnv ]; } && command -v python3 >/dev/null 2>&1; then
|
||||
rfnv_dev="/dev/disk/by-partlabel/rf_nv"
|
||||
[ -e "$rfnv_dev" ] || rfnv_dev="/dev/disk/by-partlabel/rfnv"
|
||||
eval "$(python3 - "$rfnv_dev" << 'PY' 2>/dev/null || true
|
||||
import sys
|
||||
SIGVAL = b"IEMI"
|
||||
SIGPOS = 0x80
|
||||
SIGVAL2 = b"\x92\x8a\x9a\x92"
|
||||
SIGPOS2 = SIGPOS + 0x80
|
||||
def dec(d):
|
||||
if not d or len(d) < 9: return ""
|
||||
inv = bytes(((b >> 4) | ((b & 15) << 4)) for b in d[:9])
|
||||
s = inv.hex()[3:]
|
||||
return s if len(s) == 15 and s.isdigit() else ""
|
||||
try:
|
||||
with open(sys.argv[1], "rb") as fh:
|
||||
fh.seek(SIGPOS)
|
||||
v1 = fh.read(4)
|
||||
fh.seek(SIGPOS2)
|
||||
v2 = fh.read(4)
|
||||
if v1 == SIGVAL and v2 == SIGVAL2:
|
||||
fh.seek(SIGPOS + 8)
|
||||
i1 = dec(fh.read(9))
|
||||
fh.seek(SIGPOS2 + 8)
|
||||
i2 = dec(fh.read(9))
|
||||
if i1: print(f"RFNV1={i1}")
|
||||
if i2: print(f"RFNV2={i2}")
|
||||
except Exception:
|
||||
pass
|
||||
PY
|
||||
)"
|
||||
[ -z "$imei1" ] && [ -n "${RFNV1:-}" ] && imei1="$RFNV1"
|
||||
[ -z "$imei2" ] && [ -n "${RFNV2:-}" ] && imei2="$RFNV2"
|
||||
fi
|
||||
# Query secondary AT channel (/dev/wwan0at1) if present
|
||||
if [ -c "/dev/wwan0at1" ]; then
|
||||
at_out="$(timeout 1 sh -c '
|
||||
|
||||
Reference in new issue
Block a user