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
47 devname
="$(basename "$device")"
50 devpath
="$(readlink -f /sys/class/tty/$devname/device)"
51 ifname
="$( ls "$devpath"/../../*/net )"
54 devpath
="$(readlink -f /sys/class/usbmisc/$devname/device/)"
55 ifname
="$( ls "$devpath"/net )"
59 echo "The interface could not be found."
60 proto_notify_error
"$interface" NO_IFACE
61 proto_set_available
"$interface" 0
65 [ -n "$delay" ] && sleep "$delay"
67 manufacturer
=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'`
69 echo "Failed to get modem information"
70 proto_notify_error
"$interface" GETINFO_FAILED
74 json_load
"$(cat /etc/gcom/ncm.json)"
75 json_select
"$manufacturer"
77 echo "Unsupported modem"
78 proto_notify_error
"$interface" UNSUPPORTED_MODEM
79 proto_set_available
"$interface" 0
82 json_get_values initialize initialize
83 for i
in $initialize; do
84 eval COMMAND
="$i" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
85 echo "Failed to initialize modem"
86 proto_notify_error
"$interface" INITIALIZE_FAILED
91 [ -n "$pincode" ] && {
92 PINCODE
="$pincode" gcom
-d "$device" -s /etc
/gcom
/setpin.gcom ||
{
93 echo "Unable to verify PIN"
94 proto_notify_error
"$interface" PIN_FAILED
95 proto_block_restart
"$interface"
101 json_get_var setmode
"$mode"
102 COMMAND
="$setmode" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
103 echo "Failed to set operating mode"
104 proto_notify_error
"$interface" SETMODE_FAILED
110 json_get_vars connect
111 eval COMMAND
="$connect" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
112 echo "Failed to connect"
113 proto_notify_error
"$interface" CONNECT_FAILED
117 echo "Connected, starting DHCP"
119 proto_init_update
"$ifname" 1
120 proto_send_update
"$interface"
123 json_add_string name
"${interface}_4"
124 json_add_string ifname
"@$interface"
125 json_add_string proto
"dhcp"
126 ubus call network add_dynamic
"$(json_dump)"
129 json_add_string name
"${interface}_6"
130 json_add_string ifname
"@$interface"
131 json_add_string proto
"dhcpv6"
132 ubus call network add_dynamic
"$(json_dump)"
135 proto_ncm_teardown
() {
138 local manufacturer disconnect
143 echo "Stopping network"
145 manufacturer
=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'`
147 echo "Failed to get modem information"
148 proto_notify_error
"$interface" GETINFO_FAILED
152 json_load
"$(cat /etc/gcom/ncm.json)"
153 json_select
"$manufacturer" ||
{
154 echo "Unsupported modem"
155 proto_notify_error
"$interface" UNSUPPORTED_MODEM
159 json_get_vars disconnect
160 COMMAND
="$disconnect" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
161 echo "Failed to disconnect"
162 proto_notify_error
"$interface" DISCONNECT_FAILED
166 proto_init_update
"*" 0
167 proto_send_update
"$interface"
169 [ -n "$INCLUDE_ONLY" ] ||
{