diff options
Diffstat (limited to 'recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.init')
-rw-r--r-- | recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.init | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.init b/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.init new file mode 100644 index 0000000..82b5cb5 --- /dev/null +++ b/recipes-core/multitech/cell-radio-fwswitch/cell-radio-fwswitch.init @@ -0,0 +1,57 @@ +#!/bin/sh + +# no firmware switch by default +ENABLED="no" +# radio come up timeout +TIMEOUT=15 +# default radio firmware image id +FWIMAGE="0" + +[ -r /etc/default/cell-radio-fwswitch ] && source /etc/default/cell-radio-fwswitch +[ "$ENABLED" == "yes" ] || exit 0 + +function start() { + FWACTIVE=$(radio-query --active-firmware) + if [[ $? != 0 || x"$FWACTIVE" == x"" ]]; then + # radio does not support firmware switching. + exit 0 + fi + + FWSWITCH=$(curl -s 127.0.0.1/api/ppp/modem/fwSwitch | jsparser -p /result/) + if [[ x"$FWSWITCH" == x"" ]]; then + echo "Failed to obtain the radio firmware image id to use." + exit 1 + fi + + if [[ "$FWSWITCH" == "att" ]]; then + FWIMAGE="0" + elif [[ "$FWSWITCH" == "vz" ]]; then + FWIMAGE="1" + else + # autodetect + ICCID=$(radio-query --iccid) + if [ $? -ne 0 ]; then + exit 0 + fi + if [[ "$ICCID" =~ ^89148.* ]]; then + # + # Switch to FW image #1 for Verizon SIMs + # + FWIMAGE="1" + fi + fi + + cell-radio-fwswitch $FWIMAGE $TIMEOUT +} + +case $1 in + start) + start + ;; + + *) + echo "Usage: $0 {start}" + exit 2 + ;; +esac + |