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
92 uqmi -s -d "$device" --wda-set-data-format 802.3
94 echo "Waiting for network registration"
95 while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do
99 [ -n "$modes" ] && uqmi -s -d "$device" --set-network-modes "$modes"
101 echo "Starting network $apn"
102 cid=`uqmi -s -d "$device" --get-client-id wds`
104 echo "Unable to obtain client ID"
105 proto_notify_error "$interface" NO_CID
109 uqmi -s -d "$device" --set-client-id wds,"$cid" \
110 --start-network "$apn" \
111 ${auth:+--auth-type $auth} \
112 ${username:+--username $username} \
113 ${password:+--password $password} \
114 --autoconnect > /dev/null
117 proto_init_update "$ifname" 1
118 proto_send_update "$interface"
121 json_add_string name "${interface}_4"
122 json_add_string ifname "@$interface"
123 json_add_string proto "dhcp"
125 ubus call network add_dynamic "$(json_dump)"
128 json_add_string name "${interface}_6"
129 json_add_string ifname "@$interface"
130 json_add_string proto "dhcpv6"
132 ubus call network add_dynamic "$(json_dump)"
142 logger "qmi bringup failed, retry in 15s"
149 proto_qmi_teardown() {
155 [ -n "$ctl_device" ] && device=$ctl_device
157 local cid=$(uci_get_state network $interface cid)
159 echo "Stopping network"
163 proto_init_update "*" 0
164 proto_send_update "$interface"
167 [ -n "$INCLUDE_ONLY" ] || {