comgt-ncm: Add support for specifying profile index
Add support for specifying a call profile index instead of APN. A specific index different from 1 must be used for some service provider and modem combinations. In addition, change the manufacturer detection to use the standard AT+CGMI command, which produces more predictable output than ATI, remove the redundant ipv6 option, since it is less ambiguous to directly specify the PDP context type with mobile connections, and fix missing device during teardown when using ncm through the wwan proto. Signed-off-by: Matti Laakso <malaakso@elisanet.fi>
This commit is contained in:
parent
2e2748b053
commit
5bd3b9dfc0
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=comgt
|
||||
PKG_VERSION:=0.32
|
||||
PKG_RELEASE:=27
|
||||
PKG_RELEASE:=28
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
|
||||
PKG_SOURCE_URL:=@SF/comgt
|
||||
|
@ -6,7 +6,7 @@ opengt
|
||||
flash 0.1
|
||||
|
||||
:start
|
||||
send "ATI^m"
|
||||
send "AT+CGMI^m"
|
||||
get 1 "" $s
|
||||
print $s
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
"ATV1",
|
||||
"ATE1",
|
||||
"ATS0=0",
|
||||
"AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\""
|
||||
"AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
|
||||
],
|
||||
"modes": {
|
||||
"preferlte": "AT^SYSCFGEX=\\\"030201\\\",3fffffff,2,4,7fffffffffffffff,,",
|
||||
@ -17,8 +17,8 @@
|
||||
"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": [
|
||||
@ -26,7 +26,7 @@
|
||||
"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"
|
||||
@ -34,11 +34,11 @@
|
||||
"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",
|
||||
@ -48,20 +48,20 @@
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ proto_ncm_init_config() {
|
||||
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
|
||||
}
|
||||
|
||||
@ -27,22 +27,15 @@ proto_ncm_setup() {
|
||||
|
||||
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
|
||||
|
||||
@ -57,11 +50,6 @@ proto_ncm_setup() {
|
||||
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
|
||||
@ -83,7 +71,7 @@ proto_ncm_setup() {
|
||||
|
||||
[ -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
|
||||
@ -126,6 +114,7 @@ proto_ncm_setup() {
|
||||
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"
|
||||
@ -133,19 +122,24 @@ proto_ncm_setup() {
|
||||
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"
|
||||
@ -161,17 +155,18 @@ proto_ncm_teardown() {
|
||||
|
||||
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" || {
|
||||
@ -181,7 +176,7 @@ proto_ncm_teardown() {
|
||||
}
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user