3 [ -n "$INCLUDE_ONLY" ] ||
{
10 proto_mbim_init_config
() {
13 proto_config_add_string
"device:device"
14 proto_config_add_string apn
15 proto_config_add_string pincode
16 proto_config_add_string delay
17 proto_config_add_string auth
18 proto_config_add_string username
19 proto_config_add_string password
20 proto_config_add_defaults
28 local device apn pincode delay
$PROTO_DEFAULT_OPTIONS
29 json_get_vars device apn pincode delay auth username password
$PROTO_DEFAULT_OPTIONS
31 [ -n "$ctl_device" ] && device
=$ctl_device
34 echo "mbim[$$]" "No control device specified"
35 proto_notify_error
"$interface" NO_DEVICE
36 proto_set_available
"$interface" 0
40 echo "mbim[$$]" "The specified control device does not exist"
41 proto_notify_error
"$interface" NO_DEVICE
42 proto_set_available
"$interface" 0
46 devname
="$(basename "$device")"
47 devpath
="$(readlink -f /sys/class/usbmisc/$devname/device/)"
48 ifname
="$( ls "$devpath"/net )"
51 echo "mbim[$$]" "Failed to find matching interface"
52 proto_notify_error
"$interface" NO_IFNAME
53 proto_set_available
"$interface" 0
58 echo "mbim[$$]" "No APN specified"
59 proto_notify_error
"$interface" NO_APN
63 [ -n "$delay" ] && sleep "$delay"
65 echo "mbim[$$]" "Reading capabilities"
66 umbim
$DBG -n -d $device caps ||
{
67 echo "mbim[$$]" "Failed to read modem caps"
68 proto_notify_error
"$interface" PIN_FAILED
74 echo "mbim[$$]" "Sending pin"
75 umbim
$DBG -n -t $tid -d $device unlock
"$pincode" ||
{
76 echo "mbim[$$]" "Unable to verify PIN"
77 proto_notify_error
"$interface" PIN_FAILED
78 proto_block_restart
"$interface"
84 echo "mbim[$$]" "Checking pin"
85 umbim
$DBG -n -t $tid -d $device pinstate ||
{
86 echo "mbim[$$]" "PIN required"
87 proto_notify_error
"$interface" PIN_FAILED
88 proto_block_restart
"$interface"
93 echo "mbim[$$]" "Checking subscriber"
94 umbim
$DBG -n -t $tid -d $device subscriber ||
{
95 echo "mbim[$$]" "Subscriber init failed"
96 proto_notify_error
"$interface" NO_SUBSCRIBER
101 echo "mbim[$$]" "Register with network"
102 umbim
$DBG -n -t $tid -d $device registration ||
{
103 echo "mbim[$$]" "Subscriber registration failed"
104 proto_notify_error
"$interface" NO_REGISTRATION
109 echo "mbim[$$]" "Attach to network"
110 umbim
$DBG -n -t $tid -d $device attach ||
{
111 echo "mbim[$$]" "Failed to attach to network"
112 proto_notify_error
"$interface" ATTACH_FAILED
117 echo "mbim[$$]" "Connect to network"
118 while ! umbim
$DBG -n -t $tid -d $device connect
"$apn" "$auth" "$username" "$password"; do
124 uci_set_state network
$interface tid
"$tid"
126 echo "mbim[$$]" "Connected, starting DHCP"
127 proto_init_update
"$ifname" 1
128 proto_send_update
"$interface"
131 json_add_string name
"${interface}_4"
132 json_add_string ifname
"@$interface"
133 json_add_string proto
"dhcp"
134 proto_add_dynamic_defaults
136 ubus call network add_dynamic
"$(json_dump)"
139 json_add_string name
"${interface}_6"
140 json_add_string ifname
"@$interface"
141 json_add_string proto
"dhcpv6"
142 json_add_string extendprefix
1
143 proto_add_dynamic_defaults
144 ubus call network add_dynamic
"$(json_dump)"
154 logger
"mbim bringup failed, retry in 15s"
161 proto_mbim_teardown
() {
166 local tid
=$
(uci_get_state network
$interface tid
)
168 [ -n "$ctl_device" ] && device
=$ctl_device
170 echo "mbim[$$]" "Stopping network"
172 umbim
$DBG -t$tid -d "$device" disconnect
173 uci_revert_state network
$interface tid
176 proto_init_update
"*" 0
177 proto_send_update
"$interface"
180 [ -n "$INCLUDE_ONLY" ] || add_protocol mbim