Skip to content

Commit

Permalink
uqmi: fix acquiring PIN status
Browse files Browse the repository at this point in the history
Evaluating the return value of 'json_load' didn't work in the
intended way resulting in PIN status no longer being read on modems
where --get-pin-status doesn't fail.
Fix this by trying --get-pin-status first and checking if pin1_status
field exists in JSON, and if it doesn't try again with
--uim-get-sim-state.

Fixes: openwrt#9501
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
  • Loading branch information
dangowrt committed Mar 24, 2022
1 parent dc23df8 commit ee7cb5e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
Expand Up @@ -105,10 +105,12 @@ proto_qmi_setup() {
}
}
else
. /usr/share/libubox/jshn.sh
json_load "$(uqmi -s -d "$device" --get-pin-status)" 2>&1 | grep -q Failed &&
json_load "$(uqmi -s -d "$device" --uim-get-sim-state)"
json_load "$(uqmi -s -d "$device" --get-pin-status)"
json_get_var pin1_status pin1_status
if [ -z "$pin1_status" ]; then
json_load "$(uqmi -s -d "$device" --uim-get-sim-state)"
json_get_var pin1_status pin1_status
fi
json_get_var pin1_verify_tries pin1_verify_tries

case "$pin1_status" in
Expand Down Expand Up @@ -152,6 +154,7 @@ proto_qmi_setup() {
return 1
;;
esac
json_cleanup
fi

if [ -n "$plmn" ]; then
Expand Down Expand Up @@ -247,7 +250,8 @@ proto_qmi_setup() {

echo "Starting network $interface"

pdptype=$(echo "$pdptype" | awk '{print tolower($0)}')
pdptype="$(echo "$pdptype" | awk '{print tolower($0)}')"

[ "$pdptype" = "ip" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] || pdptype="ip"

if [ "$pdptype" = "ip" ]; then
Expand Down

0 comments on commit ee7cb5e

Please sign in to comment.