[openwrt/openwrt] uqmi: fix network registration loop
LEDE Commits
lede-commits at lists.infradead.org
Sat May 8 03:33:16 PDT 2021
zorun pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/2eda042d553c23590c9d6ade8a1a17ffcfb4be7c
commit 2eda042d553c23590c9d6ade8a1a17ffcfb4be7c
Author: Thomas Richard <thomas.richard at kontron.com>
AuthorDate: Tue Apr 20 16:49:02 2021 +0200
uqmi: fix network registration loop
With some debug in qmi.sh using following patch, some errors are visible
in the registration step
@@ -29,6 +29,7 @@ proto_qmi_init_config() {
}
proto_qmi_setup() {
+ set -x
local interface="$1"
local dataformat connstat plmn_mode mcc mnc
local device apn auth username password pincode delay modes pdptype
@@ -224,6 +225,8 @@ proto_qmi_setup() {
fi
done
+ registration=$(uqmi -s -d "$device" --get-serving-system)
+
[ -n "$modes" ] && uqmi -s -d "$device" --set-network-modes "$modes" > /dev/null 2>&1
echo "Starting network $interface"
During the boot of the system, modem could not start automatically its
network registration.
netifd: wan (9235): + echo 'Waiting for network registration'
netifd: wan (9235): Waiting for network registration
netifd: wan (9235): + local 'registration_timeout=0'
netifd: wan (9235): + uqmi -s -d /dev/cdc-wdm1 --get-serving-system
netifd: wan (9235): + grep '"searching"'
netifd: wan (9235): + uqmi -s -d /dev/cdc-wdm1 --get-serving-system
netifd: wan (9235): + registration='{"registration":"not_registered","plmn_mcc":208,"plmn_mnc":20,"plmn_description":"","roaming":true}'
netifd: wan (9235): + '[' -n ]
netifd: wan (9235): + echo 'Starting network wan'
As the while loop checks only "searching" pattern, uqmi.sh script quits
searching loop and continues whereas the modem is not registered
Other issue, after X seconds modem stops searching.
netifd: wan (9213): + uqmi -s -d /dev/cdc-wdm0 --get-serving-system
netifd: wan (9213): + grep '"searching"'
netifd: wan (9213): + '[' -e /dev/cdc-wdm0 ]
netifd: wan (9213): + '[' 3 -lt 0 -o 0 '=' 0 ]
netifd: wan (9213): + let registration_timeout++
netifd: wan (9213): + sleep 1
netifd: wan (9213): + uqmi -s -d /dev/cdc-wdm0 --get-serving-system
netifd: wan (9213): + grep '"searching"'
netifd: wan (9213): + uqmi -s -d /dev/cdc-wdm0 --get-serving-system
netifd: wan (9213): + registration='{"registration":"not_registered"}'
netifd: wan (9213): + '[' -n ]
netifd: wan (9213): + echo 'Starting network wan'
netifd: wan (9213): Starting network wan
If registration_timeout is not expired, registration can be restarted
Signed-off-by: Thomas Richard <thomas.richard at kontron.com>
Tested-by: Florian Eckert <fe at dev.tdt.de>
---
package/network/utils/uqmi/Makefile | 2 +-
.../utils/uqmi/files/lib/netifd/proto/qmi.sh | 35 ++++++++++++++++------
2 files changed, 27 insertions(+), 10 deletions(-)
diff --git a/package/network/utils/uqmi/Makefile b/package/network/utils/uqmi/Makefile
index 68958a3729..da54ba0f46 100644
--- a/package/network/utils/uqmi/Makefile
+++ b/package/network/utils/uqmi/Makefile
@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=uqmi
-PKG_RELEASE:=2
+PKG_RELEASE:=3
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/uqmi.git
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 a6c785eb56..c0134f44dd 100755
--- a/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
+++ b/package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh
@@ -209,19 +209,36 @@ proto_qmi_setup() {
uqmi -s -d "$device" --sync > /dev/null 2>&1
+ uqmi -s -d "$device" --network-register > /dev/null 2>&1
+
echo "Waiting for network registration"
+ sleep 1
local registration_timeout=0
- while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do
- [ -e "$device" ] || return 1
- if [ "$registration_timeout" -lt "$timeout" -o "$timeout" = "0" ]; then
- let registration_timeout++
- sleep 1;
+ local registration_state=""
+ while true; do
+ registration_state=$(uqmi -s -d "$device" --get-serving-system 2>/dev/null | jsonfilter -e "@.registration" 2>/dev/null)
+
+ [ "$registration_state" = "registered" ] && break
+
+ if [ "$registration_state" = "searching" ] || [ "$registration_state" = "not_registered" ]; then
+ if [ "$registration_timeout" -lt "$timeout" ] || [ "$timeout" = "0" ]; then
+ [ "$registration_state" = "searching" ] || {
+ echo "Device stopped network registration. Restart network registration"
+ uqmi -s -d "$device" --network-register > /dev/null 2>&1
+ }
+ let registration_timeout++
+ sleep 1
+ continue
+ fi
+ echo "Network registration failed, registration timeout reached"
else
- echo "Network registration failed"
- proto_notify_error "$interface" NETWORK_REGISTRATION_FAILED
- proto_block_restart "$interface"
- return 1
+ # registration_state is 'registration_denied' or 'unknown' or ''
+ echo "Network registration failed (reason: '$registration_state')"
fi
+
+ proto_notify_error "$interface" NETWORK_REGISTRATION_FAILED
+ proto_block_restart "$interface"
+ return 1
done
[ -n "$modes" ] && uqmi -s -d "$device" --set-network-modes "$modes" > /dev/null 2>&1
More information about the lede-commits
mailing list