diff options
Diffstat (limited to 'package/network/utils/uqmi/files/lib/netifd')
-rwxr-xr-x | package/network/utils/uqmi/files/lib/netifd/proto/qmi.sh | 35 |
1 files changed, 26 insertions, 9 deletions
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 |