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
30 [ -n "$ctl_device" ] && device
=$ctl_device
33 echo "No control device specified"
34 proto_notify_error
"$interface" NO_DEVICE
35 proto_set_available
"$interface" 0
39 echo "Control device not valid"
40 proto_set_available
"$interface" 0
44 echo "No APN specified"
45 proto_notify_error
"$interface" NO_APN
49 devname
="$(basename "$device")"
52 devpath
="$(readlink -f /sys/class/tty/$devname/device)"
53 ifname
="$( ls "$devpath"/../../*/net )"
56 devpath
="$(readlink -f /sys/class/usbmisc/$devname/device/)"
57 ifname
="$( ls "$devpath"/net )"
61 echo "The interface could not be found."
62 proto_notify_error
"$interface" NO_IFACE
63 proto_set_available
"$interface" 0
67 [ -n "$delay" ] && sleep "$delay"
69 manufacturer
=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'`
71 echo "Failed to get modem information"
72 proto_notify_error
"$interface" GETINFO_FAILED
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
93 [ -n "$pincode" ] && {
94 PINCODE
="$pincode" gcom
-d "$device" -s /etc
/gcom
/setpin.gcom ||
{
95 echo "Unable to verify PIN"
96 proto_notify_error
"$interface" PIN_FAILED
97 proto_block_restart
"$interface"
103 json_get_var setmode
"$mode"
104 COMMAND
="$setmode" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
105 echo "Failed to set operating mode"
106 proto_notify_error
"$interface" SETMODE_FAILED
112 json_get_vars connect
113 eval COMMAND
="$connect" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
114 echo "Failed to connect"
115 proto_notify_error
"$interface" CONNECT_FAILED
119 echo "Connected, starting DHCP"
121 proto_init_update
"$ifname" 1
122 proto_send_update
"$interface"
125 json_add_string name
"${interface}_4"
126 json_add_string ifname
"@$interface"
127 json_add_string proto
"dhcp"
128 ubus call network add_dynamic
"$(json_dump)"
131 json_add_string name
"${interface}_6"
132 json_add_string ifname
"@$interface"
133 json_add_string proto
"dhcpv6"
134 ubus call network add_dynamic
"$(json_dump)"
137 proto_ncm_teardown
() {
140 local manufacturer disconnect
145 echo "Stopping network"
147 manufacturer
=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'`
149 echo "Failed to get modem information"
150 proto_notify_error
"$interface" GETINFO_FAILED
154 json_load
"$(cat /etc/gcom/ncm.json)"
155 json_select
"$manufacturer" ||
{
156 echo "Unsupported modem"
157 proto_notify_error
"$interface" UNSUPPORTED_MODEM
161 json_get_vars disconnect
162 COMMAND
="$disconnect" gcom
-d "$device" -s /etc
/gcom
/runcommand.gcom ||
{
163 echo "Failed to disconnect"
164 proto_notify_error
"$interface" DISCONNECT_FAILED
168 proto_init_update
"*" 0
169 proto_send_update
"$interface"
171 [ -n "$INCLUDE_ONLY" ] ||
{