dwm-plugins: fix vibration test, AT debug channel, and Close softkey leak

This commit is contained in:
Luxferre
2026-10-24 21:11:57 +03:00
parent f394d2b135
commit 5646f03ebe
21 changed files with 160 additions and 54 deletions
@@ -504,57 +504,50 @@ case "$cmd" in
echo "ERROR: Empty AT command"
exit 1
fi
run_at_dev() {
dev="$1"
[ -c "$dev" ] || return 1
out="$(timeout 2 awk -v dev="$dev" -v cmd="$at_cmd" '
BEGIN {
sys = "stty -F " dev " raw -echo 115200 min 0 time 2 2>/dev/null"
system(sys)
printf "%s\r\n", cmd > dev
close(dev)
}
' 2>/dev/null || true)"
return 0
}
resp=""
for candidate in "$port" wwan0at1 wwan0at0; do
for candidate in "$port" /dev/wwan0at1 /dev/wwan0at0; do
case "$candidate" in
wwan0at0|wwan0at1)
dev="/dev/$candidate"
if [ -c "$dev" ]; then
resp="$(timeout 2 sh -c '
dev="$1"
cmd="$2"
stty -F "$dev" raw -echo 115200 min 0 time 2 2>/dev/null || true
exec 3<>"$dev"
dd bs=256 count=4 status=none <&3 >/dev/null 2>&1 || true
printf "%s\r\n" "$cmd" >&3
lines=""
i=0
while [ "$i" -lt 8 ]; do
chunk="$(dd bs=512 count=1 status=none <&3 2>/dev/null | tr -d "\r" || true)"
if [ -n "$chunk" ]; then
lines="${lines}${chunk}"
case "$lines" in
*OK*|*ERROR*)
break
;;
esac
fi
i=$((i + 1))
done
exec 3>&-
printf "%s\n" "$lines"
' _ "$dev" "$at_cmd" 2>/dev/null | sed '/^[[:space:]]*$/d' || true)"
if [ -n "$resp" ]; then
printf "%s\n" "$resp"
exit 0
fi
fi
;;
/dev/wwan0at0|/dev/wwan0at1)
dev="$candidate"
;;
*)
dev=""
;;
esac
[ "$port" != "auto" ] && [ "$candidate" = "$port" ] && break
if [ -n "$dev" ] && [ -c "$dev" ]; then
resp="$(timeout 2 sh -c '
dev="$1"
cmd="$2"
tmpf="/tmp/at_resp_$$.txt"
rm -f "$tmpf"
cat "$dev" > "$tmpf" 2>/dev/null &
rpid=$!
sleep 0.04
printf "%s\r\n" "$cmd" > "$dev" 2>/dev/null || true
i=0
while [ "$i" -lt 12 ]; do
if grep -qE "(^|[[:space:]])(OK|ERROR|\+CME ERROR|\+CMS ERROR)([[:space:]]|$)" "$tmpf" 2>/dev/null; then
break
fi
sleep 0.08
i=$((i + 1))
done
kill "$rpid" 2>/dev/null || true
wait "$rpid" 2>/dev/null || true
tr -d "\r" < "$tmpf" 2>/dev/null || true
rm -f "$tmpf"
' _ "$dev" "$at_cmd" 2>/dev/null | sed '/^[[:space:]]*$/d' || true)"
if [ -n "$resp" ]; then
printf "%s\n" "$resp"
exit 0
fi
fi
if [ "$port" != "auto" ] && [ "$candidate" = "$port" ]; then
break
fi
done
mm_out="$(mmcli -m any --command="$at_cmd" 2>&1 || true)"
if [ -n "$mm_out" ]; then