2 append DRIVERS "mac80211"
6 [ -d /sys/class/ieee80211/$phy ] && return
10 config_get devpath "$device" path
11 [ -n "$devpath" ] && {
12 for _phy in /sys/devices/$devpath/ieee80211/phy*; do
13 case "$(readlink -f /sys/class/ieee80211/$_phy/device)" in
19 local macaddr="$(config_get "$device" macaddr | tr 'A-Z' 'a-z')"
20 [ -n "$macaddr" ] && {
21 for _phy in /sys/class/ieee80211/*; do
22 [ -e "$_phy" ] || continue
24 [ "$macaddr" = "$(cat ${_phy}/macaddress)" ] || continue
36 config_get phy "$device" phy
38 [ -n "$phy" -a -d "/sys/class/ieee80211/$phy" ] || {
39 echo "PHY for wifi device $1 not found"
42 config_set "$device" phy "$phy"
44 config_get macaddr "$device" macaddr
45 [ -z "$macaddr" ] && {
46 config_set "$device" macaddr "$(cat /sys/class/ieee80211/${phy}/macaddress)"
52 check_mac80211_device() {
53 config_get phy "$1" phy
55 find_mac80211_phy "$1" >/dev/null || return 0
56 config_get phy "$1" phy
58 [ "$phy" = "$dev" ] && found=1
65 config_get type "radio$devidx" type
66 [ -n "$type" ] || break
67 devidx=$(($devidx + 1))
70 for _dev in /sys/class/ieee80211/*; do
71 [ -e "$_dev" ] || continue
76 config_foreach check_mac80211_device wifi-device
77 [ "$found" -gt 0 ] && continue
84 iw phy "$dev" info | grep -q 'Capabilities:' && htmode=HT20
85 iw phy "$dev" info | grep -q '2412 MHz' || { mode_band="a"; channel="36"; }
87 vht_cap=$(iw phy "$dev" info | grep -c 'VHT Capabilities')
88 cap_5ghz=$(iw phy "$dev" info | grep -c "Band 2")
89 [ "$vht_cap" -gt 0 -a "$cap_5ghz" -gt 0 ] && {
95 [ -n $htmode ] && append ht_capab " option htmode $htmode" "$N"
97 if [ -x /usr/bin/readlink -a -h /sys/class/ieee80211/${dev} ]; then
98 path="$(readlink -f /sys/class/ieee80211/${dev}/device)"
102 if [ -n "$path" ]; then
103 path="${path##/sys/devices/}"
104 path="${path##platform/}"
105 dev_id=" option path '$path'"
107 dev_id=" option macaddr $(cat /sys/class/ieee80211/${dev}/macaddress)"
111 config wifi-device radio$devidx
113 option channel ${channel}
114 option hwmode 11${mode_band}
117 # REMOVE THIS LINE TO ENABLE WIFI:
121 option device radio$devidx
125 option encryption none
128 devidx=$(($devidx + 1))