netifd: mbim.sh: only check pin1 for failure
authorJames Christopher Adduono <jc@adduono.com>
Tue, 18 Jun 2019 21:52:29 +0000 (17:52 -0400)
committerJo-Philipp Wich <jo@mein.io>
Wed, 21 Feb 2024 21:31:36 +0000 (22:31 +0100)
Sierra MC7xxx and EM7xxx series cards will always respond
with 3 - pin2 required on pinstate check. We have to ignore
required pins other than pin1 and proceed in order to connect.

Signed-off-by: James Christopher Adduono <jc@adduono.com>
package/network/utils/umbim/files/lib/netifd/proto/mbim.sh

index 17b8a2b95bfa26cc7f9d90f34fb05853246bfa6a..b2aad158da1021f5fade4715dffb3ec62b5bb665 100755 (executable)
@@ -109,14 +109,18 @@ _proto_mbim_setup() {
        tid=$((tid + 1))
 
        echo "mbim[$$]" "Checking pin"
-       umbim $DBG -n -t $tid -d $device pinstate
-       [ $? -eq 2 ] && {
-               echo "mbim[$$]" "PIN required"
-               tid=$((tid + 1))
-               umbim $DBG -t $tid -d "$device" disconnect
-               proto_notify_error "$interface" PIN_FAILED
-               proto_block_restart "$interface"
-               return 1
+       local pinstate="/var/run/mbim.$$.pinstate"
+       umbim $DBG -n -t $tid -d $device pinstate > "$pinstate" 2>&1 || {
+               local pin=$(awk '$2=="pin:" {print $5}' "$pinstate")
+               # we only need pin1 (the SIM pin) to connect
+               [ "$pin" = "pin1" ] && {
+                       echo "mbim[$$]" "PIN required"
+                       tid=$((tid + 1))
+                       umbim $DBG -t $tid -d "$device" disconnect
+                       proto_notify_error "$interface" PIN_FAILED
+                       proto_block_restart "$interface"
+                       return 1
+               }
        }
        tid=$((tid + 1))
 
@@ -303,6 +307,8 @@ proto_mbim_setup() {
        _proto_mbim_setup $@
        ret=$?
 
+       rm -f "/var/run/mbim.$$."*
+
        [ "$ret" = 0 ] || {
                logger "mbim bringup failed, retry in 15s"
                sleep 15