[package] mac80211: use first available channel from current phy if channel is set...
authorJo-Philipp Wich <jow@openwrt.org>
Sat, 13 Aug 2011 22:55:59 +0000 (22:55 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Sat, 13 Aug 2011 22:55:59 +0000 (22:55 +0000)
SVN-Revision: 27976

package/mac80211/files/lib/wifi/mac80211.sh

index dbf13b8106698b51c8597d43ab9ba7716838319e..86ec75cec300d05c4f1eb179ac19369a12adf46c 100644 (file)
@@ -17,7 +17,13 @@ mac80211_hostapd_setup_base() {
        config_get basic_rate_list "$device" basic_rate
        config_get_bool noscan "$device" noscan
        [ -n "$channel" -a -z "$hwmode" ] && wifi_fixup_hwmode "$device"
-       [ "$channel" = auto ] && channel=
+
+       [ "$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" ] && {