7 proto_qmi_init_config
() {
8 proto_config_add_string
"device:device"
9 proto_config_add_string apn
10 proto_config_add_string auth
11 proto_config_add_string username
12 proto_config_add_string password
13 proto_config_add_string pincode
14 proto_config_add_string delay
15 proto_config_add_string modes
21 local device apn auth username password pincode delay modes cid pdh
22 json_get_vars device apn auth username password pincode delay modes
25 logger
-p daemon.err
-t "qmi[$$]" "No control device specified"
26 proto_notify_error
"$interface" NO_DEVICE
27 proto_block_restart
"$interface"
31 logger
-p daemon.err
-t "qmi[$$]" "The specified control device does not exist"
32 proto_notify_error
"$interface" NO_DEVICE
33 proto_block_restart
"$interface"
37 [ -n "$delay" ] && sleep "$delay"
39 while uqmi
-s -d "$device" --get-pin-status |
grep '"UIM uninitialized"' > /dev
/null
; do
43 [ -n "$pincode" ] && {
44 uqmi
-s -d "$device" --verify-pin1 "$pincode" ||
{
45 logger
-p daemon.err
-t "qmi[$$]" "Unable to verify PIN"
46 proto_notify_error
"$interface" PIN_FAILED
47 proto_block_restart
"$interface"
53 logger
-p daemon.err
-t "qmi[$$]" "No APN specified"
54 proto_notify_error
"$interface" NO_APN
55 proto_block_restart
"$interface"
59 logger
-p daemon.info
-t "qmi[$$]" "Waiting for network registration"
60 while uqmi
-s -d "$device" --get-serving-system |
grep '"searching"' > /dev
/null
; do
64 [ -n "$modes" ] && uqmi
-s -d "$device" --set-network-modes "$modes"
66 logger
-p daemon.info
-t "qmi[$$]" "Starting network $apn"
67 cid
=`uqmi -s -d "$device" --get-client-id wds`
69 logger
-p daemon.err
-t "qmi[$$]" "Unable to obtain client ID"
70 proto_notify_error
"$interface" NO_CID
71 proto_block_restart
"$interface"
74 uci_set_state network
$interface cid
"$cid"
76 pdh
=`uqmi -s -d "$device" --set-client-id wds,"$cid" --start-network "$apn" \
77 ${auth:+--auth-type $auth} \
78 ${username:+--username $username} \
79 ${password:+--password $password}`
81 logger
-p daemon.err
-t "qmi[$$]" "Unable to connect, check APN and authentication"
82 proto_notify_error
"$interface" NO_PDH
83 proto_block_restart
"$interface"
86 uci_set_state network
$interface pdh
"$pdh"
88 if ! uqmi
-s -d "$device" --get-data-status |
grep '"connected"' > /dev
/null
; then
89 logger
-p daemon.err
-t "qmi[$$]" "Connection lost"
90 proto_notify_error
"$interface" NOT_CONNECTED
91 proto_block_restart
"$interface"
95 logger
-p daemon.info
-t "qmi[$$]" "Connected, starting DHCP"
96 proto_init_update
"*" 1
97 proto_send_update
"$interface"
100 json_add_string name
"${interface}_dhcp"
101 json_add_string ifname
"@$interface"
102 json_add_string proto
"dhcp"
104 ubus call network add_dynamic
"$(json_dump)"
107 json_add_string name
"${interface}_dhcpv6"
108 json_add_string ifname
"@$interface"
109 json_add_string proto
"dhcpv6"
111 ubus call network add_dynamic
"$(json_dump)"
114 proto_qmi_teardown
() {
119 local cid
=$
(uci_get_state network
$interface cid
)
120 local pdh
=$
(uci_get_state network
$interface pdh
)
122 logger
-p daemon.info
-t "qmi[$$]" "Stopping network"
125 uqmi
-s -d "$device" --set-client-id wds
,"$cid" --stop-network "$pdh"
126 uci_revert_state network
$interface pdh
128 uqmi
-s -d "$device" --set-client-id wds
,"$cid" --release-client-id wds
129 uci_revert_state network
$interface cid
132 proto_init_update
"*" 0
133 proto_send_update
"$interface"