"ATV1",
"ATE1",
"ATS0=0",
- "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\""
+ "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
],
"modes": {
"preferlte": "AT^SYSCFGEX=\\\"030201\\\",3fffffff,2,4,7fffffffffffffff,,",
"gsm": "AT^SYSCFGEX=\\\"01\\\",3fffffff,2,4,7fffffffffffffff,,",
"auto": "AT^SYSCFGEX=\\\"00\\\",3fffffff,2,4,7fffffffffffffff,,"
},
- "connect": "AT^NDISDUP=1,1,\\\"${apn}\\\"${username:+,\\\"$username\\\"}${password:+,\\\"$password\\\"}${auth:+,$auth}",
- "disconnect": "AT^NDISDUP=1,0"
+ "connect": "AT^NDISDUP=${profile},1${apn:+,\\\"$apn\\\"}${username:+,\\\"$username\\\"}${password:+,\\\"$password\\\"}${auth:+,$auth}",
+ "disconnect": "AT^NDISDUP=${profile},0"
},
"samsung": {
"initialize": [
"AT+CGREG=2",
"AT+CFUN=5",
"AT+MODESELECT=3",
- "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\""
+ "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
],
"modes": {
"umts": "AT+CHANGEALLPATH=1"
"connect": "AT+CGATT=1",
"disconnect": "AT+CGATT=0"
},
- "sierra wireless, incorporated": {
+ "sierra": {
"initialize": [
"AT+CFUN=1",
- "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"",
- "AT$QCPDPP=1${auth:+,$auth}${password:+,\\\"$password\\\"}${username:+,\\\"$username\\\"}"
+ "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}",
+ "AT$QCPDPP=${profile},${auth:-0}${password:+,\\\"$password\\\"}${username:+,\\\"$username\\\"}"
],
"modes": {
"preferlte": "AT!SELRAT=07",
"gsm": "AT!SELRAT=02",
"auto": "AT!SELRAT=00"
},
- "connect": "AT!SCACT=1,1",
- "disconnect": "AT!SCACT=0,1"
+ "connect": "AT!SCACT=1,${profile}",
+ "disconnect": "AT!SCACT=0,${profile}"
},
- "sony ericsson": {
+ "sony": {
"initialize": [
"AT+CFUN=1",
- "AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"",
- "AT*EIAAUW=1,1,\\\"${username}\\\",\\\"${password}\\\",${auth:-00111}"
+ "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}",
+ "AT*EIAAUW=${profile},1,\\\"${username}\\\",\\\"${password}\\\",${auth:-00111}"
],
"modes": {
"umts": "AT+CFUN=6",
"gsm": "AT+CFUN=5"
},
- "connect": "AT*ENAP=1,1",
+ "connect": "AT*ENAP=1,${profile}",
"disconnect": "AT*ENAP=0"
}
}
proto_config_add_string delay
proto_config_add_string mode
proto_config_add_string pdptype
- proto_config_add_boolean ipv6
+ proto_config_add_int profile
proto_config_add_defaults
}
local manufacturer initialize setmode connect ifname devname devpath
- local device apn auth username password pincode delay mode pdptype ipv6 $PROTO_DEFAULT_OPTIONS
- json_get_vars device apn auth username password pincode delay mode pdptype ipv6 $PROTO_DEFAULT_OPTIONS
-
- if [ "$ipv6" = 0 ]; then
- ipv6=""
- else
- ipv6=1
- fi
-
- [ -z "$pdptype" ] && {
- if [ -n "$ipv6" ]; then
- pdptype="IPV4V6"
- else
- pdptype="IP"
- fi
- }
+ local device apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS
+ json_get_vars device apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS
+
+ [ "$metric" = "" ] && metric="0"
+
+ [ -n "$profile" ] || profile=1
+
+ pdptype=`echo "$pdptype" | awk '{print toupper($0)}'`
+ [ "$pdptype" = "IP" -o "$pdptype" = "IPV6" -o "$pdptype" = "IPV4V6" ] || $pdptype="IP"
[ -n "$ctl_device" ] && device=$ctl_device
proto_set_available "$interface" 0
return 1
}
- [ -n "$apn" ] || {
- echo "No APN specified"
- proto_notify_error "$interface" NO_APN
- return 1
- }
devname="$(basename "$device")"
case "$devname" in
[ -n "$delay" ] && sleep "$delay"
- manufacturer=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'`
+ manufacturer=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk 'NF && $0 !~ /AT\+CGMI/ { sub(/\+CGMI: /,""); print tolower($1); exit; }'`
[ $? -ne 0 ] && {
echo "Failed to get modem information"
proto_notify_error "$interface" GETINFO_FAILED
json_select ..
}
+ echo "Starting network $interface"
json_get_vars connect
eval COMMAND="$connect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
echo "Failed to connect"
return 1
}
- echo "Connected, starting DHCP on $ifname"
+ echo "Setting up $ifname"
proto_init_update "$ifname" 1
+ proto_add_data
+ json_add_string "manufacturer" "$manufacturer"
+ proto_close_data
proto_send_update "$interface"
- json_init
- json_add_string name "${interface}_4"
- json_add_string ifname "@$interface"
- json_add_string proto "dhcp"
- proto_add_dynamic_defaults
- ubus call network add_dynamic "$(json_dump)"
+ [ "$pdptype" = "IP" -o "$pdptype" = "IPV4V6" ] && {
+ json_init
+ json_add_string name "${interface}_4"
+ json_add_string ifname "@$interface"
+ json_add_string proto "dhcp"
+ proto_add_dynamic_defaults
+ ubus call network add_dynamic "$(json_dump)"
+ }
- [ -n "$ipv6" ] && {
+ [ "$pdptype" = "IPV6" -o "$pdptype" = "IPV4V6" ] && {
json_init
json_add_string name "${interface}_6"
json_add_string ifname "@$interface"
local manufacturer disconnect
- local device
- json_get_vars device
+ local device profile
+ json_get_vars device profile
- echo "Stopping network"
+ [ -n "$ctl_device" ] && device=$ctl_device
- manufacturer=`gcom -d "$device" -s /etc/gcom/getcardinfo.gcom | awk '/Manufacturer/ { print tolower($2) }'`
- [ $? -ne 0 ] && {
- echo "Failed to get modem information"
- proto_notify_error "$interface" GETINFO_FAILED
- 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
json_load "$(cat /etc/gcom/ncm.json)"
json_select "$manufacturer" || {
}
json_get_vars disconnect
- COMMAND="$disconnect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
+ eval COMMAND="$disconnect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
echo "Failed to disconnect"
proto_notify_error "$interface" DISCONNECT_FAILED
return 1