Skip to content
Snippets Groups Projects
Commit 4955a2cd authored by Felix Fietkau's avatar Felix Fietkau
Browse files

uqmi: use the autoconnect feature


Instead of connecting once and saving the packet data handle, let the
firmware handle connecting/reconnecting automatically. This is more
reliable and reduces reliance on potentially stale data.

Use the global packet data handle to attempt to disable autoconnect
before restarting the connection. This ensures that the firmware will
take the new APN/auth settings.

Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>

SVN-Revision: 42721
parent b54144a4
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,14 @@ proto_qmi_init_config() { ...@@ -17,6 +17,14 @@ proto_qmi_init_config() {
proto_config_add_string modes proto_config_add_string modes
} }
qmi_disconnect() {
# disable previous autoconnect state using the global handle
# do not reuse previous wds client id to prevent hangs caused by stale data
uqmi -s -d "$device" \
--stop-network 0xffffffff \
--autoconnect > /dev/null
}
proto_qmi_setup() { proto_qmi_setup() {
local interface="$1" local interface="$1"
...@@ -68,6 +76,8 @@ proto_qmi_setup() { ...@@ -68,6 +76,8 @@ proto_qmi_setup() {
return 1 return 1
} }
qmi_disconnect
echo "Waiting for network registration" echo "Waiting for network registration"
while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do
sleep 5; sleep 5;
...@@ -83,24 +93,17 @@ proto_qmi_setup() { ...@@ -83,24 +93,17 @@ proto_qmi_setup() {
proto_block_restart "$interface" proto_block_restart "$interface"
return 1 return 1
} }
uci_set_state network $interface cid "$cid"
pdh=`uqmi -s -d "$device" --set-client-id wds,"$cid" --start-network "$apn" \ uqmi -s -d "$device" --set-client-id wds,"$cid" \
${auth:+--auth-type $auth} \ --start-network "$apn" \
${username:+--username $username} \ ${auth:+--auth-type $auth} \
${password:+--password $password}` ${username:+--username $username} \
[ $? -ne 0 ] && { ${password:+--password $password} \
echo "Unable to connect, check APN and authentication" --autoconnect > /dev/null
proto_notify_error "$interface" NO_PDH
proto_block_restart "$interface"
return 1
}
uci_set_state network $interface pdh "$pdh"
if ! uqmi -s -d "$device" --get-data-status | grep '"connected"' > /dev/null; then if ! uqmi -s -d "$device" --get-data-status | grep '"connected"' > /dev/null; then
echo "Connection lost" echo "Connection lost"
proto_notify_error "$interface" NOT_CONNECTED proto_notify_error "$interface" NOT_CONNECTED
proto_block_restart "$interface"
return 1 return 1
fi fi
...@@ -129,14 +132,10 @@ proto_qmi_teardown() { ...@@ -129,14 +132,10 @@ proto_qmi_teardown() {
local device local device
json_get_vars device json_get_vars device
local cid=$(uci_get_state network $interface cid) local cid=$(uci_get_state network $interface cid)
local pdh=$(uci_get_state network $interface pdh)
echo "Stopping network" echo "Stopping network"
qmi_disconnect
[ -n "$cid" ] && { [ -n "$cid" ] && {
[ -n "$pdh" ] && {
uqmi -s -d "$device" --set-client-id wds,"$cid" --stop-network "$pdh"
uci_revert_state network $interface pdh
}
uqmi -s -d "$device" --set-client-id wds,"$cid" --release-client-id wds uqmi -s -d "$device" --set-client-id wds,"$cid" --release-client-id wds
uci_revert_state network $interface cid uci_revert_state network $interface cid
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment