-c will not fallback automatically

This commit is contained in:
garywill 2023-10-04 11:21:00 +08:00
parent 992ad00ca1
commit 4e92b3ebf5
1 changed files with 21 additions and 19 deletions

View File

@ -88,7 +88,7 @@ Options:
Using this you can't use same wlan interface Using this you can't use same wlan interface
for both Internet and AP for both Internet and AP
--virt-name <name> Set name of virtual interface --virt-name <name> Set name of virtual interface
-c <channel> Channel number (default: 1) -c <channel> Specify channel (default: use current one, or 1 / 36)
--country <code> Set two-letter country code for regularity --country <code> Set two-letter country code for regularity
(example: US) (example: US)
--freq-band <GHz> Set frequency band: 2.4 or 5 (default: 2.4) --freq-band <GHz> Set frequency band: 2.4 or 5 (default: 2.4)
@ -1571,14 +1571,6 @@ check_wifi_settings() {
exit 1 exit 1
fi fi
if [[ $CHANNEL == default ]]; then
if [[ $FREQ_BAND == 2.4 ]]; then
CHANNEL=1
else
CHANNEL=36
fi
fi
if [[ $FREQ_BAND != 5 && $CHANNEL -gt 14 ]]; then if [[ $FREQ_BAND != 5 && $CHANNEL -gt 14 ]]; then
echo "Channel number is greater than 14, assuming 5GHz frequency band" echo "Channel number is greater than 14, assuming 5GHz frequency band"
FREQ_BAND=5 FREQ_BAND=5
@ -1697,20 +1689,21 @@ prepare_wifi_interface() {
if [[ $NO_VIRT -eq 0 ]]; then if [[ $NO_VIRT -eq 0 ]]; then
## Will generate virtual wifi interface ## Will generate virtual wifi interface
# TODO move this to check_wifi_settings() ?
if is_interface_wifi_connected ${WIFI_IFACE}; then if is_interface_wifi_connected ${WIFI_IFACE}; 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 "${WIFI_IFACE} already in channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)"
if is_5ghz_frequency $WIFI_IFACE_FREQ; then echo "${WIFI_IFACE} already working in channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)"
FREQ_BAND=5
else if [[ $CHANNEL == default ]]; then
FREQ_BAND=2.4 echo "Use wifi adapter current channel $WIFI_IFACE_CHANNEL as target channel"
fi
if [[ $WIFI_IFACE_CHANNEL -ne $CHANNEL ]]; then
echo "Channel fallback to ${WIFI_IFACE_CHANNEL}"
CHANNEL=$WIFI_IFACE_CHANNEL CHANNEL=$WIFI_IFACE_CHANNEL
else fi
echo
if [[ $WIFI_IFACE_CHANNEL -ne $CHANNEL ]]; then
echo "WARN: Wifi adapter already working in channel ${WIFI_IFACE_CHANNEL}, which is different than target channel $CHANNEL" >&2
fi fi
fi fi
@ -1736,6 +1729,15 @@ prepare_wifi_interface() {
else # no virtual wifi interface, use wifi device interface itself else # no virtual wifi interface, use wifi device interface itself
AP_IFACE=${WIFI_IFACE} AP_IFACE=${WIFI_IFACE}
fi fi
if [[ $CHANNEL == default ]]; then
echo "Channel not specified, use default"
if [[ $FREQ_BAND == 2.4 ]]; then
CHANNEL=1
else
CHANNEL=36
fi
fi
} }
decide_subnet_interface() { decide_subnet_interface() {