summaryrefslogtreecommitdiff
path: root/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-apn
diff options
context:
space:
mode:
authorJohn Klug <john.klug@multitech.com>2017-08-31 16:45:53 -0500
committerJohn Klug <john.klug@multitech.com>2017-09-14 17:34:52 -0500
commit4c71e7f725e5cab0404a20a63fe699a9f3726b94 (patch)
tree489b49d2363697391009e988b88706a7d1c661ed /recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-apn
parentf02d11351f80b47dc37d3e306a1d1ce383b41add (diff)
downloadmeta-mlinux-4c71e7f725e5cab0404a20a63fe699a9f3726b94.tar.gz
meta-mlinux-4c71e7f725e5cab0404a20a63fe699a9f3726b94.tar.bz2
meta-mlinux-4c71e7f725e5cab0404a20a63fe699a9f3726b94.zip
AT&T is default, mlinux-set-apn can be used for non-VZ and non-AT&T.
Diffstat (limited to 'recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-apn')
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-apn97
1 files changed, 60 insertions, 37 deletions
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-apn b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-apn
index f6b1894..da87cd3 100755
--- a/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-apn
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-apn
@@ -1,6 +1,6 @@
#!/bin/bash
-# Copyright (C) 2014 Multi-Tech Systems
+# Copyright (C) 2014, 2017 Multi-Tech Systems
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -20,58 +20,81 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
-lna3_chat_file=/etc/ppp/peers/lna3_chat
+lna3_chat_file[0]=/etc/ppp/peers/lna3_chat_non_vz
+lna3_chat_file[1]=/etc/ppp/peers/lna3_chat_vz
+lna3_chat_link=/etc/ppp/peers/lna3_chat
+
+function setchat {
+ fw=$1
+ silent=$2
+ if ((${#lna3_chat_file[$fw]} == 0)) ; then
+ >&2 echo "Invalid firmware SKU $fw"
+ return 1
+ else
+ if ((silent == 0)) ; then
+ echo "Setting chat script to ${lna3_chat_file[$fw]}"
+ fi
+ ln -sf "${lna3_chat_file[$fw]}" "${lna3_chat_link}"
+ fi
+}
+
function usage {
- echo "$(basename $0) [firmware image SKU]"
- echo "The firmware image SKU is optional."
- echo "If not specified, the image SKU is queried (recommended)."
- echo "Current valid SKU's are 0 and 1"
- echo "Only LE910-NA1 is supported on product-ids containing string -LNA3-"
+ >&2 echo "$(basename $0) [firmware image SKU]"
+ >&2 echo "The firmware image SKU is optional."
+ >&2 echo "If not specified, the image SKU will be determined"
+ >&2 echo "from the SIM, and automatically switched with the"
+ >&2 echo "APN. Current valid SKU's are 0 and 1"
+ >&2 echo "Only LE910-NA1 is supported on product-ids containing string -LNA3-"
exit 1
}
+function not_ready {
+ >&2 echo "Radio is not ready"
+ >&2 echo "Try executing mlinux-switch-apn once the radio is ready"
+ exit 1
+}
+productid=$(/usr/sbin/mts-io-sysfs show product-id)
+if ! [[ $productid =~ -LNA3- ]] ; then
+ echo "Firmware switch is supported only on LE910-NA1 models with product-id containing -LNA3-."
+ usage
+ exit 1
+fi
+
if (($# > 0)) ; then
fw="$1"
-
if [[ fw =~ ^[0-9]+$ ]] ; then
if ((fw < 0)) || ((fw > 1)) ; then
usage
fi
else
if ((fw > 1)) || ((fw < 0)) ; then
- echo "Invalid firmware SKU value"
+ >&2 echo "Invalid firmware SKU value"
usage
fi
fi
+ echo "Switching chat script to firmware SKU $fw"
+ setchat $fw 0
+ exit $?
else
- radioproduct=$(/usr/sbin/mts-io-sysfs show product-id) # Hopefully LNA3
- ((query=0))
- lna3_chat_file=/etc/ppp/peers/lna3_chat
- model=$(radio-query --model 2>/dev/null)
- if [[ $model != "LE910-NA1" ]] || ! [[ $radioproduct =~ "-LNA3-" ]] ; then
- [[ $VERBOSE ]] && echo "Firmware switch is supported only on LE910-NA1 models with product-id containing -LNA3-."
- # Nothing to do
- exit 0
+ if ! /usr/sbin/mlinux-cell-radio-ready ; then
+ >&2 echo Radio is not ready
+ >&2 echo Try again later
+ exit 1
fi
- fw=$(radio-query --active-firmware 2>/dev/null) || ((fw=-1))
- if ((fw == -1)) ; then
- echo Active firmware query failed.
- echo Assuming firmware 1
+ MODEL=$(radio-query --model)
+ if (($? != 0)) ; then
+ >&2echo "Assume no radio on this device."
+ usage
+ exit 1
fi
-fi
-
-if (( fw == 1 )) ; then
- # Verizon is active, so comment out the APN
- echo "Temporarily commenting out APN, since Verizon is active and no APN is allowed in a Verizon chat file."
- sed -r -i "s/^(OK\s+'AT\+CGDCONT=3,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lna3_chat_file
-else
- # Set non-Verizon APN in chat file
- # if sed -r -i "s/^(#comment by mlinux-set-apn )* OK\s+'AT\+CGDCONT=3,\"IPV4V6\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=3,\"IPV4V6\",\"${apn}\"'/" $lna3_chat_file ; then
- # (OK\s+'AT\+CGDCONT=3,\"IPV4V6\",\"(^\"]*\"'$)
- if sed -r -i "s/^(#comment by mlinux-set-apn )*(OK\s+'AT\+CGDCONT=3,\"[^\"]*\",\"[^\"]*\"'$)/\2/" $lna3_chat_file ; then
- echo "Set APN in $lna3_chat_file"
- else
- echo "Failed to set APN in $lna3_chat_file"
+ if [[ $MODEL != LE910-NA1 ]] ; then
+ >&2 echo "Firmware switch is supported only on LE910-NA1 models with product-id containing -LNA3-."
+ usage
fi
- exit 0
-fi
+
+ if fwreply=$(/usr/sbin/mlinux-switch-cell-fw -1); then
+ [[ $fwreply =~ Cellular[[:space:]]+radio[[:space:]]+firmware[[:space:]]+has[[:space:]]+been[[:space:]]+switched[[:space:]]+to[[:space:]]+([^[:space:]]*)[[:space:]]+image\. ]]
+ fw=${BASH_REMATCH[1]}
+ setchat $fw 0
+ fi
+fi \ No newline at end of file