uqmi: update to git HEAD and improve proto handler script
[openwrt/staging/thess.git] / package / network / utils / uqmi / files / lib / netifd / proto / qmi.sh
index c0134f44dde3e5755456744c7f083013f8580ac9..156e57b13529195961e5ce5194ef3ffe9e30bd71 100755 (executable)
@@ -94,7 +94,8 @@ proto_qmi_setup() {
                fi
        done
 
-       if uqmi -s -d "$device" --get-pin-status | grep '"Not supported"\|"Invalid QMI command"' > /dev/null; then
+       if uqmi -s -d "$device" --uim-get-sim-state | grep -q '"Not supported"\|"Invalid QMI command"' &&
+          uqmi -s -d "$device" --get-pin-status | grep -q '"Not supported"\|"Invalid QMI command"' ; 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"
@@ -105,7 +106,8 @@ proto_qmi_setup() {
                }
        else
                . /usr/share/libubox/jshn.sh
-               json_load "$(uqmi -s -d "$device" --get-pin-status)"
+               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_get_var pin1_status pin1_status
                json_get_var pin1_verify_tries pin1_verify_tries
 
@@ -144,7 +146,7 @@ proto_qmi_setup() {
                                echo "PIN already verified"
                                ;;
                        *)
-                               echo "PIN status failed ($pin1_status)"
+                               echo "PIN status failed (${pin1_status:-sim_not_present})"
                                proto_notify_error "$interface" PIN_STATUS_FAILED
                                proto_block_restart "$interface"
                                return 1