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
23 local device apn auth username password pincode delay modes cid pdh
24 json_get_vars device apn auth username password pincode delay modes
27 echo "No control device specified"
28 proto_notify_error
"$interface" NO_DEVICE
29 proto_block_restart
"$interface"
33 echo "The specified control device does not exist"
34 proto_notify_error
"$interface" NO_DEVICE
35 proto_block_restart
"$interface"
39 devname
="$(basename "$device")"
40 devpath
="$(readlink -f /sys/class/usbmisc/$devname/device/)"
41 ifname
="$( ls "$devpath"/net )"
43 echo "The interface could not be found."
44 proto_notify_error
"$interface" NO_IFACE
45 proto_block_restart
"$interface"
49 [ -n "$delay" ] && sleep "$delay"
51 while uqmi
-s -d "$device" --get-pin-status |
grep '"UIM uninitialized"' > /dev
/null
; do
55 [ -n "$pincode" ] && {
56 uqmi
-s -d "$device" --verify-pin1 "$pincode" ||
{
57 echo "Unable to verify PIN"
58 proto_notify_error
"$interface" PIN_FAILED
59 proto_block_restart
"$interface"
65 echo "No APN specified"
66 proto_notify_error
"$interface" NO_APN
67 proto_block_restart
"$interface"
71 echo "Waiting for network registration"
72 while uqmi
-s -d "$device" --get-serving-system |
grep '"searching"' > /dev
/null
; do
76 [ -n "$modes" ] && uqmi
-s -d "$device" --set-network-modes "$modes"
78 echo "Starting network $apn"
79 cid
=`uqmi -s -d "$device" --get-client-id wds`
81 echo "Unable to obtain client ID"
82 proto_notify_error
"$interface" NO_CID
83 proto_block_restart
"$interface"
86 uci_set_state network
$interface cid
"$cid"
88 pdh
=`uqmi -s -d "$device" --set-client-id wds,"$cid" --start-network "$apn" \
89 ${auth:+--auth-type $auth} \
90 ${username:+--username $username} \
91 ${password:+--password $password}`
93 echo "Unable to connect, check APN and authentication"
94 proto_notify_error
"$interface" NO_PDH
95 proto_block_restart
"$interface"
98 uci_set_state network
$interface pdh
"$pdh"
100 if ! uqmi
-s -d "$device" --get-data-status |
grep '"connected"' > /dev
/null
; then
101 echo "Connection lost"
102 proto_notify_error
"$interface" NOT_CONNECTED
103 proto_block_restart
"$interface"
107 echo "Connected, starting DHCP"
108 proto_init_update
"$ifname" 1
109 proto_send_update
"$interface"
112 json_add_string name
"${interface}_dhcp"
113 json_add_string ifname
"@$interface"
114 json_add_string proto
"dhcp"
116 ubus call network add_dynamic
"$(json_dump)"
119 json_add_string name
"${interface}_dhcpv6"
120 json_add_string ifname
"@$interface"
121 json_add_string proto
"dhcpv6"
123 ubus call network add_dynamic
"$(json_dump)"
126 proto_qmi_teardown
() {
131 local cid
=$
(uci_get_state network
$interface cid
)
132 local pdh
=$
(uci_get_state network
$interface pdh
)
134 echo "Stopping network"
137 uqmi
-s -d "$device" --set-client-id wds
,"$cid" --stop-network "$pdh"
138 uci_revert_state network
$interface pdh
140 uqmi
-s -d "$device" --set-client-id wds
,"$cid" --release-client-id wds
141 uci_revert_state network
$interface cid
144 proto_init_update
"*" 0
145 proto_send_update
"$interface"