Don't change frequency band automatically if set by manually

This commit is contained in:
lakinduakash 2019-04-12 18:50:48 +05:30
parent 3601245eaf
commit 512b3ba9bb

View File

@ -345,19 +345,19 @@ is_5ghz_frequency() {
[[ $1 =~ ^(49[0-9]{2})|(5[0-9]{3})$ ]] [[ $1 =~ ^(49[0-9]{2})|(5[0-9]{3})$ ]]
} }
#is_wifi_connected() {
# if [[ $USE_IWCONFIG -eq 0 ]]; then
# iw dev "$1" link 2>&1 | grep -E '^Connected to' > /dev/null 2>&1 && return 0
# else
# iwconfig "$1" 2>&1 | grep -E 'Access Point: [0-9a-fA-F]{2}:' > /dev/null 2>&1 && #return 0
# fi
# return 1
#}
is_wifi_connected() { is_wifi_connected() {
if [[ $USE_IWCONFIG -eq 0 ]]; then
iw dev "$1" link 2>&1 | grep -E '^Connected to' > /dev/null 2>&1 && return 0
else
iwconfig "$1" 2>&1 | grep -E 'Access Point: [0-9a-fA-F]{2}:' > /dev/null 2>&1 && return 0
fi
return 1 return 1
} }
#is_wifi_connected() {
# return 1
#}
is_macaddr() { is_macaddr() {
echo "$1" | grep -E "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$" > /dev/null 2>&1 echo "$1" | grep -E "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$" > /dev/null 2>&1
} }
@ -629,6 +629,7 @@ VHT_CAPAB=
DRIVER=nl80211 DRIVER=nl80211
NO_VIRT=0 NO_VIRT=0
COUNTRY= COUNTRY=
FREQ_BAND_SET=0
FREQ_BAND=2.4 FREQ_BAND=2.4
NEW_MACADDR= NEW_MACADDR=
DAEMONIZE=0 DAEMONIZE=0
@ -1136,6 +1137,7 @@ while :; do
--freq-band) --freq-band)
shift shift
FREQ_BAND="$1" FREQ_BAND="$1"
FREQ_BAND_SET=1
shift shift
;; ;;
--mac) --mac)
@ -1531,7 +1533,8 @@ if [[ $NO_VIRT -eq 0 ]]; then
echo "DONE" echo "DONE"
fi fi
if is_wifi_connected ${WIFI_IFACE}; then
if is_wifi_connected ${WIFI_IFACE} && [[ $FREQ_BAND_SET -eq 0 ]]; then
WIFI_IFACE_FREQ=$(iw dev ${WIFI_IFACE} link | grep -i freq | awk '{print $2}') WIFI_IFACE_FREQ=$(iw dev ${WIFI_IFACE} link | grep -i freq | awk '{print $2}')
WIFI_IFACE_CHANNEL=$(ieee80211_frequency_to_channel ${WIFI_IFACE_FREQ}) WIFI_IFACE_CHANNEL=$(ieee80211_frequency_to_channel ${WIFI_IFACE_FREQ})
echo -n "${WIFI_IFACE} is already associated with channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)" echo -n "${WIFI_IFACE} is already associated with channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)"
@ -1542,12 +1545,16 @@ if [[ $NO_VIRT -eq 0 ]]; then
fi fi
if [[ $WIFI_IFACE_CHANNEL -ne $CHANNEL ]]; then if [[ $WIFI_IFACE_CHANNEL -ne $CHANNEL ]]; then
echo ", fallback to channel ${WIFI_IFACE_CHANNEL}" echo ", fallback to channel ${WIFI_IFACE_CHANNEL}"
#CHANNEL=$WIFI_IFACE_CHANNEL CHANNEL=$WIFI_IFACE_CHANNEL
else else
echo echo "channel------------------ ${CHANNEL}"
fi fi
elif is_wifi_connected ${WIFI_IFACE} && [[ $FREQ_BAND_SET -eq 1 ]]; then
echo "Custom frequency band set with ${FREQ_BAND}Mhz with channel ${CHANNEL}"
fi fi
VIRTDIEMSG="Maybe your WiFi adapter does not fully support virtual interfaces. VIRTDIEMSG="Maybe your WiFi adapter does not fully support virtual interfaces.
Try again with --no-virt." Try again with --no-virt."
echo -n "Creating a virtual WiFi interface... " echo -n "Creating a virtual WiFi interface... "