Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
67fb594
improve error logging and fix typos
rslater-cs Dec 12, 2025
72d6b1c
Add dummy and dummy2 manager implementations and test harness for hal…
rslater-cs Dec 12, 2025
e964f98
Managers now get their own contexts with cancellation
rslater-cs Dec 16, 2025
390e006
Added test abstractions: timeouts are now based on time indepentant y…
rslater-cs Dec 16, 2025
bf4cd38
small style improvements
rslater-cs Dec 16, 2025
e120f09
Changed mmcli and qmicli to be injectable for testing backends. Dummy…
rslater-cs Dec 17, 2025
a0a7e96
Added hooks for calling commands directly
rslater-cs Dec 19, 2025
28f7f4b
mmcli and qmicli use hooks to interact with sim modems
rslater-cs Dec 19, 2025
9418dee
simple registery for holding sim modems by qmi port and mmcli address
rslater-cs Dec 19, 2025
f661b2a
waiting on channel and changed to sleep based yeild
rslater-cs Dec 19, 2025
27b3d7f
Simplified modem info down to what is needed by our code only
rslater-cs Dec 19, 2025
fd1294f
One test for proof of sim insertion detection via log output, realist…
rslater-cs Dec 19, 2025
af45875
Test detection of modem add and remove events
rslater-cs Dec 19, 2025
7504a91
initial modem model to allow for responsive stateful reaction to driv…
rslater-cs Dec 19, 2025
c31b25c
Deep modem state research, only done eg25 on new firmware
rslater-cs Dec 19, 2025
f28bf57
temp change to sleep as yeild branch
rslater-cs Jan 12, 2026
259037f
Changed test bench to control modem events more verbosly
rslater-cs Jan 13, 2026
e1e72ac
Moved utils
rslater-cs Jan 14, 2026
d228e56
backends
rslater-cs Jan 23, 2026
a308f19
types
rslater-cs Jan 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FIBERS_VER=43a04d1
FIBERS_VER=sleep-as-yield
TRIE_VER=28b3572
BUS_VER=89af71a
UI_VER=a8c5965
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/sh
# collect_modem_snapshot.sh
# Usage: ./collect_modem_snapshot.sh /tmp/idle_run
# Env overrides (optional): MODEM, SIM, QMI_DEV

set -u

RUN_DIR="${1:-/tmp/modem_run}"
MODEM="${MODEM:-0}"
SIM="${SIM:-0}"
QMI_DEV="${QMI_DEV:-/dev/cdc-wdm0}"

MMCLI_DIR="${RUN_DIR}/mmcli"
QMI_DIR="${RUN_DIR}/qmicli"

mkdir -p "${MMCLI_DIR}" "${QMI_DIR}"

echo "Snapshot in RUN_DIR='${RUN_DIR}', MODEM='${MODEM}', SIM='${SIM}', QMI_DEV='${QMI_DEV}'" >&2

###############################################################################
# mmcli read-only snapshots
###############################################################################

# mmcli -J -m <MODEM>
mmcli -J -m "${MODEM}" \
> "${MMCLI_DIR}/modem.json" 2>&1 || true

# mmcli -J -i <SIM>
mmcli -J -i "${SIM}" \
> "${MMCLI_DIR}/sim.json" 2>&1 || true

# mmcli -J -m <MODEM> --signal-get
mmcli -J -m "${MODEM}" --signal-get \
> "${MMCLI_DIR}/signal.json" 2>&1 || true

# mmcli -J -m <MODEM> --location-status
mmcli -J -m "${MODEM}" --location-status \
> "${MMCLI_DIR}/location-status.json" 2>&1 || true

###############################################################################
# qmicli read-only snapshots
###############################################################################

# qmicli --uim-get-card-status
qmicli -p -d "${QMI_DEV}" --uim-get-card-status \
> "${QMI_DIR}/uim-get-card-status.txt" 2>&1 || true

# qmicli --uim-read-transparent=...6F3E (GID1)
qmicli -p -d "${QMI_DEV}" --uim-read-transparent=0x3F00,0x7FFF,0x6F3E \
> "${QMI_DIR}/uim-read-transparent-gid1.txt" 2>&1 || true

# qmicli --nas-get-rf-band-info
qmicli -p -d "${QMI_DEV}" --nas-get-rf-band-info \
> "${QMI_DIR}/nas-get-rf-band-info.txt" 2>&1 || true

# qmicli --nas-get-home-network
qmicli -p -d "${QMI_DEV}" --nas-get-home-network \
> "${QMI_DIR}/nas-get-home-network.txt" 2>&1 || true

# qmicli --nas-get-serving-system
qmicli -p -d "${QMI_DEV}" --nas-get-serving-system \
> "${QMI_DIR}/nas-get-serving-system.txt" 2>&1 || true

# qmicli --nas-get-signal-info
qmicli -p -d "${QMI_DEV}" --nas-get-signal-info \
> "${QMI_DIR}/nas-get-signal-info.txt" 2>&1 || true

echo "Snapshot done under '${RUN_DIR}'." >&2
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
#!/bin/sh
# collect_modem_transitions_matrix.sh
#
# Usage:
# MODEM=0 QMI_DEV=/dev/cdc-wdm0 \
# sh collect_modem_transitions_matrix.sh \
# /tmp/transitions enabled on
#
# Args:
# $1 = RUN_DIR (root output dir)
# $2 = INITIAL_MODEM_STATE: registered|disabled|connected
# $3 = INITIAL_SIM_STATE: on|off
#
# You should manually verify the modem really starts in this state.

set -u

RUN_DIR="${1:-/tmp/modem_transitions}"
INITIAL_MODEM_STATE="${2:-registered}" # registered|disabled|connected
INITIAL_SIM_STATE="${3:-on}" # on|off

MODEM="${MODEM:-0}"
QMI_DEV="${QMI_DEV:-/dev/cdc-wdm0}"

echo "RUN_DIR='${RUN_DIR}', INITIAL_MODEM_STATE='${INITIAL_MODEM_STATE}', INITIAL_SIM_STATE='${INITIAL_SIM_STATE}', MODEM='${MODEM}', QMI_DEV='${QMI_DEV}'" >&2

# Outputs go under:
# ${RUN_DIR}/${INITIAL_MODEM_STATE}_modem_${INITIAL_SIM_STATE}_sim/mmcli/<name>.txt
# ${RUN_DIR}/${INITIAL_MODEM_STATE}_modem_${INITIAL_SIM_STATE}_sim/qmicli/<name>.txt
INITIAL_STATE_DIR="${RUN_DIR}/${INITIAL_MODEM_STATE}_modem_${INITIAL_SIM_STATE}_sim"
MMCLI_DIR="${INITIAL_STATE_DIR}/mmcli"
QMI_DIR="${INITIAL_STATE_DIR}/qmicli"

mkdir -p "${MMCLI_DIR}" "${QMI_DIR}"

ensure_modem_state() {
case "$1" in
registered)
mmcli -m "${MODEM}" -e >/dev/null 2>&1 || true
sleep 1
;;
connected)
if [ -z "${CONNECTION_STRING:-}" ]; then
echo "CONNECTION_STRING is not set; cannot ensure 'connected' state." >&2
return 1
fi
mmcli -m "${MODEM}" --simple-connect="${CONNECTION_STRING}"
sleep 1
;;
disabled)
mmcli -m "${MODEM}" -d >/dev/null 2>&1 || true
;;
*)
echo "Unknown modem state '$1' (expected registered|disabled|connected)" >&2
;;
esac
}

ensure_sim_state() {
case "$1" in
on)
qmicli -p -d "${QMI_DEV}" --uim-sim-power-on=1 >/dev/null 2>&1 || true
;;
off)
qmicli -p -d "${QMI_DEV}" --uim-sim-power-off=1 >/dev/null 2>&1 || true
;;
*)
echo "Unknown SIM state '$1' (expected on|off)" >&2
;;
esac
}

# Helper to run a single experiment:
# name: logical name (e.g. mm-enable, sim-power-off)
# kind: "modem" or "sim" (which aspect this experiment changes)
# forward: shell code for the transition command (no redirection)
run_experiment() {
name="$1"
kind="$2"
forward_cmd="$3"

echo "=== Experiment '${name}' (initial state ${INITIAL_MODEM_STATE}/${INITIAL_SIM_STATE}) ===" >&2

# 1. Force the relevant initial state (modem *or* SIM, not both)
case "${kind}" in
modem)
ensure_modem_state "${INITIAL_MODEM_STATE}"
;;
sim)
ensure_sim_state "${INITIAL_SIM_STATE}"
;;
*)
echo "Unknown experiment kind '${kind}' (expected modem|sim)" >&2
;;
esac

# 2. Run transition and capture output
# Choose output directory based on kind and write to <name>.txt
case "${kind}" in
modem)
out_file="${MMCLI_DIR}/${name}.txt"
;;
sim)
out_file="${QMI_DIR}/${name}.txt"
;;
*)
out_file="${INITIAL_STATE_DIR}/${name}.txt"
;;
esac

# shellcheck disable=SC2086
sh -c "${forward_cmd} > '${out_file}' 2>&1" || true

# 3. Restore initial state for the same aspect (modem or SIM)
case "${kind}" in
modem)
ensure_modem_state "${INITIAL_MODEM_STATE}"
;;
sim)
ensure_sim_state "${INITIAL_SIM_STATE}"
;;
esac
}

###############################################################################
# Define experiments
#
# You can comment out any you don’t care about.
###############################################################################

# Modem enable (forward: -e, reverse: ensure initial state again)
run_experiment \
"mm-enable" \
"modem" \
"mmcli -m '${MODEM}' -e"

# Modem disable
run_experiment \
"mm-disable" \
"modem" \
"mmcli -m '${MODEM}' -d"

# SIM power off
run_experiment \
"sim-power-off" \
"sim" \
"qmicli -p -d '${QMI_DEV}' --uim-sim-power-off=1"

# SIM power on
run_experiment \
"sim-power-on" \
"sim" \
"qmicli -p -d '${QMI_DEV}' --uim-sim-power-on=1"

echo "All experiments done; each should have returned to initial state (best effort)." >&2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"modem": {
"location": {
"capabilities": [
"3gpp-lac-ci",
"gps-raw",
"gps-nmea",
"gps-unmanaged",
"agps-msa",
"agps-msb"
],
"enabled": [
"3gpp-lac-ci"
],
"gps": {
"assistance": [],
"assistance-servers": [],
"refresh-rate": "30",
"supl-server": "--"
},
"signals": "no"
}
}
}
Loading