old mode 100644
new mode 100755
@@ -59,8 +59,12 @@ check_mac80211_device() {
}
detect_mac80211() {
- devidx=0
+ local iw_phy_info
+
config_load wireless
+
+ devidx=0
+
while :; do
config_get type "radio$devidx" type
[ -n "$type" ] || break
@@ -81,13 +85,39 @@ detect_mac80211() {
htmode=""
ht_capab=""
- iw phy "$dev" info | grep -q 'Capabilities:' && htmode=HT20
+ iw_phy_info=$( iw phy "${dev}" info )
+
+ echo "${iw_phy_info}" | fgrep -q 'Capabilities:' && htmode=HT20
+
+ if echo "${iw_phy_info}" | egrep -q '(49|5[0-9])[0-9][0-9] MHz' ; then
- iw phy "$dev" info | grep -q '5180 MHz' && {
mode_band="a"
- channel="36"
- iw phy "$dev" info | grep -q 'VHT Capabilities' && htmode="VHT80"
- }
+
+ channel=$( echo "${iw_phy_info}" | \
+ fgrep -v disabled | \
+ sed -Ene 's/^.+ (49|5[0-9])[0-9][0-9] MHz \[([1-9][0-9]{1,2})\].*$/\2/p' | \
+ head -n 1 )
+
+ if [ -z "${channel}" ] ; then
+ logger -p warn -t detect_mac80211 \
+ "No enabled channel found in `iw phy ${dev} info`"
+ fi
+
+ if echo "${iw_phy_info}" | fgrep -q 'VHT Capabilities'
+ then
+ case "$channel" in
+ 36 | 149 )
+ htmode="VHT80"
+ ;;
+ 44 | 157 )
+ htmode="VHT40"
+ ;;
+ *)
+ htmode="VHT20"
+ ;;
+ esac
+ fi
+ fi # 5 GHz
[ -n "$htmode" ] && ht_capab="set wireless.radio${devidx}.htmode=$htmode"