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
27 local device apn pincode delay
28 json_get_vars device apn pincode delay auth username password
30 [ -n "$ctl_device" ] && device
=$ctl_device
33 echo "mbim[$$]" "No control device specified"
34 proto_notify_error
"$interface" NO_DEVICE
35 proto_set_available
"$interface" 0
39 echo "mbim[$$]" "The specified control device does not exist"
40 proto_notify_error
"$interface" NO_DEVICE
41 proto_set_available
"$interface" 0
45 devname
="$(basename "$device")"
46 devpath
="$(readlink -f /sys/class/usbmisc/$devname/device/)"
47 ifname
="$( ls "$devpath"/net )"
50 echo "mbim[$$]" "Failed to find matching interface"
51 proto_notify_error
"$interface" NO_IFNAME
52 proto_set_available
"$interface" 0
57 echo "mbim[$$]" "No APN specified"
58 proto_notify_error
"$interface" NO_APN
62 [ -n "$delay" ] && sleep "$delay"
64 echo "mbim[$$]" "Reading capabilities"
65 umbim
$DBG -n -d $device caps ||
{
66 echo "mbim[$$]" "Failed to read modem caps"
67 proto_notify_error
"$interface" PIN_FAILED
73 echo "mbim[$$]" "Sending pin"
74 umbim
$DBG -n -t $tid -d $device unlock
"$pincode" ||
{
75 echo "mbim[$$]" "Unable to verify PIN"
76 proto_notify_error
"$interface" PIN_FAILED
77 proto_block_restart
"$interface"
83 echo "mbim[$$]" "Checking pin"
84 umbim
$DBG -n -t $tid -d $device pinstate ||
{
85 echo "mbim[$$]" "PIN required"
86 proto_notify_error
"$interface" PIN_FAILED
87 proto_block_restart
"$interface"
92 echo "mbim[$$]" "Checking subscriber"
93 umbim
$DBG -n -t $tid -d $device subscriber ||
{
94 echo "mbim[$$]" "Subscriber init failed"
95 proto_notify_error
"$interface" NO_SUBSCRIBER
100 echo "mbim[$$]" "Register with network"
101 umbim
$DBG -n -t $tid -d $device registration ||
{
102 echo "mbim[$$]" "Subscriber registration failed"
103 proto_notify_error
"$interface" NO_REGISTRATION
108 echo "mbim[$$]" "Attach to network"
109 umbim
$DBG -n -t $tid -d $device attach ||
{
110 echo "mbim[$$]" "Failed to attach to network"
111 proto_notify_error
"$interface" ATTACH_FAILED
116 echo "mbim[$$]" "Connect to network"
117 while ! umbim
$DBG -n -t $tid -d $device connect
"$apn" "$auth" "$username" "$password"; do
123 uci_set_state network
$interface tid
"$tid"
125 echo "mbim[$$]" "Connected, starting DHCP"
126 proto_init_update
"$ifname" 1
127 proto_send_update
"$interface"
130 json_add_string name
"${interface}_4"
131 json_add_string ifname
"@$interface"
132 json_add_string proto
"dhcp"
134 ubus call network add_dynamic
"$(json_dump)"
137 json_add_string name
"${interface}_6"
138 json_add_string ifname
"@$interface"
139 json_add_string proto
"dhcpv6"
140 ubus call network add_dynamic
"$(json_dump)"
143 proto_mbim_teardown
() {
148 local tid
=$
(uci_get_state network
$interface tid
)
150 [ -n "$ctl_device" ] && device
=$ctl_device
152 echo "mbim[$$]" "Stopping network"
154 umbim
$DBG -t$tid -d "$device" disconnect
155 uci_revert_state network
$interface tid
158 proto_init_update
"*" 0
159 proto_send_update
"$interface"
162 [ -n "$INCLUDE_ONLY" ] || add_protocol mbim