3 [ -n "$INCLUDE_ONLY" ] ||
{
9 proto_ncm_init_config
() {
12 proto_config_add_string
"device:device"
13 proto_config_add_string apn
14 proto_config_add_string auth
15 proto_config_add_string username
16 proto_config_add_string password
17 proto_config_add_string pincode
18 proto_config_add_string delay
19 proto_config_add_string mode
25 local manufacturer initialize setmode connect ifname devname devpath
27 local device apn auth username password pincode delay mode
28 json_get_vars device apn auth username password pincode delay mode
31 echo "No control device specified"
32 proto_notify_error
"$interface" NO_DEVICE
33 proto_set_available
"$interface" 0
37 echo "Control device not valid"
38 proto_set_available
"$interface" 0
42 echo "No APN specified"
43 proto_notify_error
"$interface" NO_APN
44 proto_set_available
"$interface" 0
48 devname
="$(basename "$device")"
51 devpath
="$(readlink -f /sys/class/tty/$devname/device)"
52 ifname
="$( ls "$devpath"/../../*/net )"
55 devpath
="$(readlink -f /sys/class/usbmisc/$devname/device/)"
56 ifname
="$( ls "$devpath"/net )"
60 echo "The interface could not be found."
61 proto_notify_error
"$interface" NO_IFACE
62 proto_set_available
"$interface" 0
66 [ -n "$delay" ] && sleep "$delay"
68 manufacturer
=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'`
70 echo "Failed to get modem information"
71 proto_notify_error
"$interface" GETINFO_FAILED
72 proto_set_available
"$interface" 0
76 json_load
"$(cat /etc/gcom/ncm.json)"
77 json_select
"$manufacturer"
79 echo "Unsupported modem"
80 proto_notify_error
"$interface" UNSUPPORTED_MODEM
81 proto_set_available
"$interface" 0
84 json_get_values initialize initialize
85 for i
in $initialize; do
86 eval COMMAND
="$i" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
87 echo "Failed to initialize modem"
88 proto_notify_error
"$interface" INITIALIZE_FAILED
89 proto_set_available
"$interface" 0
94 [ -n "$pincode" ] && {
95 PINCODE
="$pincode" gcom
-d "$device" -s /etc
/gcom
/setpin.gcom ||
{
96 echo "Unable to verify PIN"
97 proto_notify_error
"$interface" PIN_FAILED
98 proto_block_restart
"$interface"
104 json_get_var setmode
"$mode"
105 COMMAND
="$setmode" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
106 echo "Failed to set operating mode"
107 proto_notify_error
"$interface" SETMODE_FAILED
108 proto_set_available
"$interface" 0
114 json_get_vars connect
115 eval COMMAND
="$connect" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
116 echo "Failed to connect"
117 proto_notify_error
"$interface" CONNECT_FAILED
118 proto_set_available
"$interface" 0
122 echo "Connected, starting DHCP"
124 proto_init_update
"$ifname" 1
125 proto_send_update
"$interface"
128 json_add_string name
"${interface}_dhcp"
129 json_add_string ifname
"@$interface"
130 json_add_string proto
"dhcp"
131 ubus call network add_dynamic
"$(json_dump)"
134 json_add_string name
"${interface}_dhcpv6"
135 json_add_string ifname
"@$interface"
136 json_add_string proto
"dhcpv6"
137 ubus call network add_dynamic
"$(json_dump)"
140 proto_ncm_teardown
() {
143 local manufacturer disconnect
148 echo "Stopping network"
150 manufacturer
=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'`
152 echo "Failed to get modem information"
153 proto_notify_error
"$interface" GETINFO_FAILED
157 json_load
"$(cat /etc/gcom/ncm.json)"
158 json_select
"$manufacturer" ||
{
159 echo "Unsupported modem"
160 proto_notify_error
"$interface" UNSUPPORTED_MODEM
164 json_get_vars disconnect
165 COMMAND
="$disconnect" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
166 echo "Failed to disconnect"
167 proto_notify_error
"$interface" DISCONNECT_FAILED
171 proto_init_update
"*" 0
172 proto_send_update
"$interface"
174 [ -n "$INCLUDE_ONLY" ] ||
{