From f81baaed5486d8aa1d39f700d2001dc0aeb17858 Mon Sep 17 00:00:00 2001 From: Nbiba Bedis Date: Mon, 27 Sep 2021 12:30:08 +0100 Subject: [PATCH] always fallback if multiple channels are not supproted --- src/scripts/create_ap | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/scripts/create_ap b/src/scripts/create_ap index b8a0e9c..3a577b0 100755 --- a/src/scripts/create_ap +++ b/src/scripts/create_ap @@ -1573,32 +1573,38 @@ if [[ $NO_VIRT -eq 0 ]]; then echo "DONE" fi + # Find interface frequency and channel + WIFI_IFACE_FREQ=$(iw dev ${WIFI_IFACE} link | grep -i freq | awk '{print $2}') + 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)" + + # If the frequency is not explicitly set, set one automatically 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_CHANNEL=$(ieee80211_frequency_to_channel ${WIFI_IFACE_FREQ}) - echo -n "${WIFI_IFACE} is already associated with channel ${WIFI_IFACE_CHANNEL} (${WIFI_IFACE_FREQ} MHz)" if is_5ghz_frequency $WIFI_IFACE_FREQ; then FREQ_BAND=5 else FREQ_BAND=2.4 fi - if [[ $WIFI_IFACE_CHANNEL -ne $CHANNEL ]]; then - if ( get_adapter_info ${IFACE} | grep "#channels <= 2" -q ) - then - echo -e "\nmultiple channels supported" - else - echo -e "\nmultiple channels not supported", - echo -e "\nfallback to channel ${WIFI_IFACE_CHANNEL}" - CHANNEL=$WIFI_IFACE_CHANNEL - fi - else - echo "channel------------------ ${CHANNEL}" - 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 + # If the access point channel is the same as the interface channel, do: + # - Make sure that the adapter support multiple channels + # - Otherwise fallback to the same interface channel + if [[ $WIFI_IFACE_CHANNEL -ne $CHANNEL ]]; then + if ( get_adapter_info ${IFACE} | grep "#channels <= 2" -q ) + then + echo -e "\nmultiple channels supported" + else + echo -e "\nmultiple channels not supported", + echo -e "\nfallback to channel ${WIFI_IFACE_CHANNEL}" + CHANNEL=$WIFI_IFACE_CHANNEL + fi + else + echo "channel------------------ ${CHANNEL}" + fi VIRTDIEMSG="Maybe your WiFi adapter does not fully support virtual interfaces. Try again with --no-virt."