diff options
author | John Klug <john.klug@multitech.com> | 2017-08-31 16:45:53 -0500 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2017-09-14 17:34:52 -0500 |
commit | 4c71e7f725e5cab0404a20a63fe699a9f3726b94 (patch) | |
tree | 489b49d2363697391009e988b88706a7d1c661ed /recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw | |
parent | f02d11351f80b47dc37d3e306a1d1ce383b41add (diff) | |
download | meta-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-cell-fw')
-rwxr-xr-x | recipes-core/mlinux-scripts/mlinux-scripts-1.1/mlinux-switch-cell-fw | 84 |
1 files changed, 59 insertions, 25 deletions
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 |