summaryrefslogtreecommitdiff
path: root/recipes-core/mlinux-scripts
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
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')
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn71
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-apn97
-rwxr-xr-xrecipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw84
-rw-r--r--recipes-core/mlinux-scripts/mlinux-scripts.inc2
-rw-r--r--recipes-core/mlinux-scripts/mlinux-scripts_1.1.bb2
5 files changed, 150 insertions, 106 deletions
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn
index 8e4d3d2..8c59c78 100755
--- a/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-set-apn
@@ -20,14 +20,21 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
+gsm_chat_file=/etc/ppp/peers/gsm_chat
+lvw2_chat_file=/etc/ppp/peers/lvw2_chat
+leu1_chat_file=/etc/ppp/peers/leu1_chat
+lna3_chat_file=/etc/ppp/peers/lna3_chat_non_vz
+lna3_chat_link=/etc/ppp/peers/lna3_chat
+lna3_readme=/etc/ppp/peers/README.lna3
+
function usage {
echo "Usage: $(basename $0) [--] APN"
echo "Or $(basename $0) -c to clear the APN line"
echo "-- is requied if the APN begins with -"
- echo "Radio must be ready to set the APN"
exit 1
}
+
((clear=0))
if (($# < 1)); then
usage
@@ -41,55 +48,22 @@ elif [[ $1 =~ ^- ]] ; then
else
apn=$1
fi
-gsm_chat_file=/etc/ppp/peers/gsm_chat
-lvw2_chat_file=/etc/ppp/peers/lvw2_chat
-leu1_chat_file=/etc/ppp/peers/leu1_chat
-lna3_chat_file=/etc/ppp/peers/lna3_chat
radioproduct=$(/usr/sbin/mts-io-sysfs show product-id) # LNA3?
-model=$(radio-query --model 2>/dev/null)
if (($? != 0)) ; then
echo "Radio is not ready or not found and cannot determine the type"
exit 1
fi
-# Only support LNA3
-
-if [[ $model == LE910-NA1 ]] && [[ $radioproduct =~ -LNA3- ]] ; then
- if ((clear != 1)) ; then
- if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=3,\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=3,\"\2\",\"${apn}\"'/" $lna3_chat_file ; then
- echo "Set APN to \"${apn}\" in $lna3_chat_file"
- else
- echo "Failed to set APN in $lna3_chat_file"
- fi
- fw=$(radio-query --active-firmware 2>/dev/null)
- if (($? != 0)) ; then
- echo "Radio query for active firmware failed, so clear APN"
- fw=1
- 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
- fi
- else
- if sed -r -i "s/^(OK\s+'AT\+CGDCONT=3,\"[^/]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lna3_chat_file ; then
- echo "Commented out APN in $lna3_chat_file"
- else
- echo "Failed to comment out APN in $lna3_chat_file"
- fi
- fi
- exit 0
-else
- echo "Radio in product-id must be -LNA3- for LE910-NA1"
- echo "Radio model is \"$model\", product-id is \"$radioproduct\""
+# Disable the LNA3 chat script
+if ! [[ -L $lna3_chat_link ]] || [[ $(basename $(readlink -f $lna3_chat_link)) != README.lna3 ]] ; then
+ ln -sf "${lna3_readme}" "${lna3_chat_link}"
+ echo Disabling LNA3 chat script.
fi
-
if ((clear != 1)) ; then
- if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=1,\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=1,\"\2\",\"${apn}\"'/" $gsm_chat_file ; then
+ if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=([0-9]*),\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=\2,\"\3\",\"${apn}\"'/" $gsm_chat_file ; then
echo "Set APN to \"${apn}\" in $gsm_chat_file"
else
echo "Failed to set APN in $gsm_chat_file"
@@ -97,25 +71,36 @@ if ((clear != 1)) ; then
echo "Not allowed to set APN for $lvw2_chat_file"
# We cannot set the APN for a Verizon modem
# sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=3,\"IPV4V6\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=3,\"IPV4V6\",\"${apn}\"'/" $lvw2_chat_file
- if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=1,\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=1,\"\2\",\"${apn}\"'/" $leu1_chat_file ; then
+ if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=([0-9]*),\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=\2,\"\3\",\"${apn}\"'/" $leu1_chat_file ; then
echo "Set APN to \"${apn}\" in $leu1_chat_file"
else
echo "Failed to set APN in $leu1_chat_file"
fi
+ if sed -r -i "s/^(#comment by mlinux-set-apn )*OK\s+'AT\+CGDCONT=([0-9]*),\"([^\"]*)\",\"[^\"]*\"'$/OK 'AT\+CGDCONT=\2,\"\3\",\"${apn}\"'/" $lna3_chat_file ; then
+ echo "Set APN to \"${apn}\" in $lna3_chat_file"
+ else
+ echo "Failed to set APN in $lna3_chat_file"
+ fi
else
- if sed -r -i "s/^(OK\s+'AT\+CGDCONT=1,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $gsm_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=[0-9]*,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $gsm_chat_file ; then
echo "Commented out APN in $gsm_chat_file"
else
echo "Failed to comment out APN in $gsm_chat_file"
fi
# Not setting APN in lvw2 is OK, since Verizon should not have an APN in a chat file.
- if sed -r -i "s/^(OK\s+'AT\+CGDCONT=3,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lvw2_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=[0-9]*,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lvw2_chat_file ; then
echo "Commented out APN in $lvw2_chat_file"
fi
- if sed -r -i "s/^(OK\s+'AT\+CGDCONT=1,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $leu1_chat_file ; then
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=[0-9]*,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $leu1_chat_file ; then
echo "Commented out APN in $leu1_chat_file"
else
echo "Failed to comment out APN in $leu1_chat_file"
fi
+ if sed -r -i "s/^(OK\s+'AT\+CGDCONT=[0-9]*,\"[^\"]*\",\"[^\"]*\"'$)/#comment by mlinux-set-apn \1/" $lna3_chat_file ; then
+ echo "Commented out APN in $lna3_chat_file"
+ else
+ echo "Failed to comment out APN in $lna3_chat_file"
+ fi
fi
+
exit 0
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
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw
index ee58d66..62eb19d 100755
--- a/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw
+++ b/recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw
@@ -1,33 +1,68 @@
-#!/bin/sh
-
-
-if [ $# -gt 2 ] || [ $# -lt 1 ]; then
-echo "\
+#!/bin/bash
+lna3_chat_link=/etc/ppp/peers/lna3_chat
+lna3_readme=/etc/ppp/peers/README.lna3
+function usage {
+>&2 echo "\
Usage: $0 <image_id> [timeout]
- image_id <0|1> : for dual FW image SKU-s, the id of the image to switch to
- (LTE910-NA1 is the only supported radio for now).
- timeout : wait time for radio to come up if set (default : 15 sec)
+ image_id <0|1|-1> : for dual FW image SKU-s, the id of the image to switch to
+ (LTE910-NA1 is the only supported radio for now).
+ -1 is based on SIM
+ timeout : wait time for radio to come up if set (default : 15 sec)
+
"
exit 1
+}
+
+if [ $# -gt 2 ] ; then
+ usage
fi
#
# Load args (don't wait for the radio by default)
#
FWIMAGE=$1
+if ((FWIMAGE < -2)) || ((FWIMAGE > 1)) ; then
+ usage
+fi
+if ! /usr/sbin/mlinux-cell-radio-ready ; then
+ [ "$VERBOSE" ] && >&2 echo Radio is not ready
+ [ "$VERBOSE" ] && >&2 echo Try again later
+ exit 1
+fi
+if ((FWIMAGE == -1)) ; then
+ iccid=$(radio-query --iccid)
+ if (($? == 0)); then
+ if ((${#iccid} == 0)) ; then
+ [ "$VERBOSE" ] && >&2 echo "No carrier. Maybe no SIM?"
+ [ "$VERBOSE" ] && >&2 echo "ERROR: Cannot decide on firmware"
+ exit 1
+ fi
+ if [[ "$iccid" =~ ^89148.* ]] ; then
+ ((FWIMAGE=1))
+ else
+ ((FWIMAGE=0))
+ fi
+ else
+ >&2 echo "Cannot get ICCID from SIM"
+ >&2 echo "Try again later"
+ exit 1
+ fi
+fi
+
+
TIMEOUT=${2:-15}
if [ "$VERBOSE" != "yes" ]; then
VERBOSE=""
fi
-[ "$VERBOSE" ] && echo -n "Switching the radio firmware image: "
+[ "$VERBOSE" ] && >&2 echo -n "Switching the radio firmware image: "
#
# Check if the radio present
#
MODEL=$(radio-query --model)
if [ $? -ne 0 ]; then
- [ "$VERBOSE" ] && echo "Assume no radio on this device."
+ [ "$VERBOSE" ] && >&2 echo "Assume no radio on this device."
exit 0
fi
@@ -36,7 +71,7 @@ fi
#
productid=$(/usr/sbin/mts-io-sysfs show product-id)
if [[ $MODEL != LE910-NA1 ]] || ! [[ $productid =~ -LNA3- ]] ; then
- [ "$VERBOSE" ] && echo "Firmware switch is supported only on LE910-NA1 models with product-id containing -LNA3-."
+ [ "$VERBOSE" ] && >&2 echo "Firmware switch is supported only on LE910-NA1 models with product-id containing -LNA3-."
exit 0
fi
@@ -45,27 +80,27 @@ fi
#
FWACTIVE=$(radio-query --active-firmware)
if [ $? -ne 0 ] || [ "$FWACTIVE" == "" ]; then
- [ "$VERBOSE" ] && echo "The $MODEL radio does not support firmware switching."
+ [ "$VERBOSE" ] && >&2 echo "The $MODEL radio does not support firmware switching."
exit 0
fi
-if [ "$FWACTIVE" == "$FWIMAGE" ]; then
- [ "$VERBOSE" ] && echo "The radio firmware image is already set."
+if (( FWACTIVE == FWIMAGE )); then
+ [ "$VERBOSE" ] && >&2 echo "The radio firmware image is already set."
exit 0
fi
-# Verizon does not want an APN, so remove first
-if ((FWIMAGE == 1)) ; then
- /usr/sbin/mlinux-switch-apn $FWIMAGE
+# Disable the LNA3 chat script in case of failure.
+if ! [[ -L $lna3_chat_link ]] || [[ $(basename $(readlink -f $lna3_chat_link)) != README.lna3 ]] ; then
+ ln -sf "${lna3_readme}" "${lna3_chat_link}"
+ echo "Chat script is now disabled."
fi
-
#
# Switch the firmware
#
RESULT=$(radio-cmd --set-active-firmware "$FWIMAGE")
if [ $? -ne 0 ]; then
- echo "$RESULT"
+ [ "$VERBOSE" ] && >&2 echo "$RESULT"
exit 1
fi
@@ -77,11 +112,11 @@ fi
# will switch.
if ((TIMEOUT == 0)) ; then
if ((FWIMAGE == 0)) ; then
- echo "Use mlinux-switch-apn to switch the APN when the radio is ready, before dialing"
+ [ "$VERBOSE" ] && >&2 echo "Use mlinux-switch-apn to switch the APN when the radio is ready, before dialing"
exit 0
fi
fi
-
+#
#
# Wait for the radio to be ready before continuing
#
@@ -98,7 +133,6 @@ while [ $COUNTER -lt $TIMEOUT ]; do
MODEL=$(radio-query --model)
if [ $? -eq 0 ]; then
echo "Cellular radio firmware has been switched to $FWIMAGE image."
- ((FWIMAGE == 0)) && /usr/sbin/mlinux-switch-apn $FWIMAGE
exit 0
fi
@@ -109,7 +143,7 @@ while [ $COUNTER -lt $TIMEOUT ]; do
sleep 1
done
-echo "Cellular radio is not ready."
-echo "When it becomes ready, invoke /usr/sbin/mlinux-switch-apn"
-echo "to set the APN"
+>&2 echo "Cellular radio is not ready."
+>&2 echo "When it becomes ready, invoke /usr/sbin/mlinux-switch-apn"
+>&2 echo "to set the APN"
exit 1
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts.inc b/recipes-core/mlinux-scripts/mlinux-scripts.inc
index a8eb832..4e098aa 100644
--- a/recipes-core/mlinux-scripts/mlinux-scripts.inc
+++ b/recipes-core/mlinux-scripts/mlinux-scripts.inc
@@ -11,6 +11,7 @@ SRC_URI = "file://mlinux-wifi-ap \
file://mlinux-switch-apn \
file://mlinux-switch-cell-fw \
file://mlinux-cell-router \
+ file://mlinux-cell-radio-ready \
file://mlinux-firmware-upgrade \
"
@@ -23,5 +24,6 @@ do_install() {
install -m 755 ${WORKDIR}/mlinux-switch-apn ${D}${sbindir}
install -m 755 ${WORKDIR}/mlinux-switch-cell-fw ${D}${sbindir}
install -m 755 ${WORKDIR}/mlinux-cell-router ${D}${sbindir}
+ install -m 755 ${WORKDIR}/mlinux-cell-radio-ready ${D}${sbindir}
install -m 755 ${WORKDIR}/mlinux-firmware-upgrade ${D}${sbindir}
}
diff --git a/recipes-core/mlinux-scripts/mlinux-scripts_1.1.bb b/recipes-core/mlinux-scripts/mlinux-scripts_1.1.bb
index 05c1b84..43dc162 100644
--- a/recipes-core/mlinux-scripts/mlinux-scripts_1.1.bb
+++ b/recipes-core/mlinux-scripts/mlinux-scripts_1.1.bb
@@ -2,6 +2,6 @@ DESCRIPTION = "Scripts to easily get started with common mLinux use cases"
require mlinux-scripts.inc
-PR = "r1"
+PR = "r2"
S = "${WORKDIR}/mlinux-scripts-${PV}"