uqmi: use built-in command for data-link verification
authorKoen Vandeputte <koen.vandeputte@ncentric.com>
Thu, 15 Feb 2018 14:16:03 +0000 (15:16 +0100)
committerJohn Crispin <john@phrozen.org>
Sun, 18 Feb 2018 08:35:01 +0000 (09:35 +0100)
uqmi contains a command for directly querying the modem if there
is a valid data connection, so let's use it.

This avoids the cases were all previous tests are succesful, but the
actual data link is not up for some reasons, leading to states were we
thought the link was up when it actually wasn't ..

Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
package/network/utils/uqmi/Makefile
package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh

index 6e891435b94143a319f89edf1f74f2cfe055a458..993069e256f89c0adaf7bbc0a295c33bc41f0d20 100644 (file)
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=uqmi
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(LEDE_GIT)/project/uqmi.git
index bdab5ee5143b5447342cacdfe7f716dd91b76c2b..c3da5ede26b14cae5e57d6f9b0f62edfc09421eb 100755 (executable)
@@ -27,7 +27,7 @@ proto_qmi_init_config() {
 
 proto_qmi_setup() {
        local interface="$1"
-       local dataformat
+       local dataformat connstat
        local device apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn $PROTO_DEFAULT_OPTIONS
        local cid_4 pdh_4 cid_6 pdh_6
        local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
@@ -164,6 +164,15 @@ proto_qmi_setup() {
                        proto_notify_error "$interface" CALL_FAILED
                        return 1
                fi
+
+        # Check data connection state
+               connstat=$(uqmi -s -d "$device" --get-data-status)
+                [ "$connstat" == '"connected"' ] || {
+                        echo "No data link!"
+                        uqmi -s -d "$device" --set-client-id wds,"$cid_4" --release-client-id wds
+                        proto_notify_error "$interface" CALL_FAILED
+                        return 1
+                }
        }
 
        [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && {
@@ -192,6 +201,15 @@ proto_qmi_setup() {
                        proto_notify_error "$interface" CALL_FAILED
                        return 1
                fi
+
+        # Check data connection state
+               connstat=$(uqmi -s -d "$device" --get-data-status)
+                [ "$connstat" == '"connected"' ] || {
+                        echo "No data link!"
+                        uqmi -s -d "$device" --set-client-id wds,"$cid_6" --release-client-id wds
+                        proto_notify_error "$interface" CALL_FAILED
+                        return 1
+                }
        }
 
        echo "Setting up $ifname"