uqmi: set plmn only if necessary

Setting the plmn to '0' (auto) will implicitly lead to a (delayed)
network re-registration, which could further lead to some timing
related issues in the qmi proto handler.

On the other hand, if you switch back from manual plmn selection
to auto mode you have to set it to '0', because this setting is
permanently "saved" in the wwan module.

Conclusion:
If plmn is configured, check if it's already set euqally in the module.
If so, do nothing. Otherwise set it.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
This commit is contained in:
Martin Schiller 2019-08-28 07:24:33 +02:00 committed by Daniel Golle
parent bc64b9c32e
commit b4b829fe64
2 changed files with 22 additions and 8 deletions

View file

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=uqmi PKG_NAME:=uqmi
PKG_RELEASE:=1 PKG_RELEASE:=2
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/uqmi.git PKG_SOURCE_URL=$(PROJECT_GIT)/project/uqmi.git

View file

@ -30,7 +30,7 @@ proto_qmi_init_config() {
proto_qmi_setup() { proto_qmi_setup() {
local interface="$1" local interface="$1"
local dataformat connstat local dataformat connstat plmn_mode mcc mnc
local device apn auth username password pincode delay modes pdptype local device apn auth username password pincode delay modes pdptype
local profile dhcp dhcpv6 autoconnect plmn timeout mtu $PROTO_DEFAULT_OPTIONS local profile dhcp dhcpv6 autoconnect plmn timeout mtu $PROTO_DEFAULT_OPTIONS
local ip4table ip6table local ip4table ip6table
@ -152,24 +152,38 @@ proto_qmi_setup() {
esac esac
fi fi
[ -n "$plmn" ] && { if [ -n "$plmn" ]; then
local mcc mnc json_load "$(uqmi -s -d "$device" --get-plmn)"
if [ "$plmn" = 0 ]; then json_get_var plmn_mode mode
json_get_vars mcc mnc || {
mcc=0 mcc=0
mnc=0 mnc=0
echo "Setting PLMN to auto" }
else
if [ "$plmn" = "0" ]; then
if [ "$plmn_mode" != "automatic" ]; then
mcc=0
mnc=0
echo "Setting PLMN to auto"
fi
elif [ "$mcc" -ne "${plmn:0:3}" -o "$mnc" -ne "${plmn:3}" ]; then
mcc=${plmn:0:3} mcc=${plmn:0:3}
mnc=${plmn:3} mnc=${plmn:3}
echo "Setting PLMN to $plmn" echo "Setting PLMN to $plmn"
else
mcc=""
mnc=""
fi fi
fi
if [ -n "$mcc" -a -n "$mnc" ]; then
uqmi -s -d "$device" --set-plmn --mcc "$mcc" --mnc "$mnc" > /dev/null 2>&1 || { uqmi -s -d "$device" --set-plmn --mcc "$mcc" --mnc "$mnc" > /dev/null 2>&1 || {
echo "Unable to set PLMN" echo "Unable to set PLMN"
proto_notify_error "$interface" PLMN_FAILED proto_notify_error "$interface" PLMN_FAILED
proto_block_restart "$interface" proto_block_restart "$interface"
return 1 return 1
} }
} fi
# Cleanup current state if any # Cleanup current state if any
uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null 2>&1 uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null 2>&1