Skip to content

Instantly share code, notes, and snippets.

@rwasef1830
Created July 9, 2020 02:13
Show Gist options
  • Save rwasef1830/60c0440bf3210cc91c808a606ee304fe to your computer and use it in GitHub Desktop.
Save rwasef1830/60c0440bf3210cc91c808a606ee304fe to your computer and use it in GitHub Desktop.
#!/bin/sh
BAND=${1:?Specify BAND (eg: 1, 3, 5, 7, 28) or 0 to unlock}
if [ "$BAND" != "0" ]; then
FREQ=${2:?Specify DL Frequency x 10 (eg: 18484 for 1848.4 MHz)}
PCI=${3:?Specify tower PCI}
else
echo "./balong-nvtool -m 53810:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"
exit
fi
case $BAND in
''|*[!0-9]*) echo "BAND is not numeric" && exit 1 ;;
*) ;;
esac
case $FREQ in
''|*[!0-9]*) echo "FREQ is not numeric" && exit 1 ;;
*) ;;
esac
case $PCI in
''|*[!0-9]*) echo "PCI is not numeric" && exit 1 ;;
*) ;;
esac
[ $BAND -gt 255 ] && echo "BAND must fit in a single byte" && exit 1;
[ $FREQ -gt 65535 ] && echo "FREQ must fit in 2 bytes" && exit 1;
[ $PCI -gt 65535 ] && echo "PCI must fit in 2 bytes" && exit 1;
dec2hex() {
PRINTF="printf"
if [ -f "/system/bin/busybox" ]; then PRINTF="busybox printf"; fi
$PRINTF "%08X\n" $1
}
CUT="cut"
if [ -f "/system/bin/busybox" ]; then CUT="busybox cut"; fi;
BANDHEX=$(dec2hex $BAND)
FREQHEX=$(dec2hex $FREQ)
PCIHEX=$(dec2hex $PCI)
BANDHEX=$(echo $BANDHEX | $CUT -c7-8)
FREQHEX1=$(echo $FREQHEX | $CUT -c7-8)
FREQHEX2=$(echo $FREQHEX | $CUT -c5-6)
PCIHEX1=$(echo $PCIHEX | $CUT -c7-8)
PCIHEX2=$(echo $PCIHEX | $CUT -c5-6)
echo "./balong-nvtool -m 53810:03:00:00:00:$BANDHEX:01:$BANDHEX:01:$PCIHEX1:$PCIHEX2:$FREQHEX1:$FREQHEX2:00:00:00:00"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment