[ -n "$delay" ] && sleep "$delay"
manufacturer=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk 'NF && $0 !~ /AT\+CGMI/ { sub(/\+CGMI: /,""); print tolower($1); exit; }')
- [ $? -ne 0 ] && {
+ [ $? -ne 0 -o -z "$manufacturer" ] && {
echo "Failed to get modem information"
proto_notify_error "$interface" GETINFO_FAILED
return 1
proto_set_available "$interface" 0
return 1
}
+
json_get_values initialize initialize
for i in $initialize; do
eval COMMAND="$i" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
[ -n "$mode" ] && {
json_select modes
json_get_var setmode "$mode"
- echo "Setting mode"
- eval COMMAND="$setmode" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
- echo "Failed to set operating mode"
- proto_notify_error "$interface" SETMODE_FAILED
- return 1
+ [ -n "$setmode" ] && {
+ echo "Setting mode"
+ eval COMMAND="$setmode" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
+ echo "Failed to set operating mode"
+ proto_notify_error "$interface" SETMODE_FAILED
+ return 1
+ }
}
json_select ..
}
echo "Starting network $interface"
json_get_vars connect
- echo "Connecting modem"
- eval COMMAND="$connect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
- echo "Failed to connect"
- proto_notify_error "$interface" CONNECT_FAILED
- return 1
+ [ -n "$connect" ] && {
+ echo "Connecting modem"
+ eval COMMAND="$connect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
+ echo "Failed to connect"
+ proto_notify_error "$interface" CONNECT_FAILED
+ return 1
+ }
}
json_get_vars finalize
return 1
}
}
-
}
proto_ncm_teardown() {
[ -n "$ctl_device" ] && device=$ctl_device
+ [ -n "$device" ] || {
+ echo "No control device specified"
+ proto_notify_error "$interface" NO_DEVICE
+ proto_set_available "$interface" 0
+ return 1
+ }
+
+ device="$(readlink -f $device)"
+ [ -e "$device" ] || {
+ echo "Control device not valid"
+ proto_set_available "$interface" 0
+ return 1
+ }
+
[ -n "$profile" ] || profile=1
echo "Stopping network $interface"
json_load "$(ubus call network.interface.$interface status)"
json_select data
json_get_vars manufacturer
+ [ $? -ne 0 -o -z "$manufacturer" ] && {
+ # Fallback to direct detect, for proper handle device replug.
+ manufacturer=$(gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk 'NF && $0 !~ /AT\+CGMI/ { sub(/\+CGMI: /,""); print tolower($1); exit; }')
+ [ $? -ne 0 -o -z "$manufacturer" ] && {
+ echo "Failed to get modem information"
+ proto_notify_error "$interface" GETINFO_FAILED
+ return 1
+ }
+ json_add_string "manufacturer" "$manufacturer"
+ }
json_load "$(cat /etc/gcom/ncm.json)"
json_select "$manufacturer" || {
}
json_get_vars disconnect
- eval COMMAND="$disconnect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
- echo "Failed to disconnect"
- proto_notify_error "$interface" DISCONNECT_FAILED
- return 1
+ [ -n "$disconnect" ] && {
+ eval COMMAND="$disconnect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
+ echo "Failed to disconnect"
+ proto_notify_error "$interface" DISCONNECT_FAILED
+ return 1
+ }
}
proto_init_update "*" 0