From: Sujith Manoharan <c_man...@qca.qualcomm.com>

Use the HW mode to determine which channel to choose
when the card is dual-band, otherwise, a channel from
the 2GHz band would be chosen when "hwmode" is set to "11a" or 11na".

Signed-off-by: Sujith Manoharan <c_man...@qca.qualcomm.com>
---
 package/mac80211/files/lib/wifi/mac80211.sh | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/package/mac80211/files/lib/wifi/mac80211.sh 
b/package/mac80211/files/lib/wifi/mac80211.sh
index a052a1c..7a6f05c 100644
--- a/package/mac80211/files/lib/wifi/mac80211.sh
+++ b/package/mac80211/files/lib/wifi/mac80211.sh
@@ -19,12 +19,6 @@ mac80211_hostapd_setup_base() {
 
        [ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
 
-       [ "$channel" = auto ] && {
-               channel=$(iw phy "$phy" info | \
-                       sed -ne '/MHz/ { /disabled\|passive\|radar/d; s/.*\[//; 
s/\].*//; p; q }')
-               config_set "$device" channel "$channel"
-       }
-
        [ -n "$hwmode" ] && {
                config_get hwmode_11n "$device" hwmode_11n
                [ -n "$hwmode_11n" ] && {
@@ -43,6 +37,20 @@ mac80211_hostapd_setup_base() {
                }
        }
 
+       [ "$channel" = auto ] && {
+               case "$hwmode" in
+               b|g)
+                       channel=$(iw phy "$phy" info | \
+                           sed -ne '/MHz/ { 
/^.*5.*\|disabled\|passive\|radar/d; s/.*\[//; s/\].*//; p; q }')
+                       ;;
+               a)
+                       channel=$(iw phy "$phy" info | \
+                           sed -ne '/MHz/ { 
/^.*2.*\|disabled\|passive\|radar/d; s/.*\[//; s/\].*//; p; q }')
+                       ;;
+               esac
+               config_set "$device" channel "$channel"
+       }
+
        local country_ie=0
        [ -n "$country" ] && country_ie=1
        config_get_bool country_ie "$device" country_ie "$country_ie"
-- 
1.8.2.3

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to