local devpath
config_get devpath "$device" path
[ -n "$devpath" ] && {
- for _phy in /sys/devices/$devpath/ieee80211/phy*; do
- [ -e "$_phy" ] && {
- phy="${_phy##*/}"
- return
- }
+ for phy in $(ls /sys/class/ieee80211 2>/dev/null); do
+ case "$(readlink -f /sys/class/ieee80211/$phy/device)" in
+ *$devpath) return;;
+ esac
done
}
local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
[ -n "$macaddr" ] && {
- for _phy in $(ls /sys/class/ieee80211 2>/dev/null); do
- [ "$macaddr" = "$(cat /sys/class/ieee80211/${_phy}/macaddress)" ] || continue
- phy="$_phy"
+ for _phy in /sys/class/ieee80211/*; do
+ [ -e "$_phy" ] || continue
+
+ [ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue
+ phy="${_phy##*/}"
return
done
}
[ -n "$type" ] || break
devidx=$(($devidx + 1))
done
- for dev in $(ls /sys/class/ieee80211); do
+
+ for _dev in /sys/class/ieee80211/*; do
+ [ -e "$_dev" ] || continue
+
+ dev="${_dev##*/}"
+
found=0
config_foreach check_mac80211_device wifi-device
[ "$found" -gt 0 ] && continue
iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="36"; }
vht_cap=$(iw phy "$dev" info | grep -c 'VHT Capabilities')
- [ "$vht_cap" -gt 0 ] && {
+ cap_5ghz=$(iw phy "$dev" info | grep -c "Band 2")
+ [ "$vht_cap" -gt 0 -a "$cap_5ghz" -gt 0 ] && {
mode_band="a";
channel="36"
htmode="VHT80"
[ -n $htmode ] && append ht_capab " option htmode $htmode" "$N"
- if [ -x /usr/bin/readlink ]; then
+ if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then
path="$(readlink -f /sys/class/ieee80211/${dev}/device)"
+ else
+ path=""
+ fi
+ if [ -n "$path" ]; then
path="${path##/sys/devices/}"
+ case "$path" in
+ platform*/pci*) path="${path##platform/}";;
+ esac
dev_id=" option path '$path'"
else
dev_id=" option macaddr $(cat /sys/class/ieee80211/${dev}/macaddress)"
option device radio$devidx
option network lan
option mode ap
- option ssid OpenWrt
+ option ssid Lede
option encryption none
EOF