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>
Sun, 26 Jan 2025 13:07:08 +0000 (14:07 +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 c5911a15e5fd80d66776fde1c4b8d0617f9f1eea..2d3857e240638706b75bc03e145938a2cd662d4d 100755 (executable)
@@ -115,14 +115,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))
 
@@ -311,6 +315,8 @@ proto_mbim_setup() {
        _proto_mbim_setup $@
        ret=$?
 
+       rm -f "/var/run/mbim.$$."*
+
        [ "$ret" = 0 ] || {
                logger "mbim bringup failed, retry in 15s"
                sleep 15