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:
Matti Laakso 2016-12-11 17:28:52 +02:00 committed by John Crispin
parent 2e2748b053
commit 5bd3b9dfc0
4 changed files with 51 additions and 56 deletions

View File

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=comgt PKG_NAME:=comgt
PKG_VERSION:=0.32 PKG_VERSION:=0.32
PKG_RELEASE:=27 PKG_RELEASE:=28
PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
PKG_SOURCE_URL:=@SF/comgt PKG_SOURCE_URL:=@SF/comgt

View File

@ -6,7 +6,7 @@ opengt
flash 0.1 flash 0.1
:start :start
send "ATI^m" send "AT+CGMI^m"
get 1 "" $s get 1 "" $s
print $s print $s

View File

@ -7,7 +7,7 @@
"ATV1", "ATV1",
"ATE1", "ATE1",
"ATS0=0", "ATS0=0",
"AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"" "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
], ],
"modes": { "modes": {
"preferlte": "AT^SYSCFGEX=\\\"030201\\\",3fffffff,2,4,7fffffffffffffff,,", "preferlte": "AT^SYSCFGEX=\\\"030201\\\",3fffffff,2,4,7fffffffffffffff,,",
@ -17,8 +17,8 @@
"gsm": "AT^SYSCFGEX=\\\"01\\\",3fffffff,2,4,7fffffffffffffff,,", "gsm": "AT^SYSCFGEX=\\\"01\\\",3fffffff,2,4,7fffffffffffffff,,",
"auto": "AT^SYSCFGEX=\\\"00\\\",3fffffff,2,4,7fffffffffffffff,," "auto": "AT^SYSCFGEX=\\\"00\\\",3fffffff,2,4,7fffffffffffffff,,"
}, },
"connect": "AT^NDISDUP=1,1,\\\"${apn}\\\"${username:+,\\\"$username\\\"}${password:+,\\\"$password\\\"}${auth:+,$auth}", "connect": "AT^NDISDUP=${profile},1${apn:+,\\\"$apn\\\"}${username:+,\\\"$username\\\"}${password:+,\\\"$password\\\"}${auth:+,$auth}",
"disconnect": "AT^NDISDUP=1,0" "disconnect": "AT^NDISDUP=${profile},0"
}, },
"samsung": { "samsung": {
"initialize": [ "initialize": [
@ -26,7 +26,7 @@
"AT+CGREG=2", "AT+CGREG=2",
"AT+CFUN=5", "AT+CFUN=5",
"AT+MODESELECT=3", "AT+MODESELECT=3",
"AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"" "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}"
], ],
"modes": { "modes": {
"umts": "AT+CHANGEALLPATH=1" "umts": "AT+CHANGEALLPATH=1"
@ -34,11 +34,11 @@
"connect": "AT+CGATT=1", "connect": "AT+CGATT=1",
"disconnect": "AT+CGATT=0" "disconnect": "AT+CGATT=0"
}, },
"sierra wireless, incorporated": { "sierra": {
"initialize": [ "initialize": [
"AT+CFUN=1", "AT+CFUN=1",
"AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"", "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}",
"AT$QCPDPP=1${auth:+,$auth}${password:+,\\\"$password\\\"}${username:+,\\\"$username\\\"}" "AT$QCPDPP=${profile},${auth:-0}${password:+,\\\"$password\\\"}${username:+,\\\"$username\\\"}"
], ],
"modes": { "modes": {
"preferlte": "AT!SELRAT=07", "preferlte": "AT!SELRAT=07",
@ -48,20 +48,20 @@
"gsm": "AT!SELRAT=02", "gsm": "AT!SELRAT=02",
"auto": "AT!SELRAT=00" "auto": "AT!SELRAT=00"
}, },
"connect": "AT!SCACT=1,1", "connect": "AT!SCACT=1,${profile}",
"disconnect": "AT!SCACT=0,1" "disconnect": "AT!SCACT=0,${profile}"
}, },
"sony ericsson": { "sony": {
"initialize": [ "initialize": [
"AT+CFUN=1", "AT+CFUN=1",
"AT+CGDCONT=1,\\\"${pdptype}\\\",\\\"${apn}\\\"", "AT+CGDCONT=${profile},\\\"${pdptype}\\\"${apn:+,\\\"$apn\\\"}",
"AT*EIAAUW=1,1,\\\"${username}\\\",\\\"${password}\\\",${auth:-00111}" "AT*EIAAUW=${profile},1,\\\"${username}\\\",\\\"${password}\\\",${auth:-00111}"
], ],
"modes": { "modes": {
"umts": "AT+CFUN=6", "umts": "AT+CFUN=6",
"gsm": "AT+CFUN=5" "gsm": "AT+CFUN=5"
}, },
"connect": "AT*ENAP=1,1", "connect": "AT*ENAP=1,${profile}",
"disconnect": "AT*ENAP=0" "disconnect": "AT*ENAP=0"
} }
} }

View File

@ -18,7 +18,7 @@ proto_ncm_init_config() {
proto_config_add_string delay proto_config_add_string delay
proto_config_add_string mode proto_config_add_string mode
proto_config_add_string pdptype proto_config_add_string pdptype
proto_config_add_boolean ipv6 proto_config_add_int profile
proto_config_add_defaults proto_config_add_defaults
} }
@ -27,22 +27,15 @@ proto_ncm_setup() {
local manufacturer initialize setmode connect ifname devname devpath local manufacturer initialize setmode connect ifname devname devpath
local device apn auth username password pincode delay mode pdptype ipv6 $PROTO_DEFAULT_OPTIONS 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 ipv6 $PROTO_DEFAULT_OPTIONS json_get_vars device apn auth username password pincode delay mode pdptype profile $PROTO_DEFAULT_OPTIONS
if [ "$ipv6" = 0 ]; then [ "$metric" = "" ] && metric="0"
ipv6=""
else
ipv6=1
fi
[ -z "$pdptype" ] && { [ -n "$profile" ] || profile=1
if [ -n "$ipv6" ]; then
pdptype="IPV4V6" pdptype=`echo "$pdptype" | awk '{print toupper($0)}'`
else [ "$pdptype" = "IP" -o "$pdptype" = "IPV6" -o "$pdptype" = "IPV4V6" ] || $pdptype="IP"
pdptype="IP"
fi
}
[ -n "$ctl_device" ] && device=$ctl_device [ -n "$ctl_device" ] && device=$ctl_device
@ -57,11 +50,6 @@ proto_ncm_setup() {
proto_set_available "$interface" 0 proto_set_available "$interface" 0
return 1 return 1
} }
[ -n "$apn" ] || {
echo "No APN specified"
proto_notify_error "$interface" NO_APN
return 1
}
devname="$(basename "$device")" devname="$(basename "$device")"
case "$devname" in case "$devname" in
@ -83,7 +71,7 @@ proto_ncm_setup() {
[ -n "$delay" ] && sleep "$delay" [ -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 ] && { [ $? -ne 0 ] && {
echo "Failed to get modem information" echo "Failed to get modem information"
proto_notify_error "$interface" GETINFO_FAILED proto_notify_error "$interface" GETINFO_FAILED
@ -126,6 +114,7 @@ proto_ncm_setup() {
json_select .. json_select ..
} }
echo "Starting network $interface"
json_get_vars connect json_get_vars connect
eval COMMAND="$connect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || { eval COMMAND="$connect" gcom -d "$device" -s /etc/gcom/runcommand.gcom || {
echo "Failed to connect" echo "Failed to connect"
@ -133,19 +122,24 @@ proto_ncm_setup() {
return 1 return 1
} }
echo "Connected, starting DHCP on $ifname" echo "Setting up $ifname"
proto_init_update "$ifname" 1 proto_init_update "$ifname" 1
proto_add_data
json_add_string "manufacturer" "$manufacturer"
proto_close_data
proto_send_update "$interface" proto_send_update "$interface"
[ "$pdptype" = "IP" -o "$pdptype" = "IPV4V6" ] && {
json_init json_init
json_add_string name "${interface}_4" json_add_string name "${interface}_4"
json_add_string ifname "@$interface" json_add_string ifname "@$interface"
json_add_string proto "dhcp" json_add_string proto "dhcp"
proto_add_dynamic_defaults proto_add_dynamic_defaults
ubus call network add_dynamic "$(json_dump)" ubus call network add_dynamic "$(json_dump)"
}
[ -n "$ipv6" ] && { [ "$pdptype" = "IPV6" -o "$pdptype" = "IPV4V6" ] && {
json_init json_init
json_add_string name "${interface}_6" json_add_string name "${interface}_6"
json_add_string ifname "@$interface" json_add_string ifname "@$interface"
@ -161,17 +155,18 @@ proto_ncm_teardown() {
local manufacturer disconnect local manufacturer disconnect
local device local device profile
json_get_vars device 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) }'` [ -n "$profile" ] || profile=1
[ $? -ne 0 ] && {
echo "Failed to get modem information" echo "Stopping network $interface"
proto_notify_error "$interface" GETINFO_FAILED
return 1 json_load "$(ubus call network.interface.$interface status)"
} json_select data
json_get_vars manufacturer
json_load "$(cat /etc/gcom/ncm.json)" json_load "$(cat /etc/gcom/ncm.json)"
json_select "$manufacturer" || { json_select "$manufacturer" || {
@ -181,7 +176,7 @@ proto_ncm_teardown() {
} }
json_get_vars disconnect 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" echo "Failed to disconnect"
proto_notify_error "$interface" DISCONNECT_FAILED proto_notify_error "$interface" DISCONNECT_FAILED
return 1 return 1