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_set_available
"$interface" 0
48 echo "The specified control device does not exist"
49 proto_notify_error
"$interface" NO_DEVICE
50 proto_set_available
"$interface" 0
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_set_available
"$interface" 0
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
87 uqmi
-s -d "$device" --set-data-format 802.3
89 echo "Waiting for network registration"
90 while uqmi
-s -d "$device" --get-serving-system |
grep '"searching"' > /dev
/null
; do
94 [ -n "$modes" ] && uqmi
-s -d "$device" --set-network-modes "$modes"
96 echo "Starting network $apn"
97 cid
=`uqmi -s -d "$device" --get-client-id wds`
99 echo "Unable to obtain client ID"
100 proto_notify_error
"$interface" NO_CID
104 uqmi
-s -d "$device" --set-client-id wds
,"$cid" \
105 --start-network "$apn" \
106 ${auth:+--auth-type $auth} \
107 ${username:+--username $username} \
108 ${password:+--password $password} \
109 --autoconnect > /dev
/null
112 proto_init_update
"$ifname" 1
113 proto_send_update
"$interface"
116 json_add_string name
"${interface}_dhcp"
117 json_add_string ifname
"@$interface"
118 json_add_string proto
"dhcp"
120 ubus call network add_dynamic
"$(json_dump)"
123 json_add_string name
"${interface}_dhcpv6"
124 json_add_string ifname
"@$interface"
125 json_add_string proto
"dhcpv6"
127 ubus call network add_dynamic
"$(json_dump)"
130 proto_qmi_teardown
() {
135 local cid
=$
(uci_get_state network
$interface cid
)
137 echo "Stopping network"
141 proto_init_update
"*" 0
142 proto_send_update
"$interface"