3 [ -n "$INCLUDE_ONLY" ] ||
{
9 proto_qmi_init_config
() {
12 proto_config_add_string
"device:device"
13 proto_config_add_string apn
14 proto_config_add_string auth
15 proto_config_add_string username
16 proto_config_add_string password
17 proto_config_add_string pincode
18 proto_config_add_string delay
19 proto_config_add_string modes
23 # disable previous autoconnect state using the global handle
24 # do not reuse previous wds client id to prevent hangs caused by stale data
25 uqmi
-s -d "$device" \
26 --stop-network 0xffffffff \
27 --autoconnect > /dev
/null
31 [ -n "$cid" ] ||
return 0
33 uqmi
-s -d "$device" --set-client-id wds
,"$cid" --release-client-id wds
34 uci_revert_state network
$interface cid
40 local device apn auth username password pincode delay modes cid pdh
41 json_get_vars device apn auth username password pincode delay modes
43 [ -n "$ctl_device" ] && device
=$ctl_device
46 echo "No control device specified"
47 proto_notify_error
"$interface" NO_DEVICE
48 proto_set_available
"$interface" 0
52 echo "The specified control device does not exist"
53 proto_notify_error
"$interface" NO_DEVICE
54 proto_set_available
"$interface" 0
58 devname
="$(basename "$device")"
59 devpath
="$(readlink -f /sys/class/usbmisc/$devname/device/)"
60 ifname
="$( ls "$devpath"/net )"
62 echo "The interface could not be found."
63 proto_notify_error
"$interface" NO_IFACE
64 proto_set_available
"$interface" 0
68 [ -n "$delay" ] && sleep "$delay"
70 while uqmi
-s -d "$device" --get-pin-status |
grep '"UIM uninitialized"' > /dev
/null
; do
74 [ -n "$pincode" ] && {
75 uqmi
-s -d "$device" --verify-pin1 "$pincode" ||
{
76 echo "Unable to verify PIN"
77 proto_notify_error
"$interface" PIN_FAILED
78 proto_block_restart
"$interface"
84 echo "No APN specified"
85 proto_notify_error
"$interface" NO_APN
91 uqmi
-s -d "$device" --set-data-format 802.3
93 echo "Waiting for network registration"
94 while uqmi
-s -d "$device" --get-serving-system |
grep '"searching"' > /dev
/null
; do
98 [ -n "$modes" ] && uqmi
-s -d "$device" --set-network-modes "$modes"
100 echo "Starting network $apn"
101 cid
=`uqmi -s -d "$device" --get-client-id wds`
103 echo "Unable to obtain client ID"
104 proto_notify_error
"$interface" NO_CID
108 uqmi
-s -d "$device" --set-client-id wds
,"$cid" \
109 --start-network "$apn" \
110 ${auth:+--auth-type $auth} \
111 ${username:+--username $username} \
112 ${password:+--password $password} \
113 --autoconnect > /dev
/null
116 proto_init_update
"$ifname" 1
117 proto_send_update
"$interface"
120 json_add_string name
"${interface}_dhcp"
121 json_add_string ifname
"@$interface"
122 json_add_string proto
"dhcp"
124 ubus call network add_dynamic
"$(json_dump)"
127 json_add_string name
"${interface}_dhcpv6"
128 json_add_string ifname
"@$interface"
129 json_add_string proto
"dhcpv6"
131 ubus call network add_dynamic
"$(json_dump)"
134 proto_qmi_teardown
() {
140 [ -n "$ctl_device" ] && device
=$ctl_device
142 local cid
=$
(uci_get_state network
$interface cid
)
144 echo "Stopping network"
148 proto_init_update
"*" 0
149 proto_send_update
"$interface"
152 [ -n "$INCLUDE_ONLY" ] ||
{