You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

126 lines
2.0 KiB
Bash

#!/bin/sh
#NETMODE=$(uci -q get modemconfig.@modem[0].mode)
#GET_GSM=$(uci -q get modemconfig.@modem[0].gsm_band)
#GET_3G=$(uci -q get modemconfig.@modem[0].3g_band)
#GET_LTE=$(uci -q get modemconfig.@modem[0].lte_band)
#SLOT=$(/usr/bin/mmcli -L | awk '{print $1}' | awk -F [\/] '{print $NF}' | head -1)
BAND2G=""
BAND3G=""
BAND4G=""
# Control empty bands
get_bands(){
if [ "$GET_BAND" ]; then
continue
else
return
fi
}
# Network Mode prefs
set_mode(){
case $NETMODE in
2g)
NMODE=2g
PREFMODE=none
;;
3g)
NMODE=3g
PREFMODE=none
;;
4g)
NMODE=4g
PREFMODE=none
;;
3gp2g)
NMODE="2g|3g"
PREFMODE=2g
;;
p3g2g)
NMODE="2g|3g"
PREFMODE=3g
;;
p4g3g2g)
NMODE="2g|3g|4g"
PREFMODE="4g"
;;
4gp3g2g)
NMODE="2g|3g|4g"
PREFMODE=3g
;;
4g3gp2g)
NMODE="2g|3g|4g"
PREFMODE=2g
;;
p4g3g)
NMODE="4g|3g"
PREFMODE="4g"
;;
4gp3g)
NMODE="4g|3g"
PREFMODE="3g"
;;
esac
}
# Select 2G bands
set_2g(){
GET_BAND="$GET_GSM"
get_bands
for g in $GET_BAND; do
BAND2G="$g|$BAND2G"
done
}
# Select 3G bands
set_3g(){
GET_BAND="$GET_3G"
get_bands
for g in $GET_BAND; do
BAND3G="$g|$BAND3G"
done
}
# Select 4G bands
set_4g(){
GET_BAND="$GET_LTE"
get_bands
for g in $GET_BAND; do
BAND4G="$g|$BAND4G"
done
}
# Reset to defautls bands
reset_to_defaults(){
DEFBAND=""
SUPPORTED_BANDS="$(echo $(mmcli -J -m $SLOT | jsonfilter -e '@["modem"]["generic"]["supported-bands"][*]'))"
for g in $SUPPORTED_BANDS; do
DEFBAND="$g|$DEFBAND"
done
DEFBAND=$(echo $DEFBAND | sed 's/.$//')
}
set_2g
set_3g
set_4g
BAND=$(echo ${BAND2G}${BAND3G}${BAND4G} | sed 's/.$//')
# Select band
if [ "$BAND" ]; then
/usr/bin/mmcli -m $SLOT --set-current-bands="$BAND"
else
reset_to_defaults
/usr/bin/mmcli -m $SLOT --set-current-bands="$DEFBAND"
fi
# Select netmode
if [ "$NETMODE" ]; then
set_mode
/usr/bin/mmcli -m $SLOT --set-allowed-modes="$NMODE" --set-preferred-mode=$PREFMODE
else
/usr/bin/mmcli -m $SLOT --set-allowed-modes="4g|3g" --set-preferred-mode=4g
fi