12 proto_mbim_setup
() { echo "wwan[$$] mbim proto is missing"; }
13 proto_qmi_setup
() { echo "wwan[$$] qmi proto is missing"; }
14 proto_ncm_setup
() { echo "wwan[$$] ncm proto is missing"; }
15 proto_3g_setup
() { echo "wwan[$$] 3g proto is missing"; }
16 proto_directip_setup
() { echo "wwan[$$] directip proto is missing"; }
18 [ -f .
/mbim.sh
] && . .
/mbim.sh
19 [ -f .
/ncm.sh
] && . .
/ncm.sh
20 [ -f .
/qmi.sh
] && . .
/qmi.sh
21 [ -f .
/3g.sh
] && { . .
/ppp.sh
; . .
/3g.sh
; }
22 [ -f .
/directip.sh
] && . .
/directip.sh
24 proto_wwan_init_config
() {
28 proto_config_add_string apn
29 proto_config_add_string auth
30 proto_config_add_string username
31 proto_config_add_string password
32 proto_config_add_string pincode
33 proto_config_add_string delay
34 proto_config_add_string modes
38 local driver usb devicename desc
40 for a
in `ls /sys/bus/usb/devices`; do
42 [ -z "$usb" -a -f /sys
/bus
/usb
/devices
/$a/idVendor
-a -f /sys
/bus
/usb
/devices
/$a/idProduct
] ||
continue
43 vendor
=$
(cat /sys
/bus
/usb
/devices
/$a/idVendor
)
44 product
=$
(cat /sys
/bus
/usb
/devices
/$a/idProduct
)
45 [ -f /lib
/network
/wwan
/$vendor:$product ] && {
46 usb
=/lib
/network
/wwan
/$vendor:$product
52 local old_cb control data
54 json_set_namespace wwan old_cb
56 json_load
"$(cat $usb)"
58 json_get_vars desc control data
59 json_set_namespace
$old_cb
61 [ -n "$control" -a -n "$data" ] && {
62 ttys
=$
(ls -d /sys
/bus
/usb
/devices
/$devicename/${devicename}*/tty?
* /sys
/bus
/usb
/devices
/$devicename/${devicename}*/tty
/tty?
* |
sed "s/.*\///g" |
tr "\n" " ")
63 ctl_device
=/dev
/$
(echo $ttys | cut
-d" " -f $
((control
+ 1)))
64 dat_device
=/dev
/$
(echo $ttys | cut
-d" " -f $
((data
+ 1)))
69 [ -z "$ctl_device" ] && for net
in $
(ls /sys
/class
/net
/ |
grep -e wwan
-e usb
); do
70 [ -z "$ctl_device" ] ||
continue
71 driver
=$
(grep DRIVER
/sys
/class
/net
/$net/device
/uevent | cut
-d= -f2)
74 ctl_device
=/dev
/$
(ls /sys
/class
/net
/$net/device
/usbmisc
)
76 sierra_net|cdc_ether|
*cdc_ncm
)
77 ctl_device
=/dev
/$
(cd /sys
/class
/net
/$net/; find ..
/..
/..
/ -name ttyUSB
* |
xargs -n1 basename |
head -n1)
81 echo "wwan[$$]" "Using proto:$proto device:$ctl_device iface:$net desc:$desc"
84 [ -n "$ctl_device" ] ||
{
85 echo "wwan[$$]" "No valid device was found"
86 proto_notify_error
"$interface" NO_DEVICE
87 proto_block_restart
"$interface"
91 uci_set_state network
$interface driver
"$driver"
92 uci_set_state network
$interface ctl_device
"$ctl_device"
93 uci_set_state network
$interface dat_device
"$dat_device"
96 qmi_wwan
) proto_qmi_setup $@
;;
97 cdc_mbim
) proto_mbim_setup $@
;;
98 sierra_net
) proto_directip_setup $@
;;
99 comgt
) proto_3g_setup $@
;;
100 cdc_ether|
*cdc_ncm
) proto_ncm_setup $@
;;
104 proto_wwan_teardown
() {
106 local driver
=$
(uci_get_state network
$interface driver
)
107 ctl_device
=$
(uci_get_state network
$interface ctl_device
)
108 dat_device
=$
(uci_get_state network
$interface dat_device
)
111 qmi_wwan
) proto_qmi_teardown $@
;;
112 cdc_mbim
) proto_mbim_teardown $@
;;
113 sierra_net
) proto_directip_teardown $@
;;
114 comgt
) proto_3g_teardown $@
;;
115 cdc_ether|
*cdc_ncm
) proto_ncm_teardown $@
;;