9 proto_mbim_init_config
() {
10 proto_config_add_string
"device:device"
11 proto_config_add_string apn
12 proto_config_add_string pincode
13 proto_config_add_string delay
14 proto_config_add_string auth
15 proto_config_add_string username
16 proto_config_add_string password
24 local device apn pincode delay
25 json_get_vars device apn pincode delay auth username password
28 logger
-p daemon.err
-t "mbim[$$]" "No control device specified"
29 proto_notify_error
"$interface" NO_DEVICE
30 proto_block_restart
"$interface"
34 logger
-p daemon.err
-t "mbim[$$]" "The specified control device does not exist"
35 proto_notify_error
"$interface" NO_DEVICE
36 proto_block_restart
"$interface"
40 logger
-p daemon.err
-t "mbim[$$]" "No APN specified"
41 proto_notify_error
"$interface" NO_APN
42 proto_block_restart
"$interface"
46 [ -n "$delay" ] && sleep "$delay"
48 logger
-p daemon.info
-t "mbim[$$]" "Reading capabilities"
49 umbim
$DBG -n -d $device caps ||
{
50 logger
-p daemon.err
-t "mbim[$$]" "Failed to read modem caps"
51 proto_notify_error
"$interface" PIN_FAILED
52 proto_block_restart
"$interface"
58 logger
-p daemon.info
-t "mbim[$$]" "Sending pin"
59 umbim
$DBG -n -t $tid -d $device unlock
"$pincode" ||
{
60 logger
-p daemon.err
-t "mbim[$$]" "Unable to verify PIN"
61 proto_notify_error
"$interface" PIN_FAILED
62 proto_block_restart
"$interface"
68 logger
-p daemon.info
-t "mbim[$$]" "Checking pin"
69 umbim
$DBG -n -t $tid -d $device pinstate ||
{
70 logger
-p daemon.err
-t "mbim[$$]" "PIN required"
71 proto_notify_error
"$interface" PIN_FAILED
72 proto_block_restart
"$interface"
77 logger
-p daemon.info
-t "mbim[$$]" "Checking subscriber"
78 umbim
$DBG -n -t $tid -d $device subscriber ||
{
79 logger
-p daemon.err
-t "mbim[$$]" "Subscriber init failed"
80 proto_notify_error
"$interface" NO_SUBSCRIBER
81 proto_block_restart
"$interface"
86 logger
-p daemon.info
-t "mbim[$$]" "Register with network"
87 umbim
$DBG -n -t $tid -d $device registration ||
{
88 logger
-p daemon.err
-t "mbim[$$]" "Subscriber registration failed"
89 proto_notify_error
"$interface" NO_REGISTRATION
90 proto_block_restart
"$interface"
95 logger
-p daemon.info
-t "mbim[$$]" "Attach to network"
96 umbim
$DBG -n -t $tid -d $device attach ||
{
97 logger
-p daemon.err
-t "mbim[$$]" "Failed to attach to network"
98 proto_notify_error
"$interface" ATTACH_FAILED
99 proto_block_restart
"$interface"
104 logger
-p daemon.info
-t "mbim[$$]" "Connect to network"
105 while ! umbim
$DBG -n -t $tid -d $device connect
"$apn" "$auth" "$username" "$password"; do
111 uci_set_state network
$interface tid
"$tid"
113 logger
-p daemon.info
-t "mbim[$$]" "Connected, starting DHCP"
114 proto_init_update
"*" 1
115 proto_send_update
"$interface"
118 json_add_string name
"${interface}_dhcp"
119 json_add_string ifname
"@$interface"
120 json_add_string proto
"dhcp"
122 ubus call network add_dynamic
"$(json_dump)"
125 json_add_string name
"${interface}_dhcpv6"
126 json_add_string ifname
"@$interface"
127 json_add_string proto
"dhcpv6"
128 ubus call network add_dynamic
"$(json_dump)"
131 proto_mbim_teardown
() {
136 local tid
=$
(uci_get_state network
$interface tid
)
138 logger
-p daemon.info
-t "mbim[$$]" "Stopping network"
140 umbim
$DBG -t$tid -d "$device" disconnect
141 uci_revert_state network
$interface tid
144 proto_init_update
"*" 0
145 proto_send_update
"$interface"