7 proto_qmi_init_config
() {
10 proto_config_add_string
"device:device"
11 proto_config_add_string apn
12 proto_config_add_string auth
13 proto_config_add_string username
14 proto_config_add_string password
15 proto_config_add_string pincode
16 proto_config_add_string delay
17 proto_config_add_string modes
21 # disable previous autoconnect state using the global handle
22 # do not reuse previous wds client id to prevent hangs caused by stale data
23 uqmi
-s -d "$device" \
24 --stop-network 0xffffffff \
25 --autoconnect > /dev
/null
29 [ -n "$cid" ] ||
return 0
31 uqmi
-s -d "$device" --set-client-id wds
,"$cid" --release-client-id wds
32 uci_revert_state network
$interface cid
38 local device apn auth username password pincode delay modes cid pdh
39 json_get_vars device apn auth username password pincode delay modes
42 echo "No control device specified"
43 proto_notify_error
"$interface" NO_DEVICE
44 proto_block_restart
"$interface"
48 echo "The specified control device does not exist"
49 proto_notify_error
"$interface" NO_DEVICE
50 proto_block_restart
"$interface"
54 devname
="$(basename "$device")"
55 devpath
="$(readlink -f /sys/class/usbmisc/$devname/device/)"
56 ifname
="$( ls "$devpath"/net )"
58 echo "The interface could not be found."
59 proto_notify_error
"$interface" NO_IFACE
60 proto_block_restart
"$interface"
64 [ -n "$delay" ] && sleep "$delay"
66 while uqmi
-s -d "$device" --get-pin-status |
grep '"UIM uninitialized"' > /dev
/null
; do
70 [ -n "$pincode" ] && {
71 uqmi
-s -d "$device" --verify-pin1 "$pincode" ||
{
72 echo "Unable to verify PIN"
73 proto_notify_error
"$interface" PIN_FAILED
74 proto_block_restart
"$interface"
80 echo "No APN specified"
81 proto_notify_error
"$interface" NO_APN
82 proto_block_restart
"$interface"
88 uqmi
-s -d "$device" --set-data-format 802.3
90 echo "Waiting for network registration"
91 while uqmi
-s -d "$device" --get-serving-system |
grep '"searching"' > /dev
/null
; do
95 [ -n "$modes" ] && uqmi
-s -d "$device" --set-network-modes "$modes"
97 echo "Starting network $apn"
98 cid
=`uqmi -s -d "$device" --get-client-id wds`
100 echo "Unable to obtain client ID"
101 proto_notify_error
"$interface" NO_CID
102 proto_block_restart
"$interface"
106 uqmi
-s -d "$device" --set-client-id wds
,"$cid" \
107 --start-network "$apn" \
108 ${auth:+--auth-type $auth} \
109 ${username:+--username $username} \
110 ${password:+--password $password} \
111 --autoconnect > /dev
/null
114 proto_init_update
"$ifname" 1
115 proto_send_update
"$interface"
118 json_add_string name
"${interface}_dhcp"
119 json_add_string ifname
"@$interface"
120 json_add_string proto
"dhcp"
122 ubus call network add_dynamic
"$(json_dump)"
125 json_add_string name
"${interface}_dhcpv6"
126 json_add_string ifname
"@$interface"
127 json_add_string proto
"dhcpv6"
129 ubus call network add_dynamic
"$(json_dump)"
132 proto_qmi_teardown
() {
137 local cid
=$
(uci_get_state network
$interface cid
)
139 echo "Stopping network"
143 proto_init_update
"*" 0
144 proto_send_update
"$interface"