X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=blobdiff_plain;f=package%2Fnetwork%2Futils%2Fuqmi%2Ffiles%2Flib%2Fnetifd%2Fproto%2Fqmi.sh;h=f7b5f27ef67891654685898ed4d09b39e9e7cd5c;hp=f3c548757419127d1ae8e7dece9faeae26a6148f;hb=0c9d06b5b243334123eafaf2e26a15ec2757767e;hpb=dec1bfa0f48d43174921d1a1357a4842f9ba0cf6 diff --git a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh index f3c5487574..f7b5f27ef6 100755 --- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh +++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh @@ -70,17 +70,74 @@ proto_qmi_setup() { while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do [ -e "$device" ] || return 1 - sleep 1; - done - - [ -n "$pincode" ] && { - uqmi -s -d "$device" --verify-pin1 "$pincode" > /dev/null || uqmi -s -d "$device" --uim-verify-pin1 "$pincode" > /dev/null || { - echo "Unable to verify PIN" - proto_notify_error "$interface" PIN_FAILED + if [ "$uninitialized_timeout" -lt "$timeout" ]; then + let uninitialized_timeout++ + sleep 1; + else + echo "SIM not initialized" + proto_notify_error "$interface" SIM_NOT_INITIALIZED proto_block_restart "$interface" return 1 + fi + done + + if uqmi -s -d "$device" --get-pin-status | grep '"Not supported"' > /dev/null; then + [ -n "$pincode" ] && { + uqmi -s -d "$device" --verify-pin1 "$pincode" > /dev/null || uqmi -s -d "$device" --uim-verify-pin1 "$pincode" > /dev/null || { + echo "Unable to verify PIN" + proto_notify_error "$interface" PIN_FAILED + proto_block_restart "$interface" + return 1 + } } - } + else + . /usr/share/libubox/jshn.sh + json_load "$(uqmi -s -d "$device" --get-pin-status)" + json_get_var pin1_status pin1_status + json_get_var pin1_verify_tries pin1_verify_tries + + case "$pin1_status" in + disabled) + echo "PIN verification is disabled" + ;; + blocked) + echo "SIM locked PUK required" + proto_notify_error "$interface" PUK_NEEDED + proto_block_restart "$interface" + return 1 + ;; + not_verified) + [ "$pin1_verify_tries" -lt "3" ] && { + echo "PIN verify count value is $pin1_verify_tries this is below the limit of 3" + proto_notify_error "$interface" PIN_TRIES_BELOW_LIMIT + proto_block_restart "$interface" + return 1 + } + if [ -n "$pincode" ]; then + uqmi -s -d "$device" --verify-pin1 "$pincode" > /dev/null 2>&1 || uqmi -s -d "$device" --uim-verify-pin1 "$pincode" > /dev/null 2>&1 || { + echo "Unable to verify PIN" + proto_notify_error "$interface" PIN_FAILED + proto_block_restart "$interface" + return 1 + } + else + echo "PIN not specified but required" + proto_notify_error "$interface" PIN_NOT_SPECIFIED + proto_block_restart "$interface" + return 1 + fi + ;; + verified) + echo "PIN already verified" + ;; + *) + echo "PIN status failed ($pin1_status)" + proto_notify_error "$interface" PIN_STATUS_FAILED + proto_block_restart "$interface" + return 1 + ;; + esac + fi [ -n "$plmn" ] && { local mcc mnc