2019-09-08 15:09:05 +02:00
|
|
|
. /lib/functions/fff/wireless
|
|
|
|
|
|
|
|
configure() {
|
|
|
|
# get parameters
|
|
|
|
essid=$(uci -q get gateway.@client[0].essid)
|
|
|
|
chan2ghz=$(uci -q get gateway.@client[0].chan2ghz)
|
|
|
|
chan5ghz=$(uci -q get gateway.@client[0].chan5ghz)
|
2023-02-21 23:43:33 +01:00
|
|
|
width2ghz=$(uci -q get gateway.@client[0].width2ghz || echo 20)
|
|
|
|
width5ghz=$(uci -q get gateway.@client[0].width5ghz || echo 20)
|
|
|
|
|
|
|
|
if [ "$width2ghz" != 20 ] && [ "$width2ghz" != 40 ]; then
|
|
|
|
echo "ERROR: Invalid 2.4 GHz channel width: $width2ghz. Only 20 and 40 MHz are possible."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$width5ghz" != 20 ] && [ "$width5ghz" != 40 ] && [ "$width5ghz" != 80 ]; then
|
|
|
|
echo "ERROR: Invalid 5 GHz channel width: $width5ghz. Only 20, 40 and 80 MHz are possible."
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$width2ghz" == 40 ]; then
|
|
|
|
echo "WARNING: Using 40 MHz channel width on 2.4 GHz is highly discouraged and will probably result in worse throughput"
|
|
|
|
fi
|
2019-09-08 15:09:05 +02:00
|
|
|
|
|
|
|
if [ -z "$essid" ]; then
|
|
|
|
echo "WARNING: No ESSID set! WiFi AP is disabled"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for radio in $(wifiListRadio); do
|
|
|
|
freq="$(wifiGetFreq $radio)"
|
|
|
|
disabled=1
|
|
|
|
|
|
|
|
# Delete wXmesh, wXconfigap
|
|
|
|
uci -q del wireless.w${freq}mesh
|
|
|
|
uci -q del wireless.w${freq}configap
|
|
|
|
|
2023-02-21 23:43:33 +01:00
|
|
|
# Get htmode
|
|
|
|
ht=$(uci -q get wireless.${radio}.htmode)
|
|
|
|
|
2019-09-08 15:09:05 +02:00
|
|
|
if [ -n "$essid" ]; then
|
2023-02-21 23:43:33 +01:00
|
|
|
# set channel and bandwidth for 5ghz
|
2019-09-08 15:09:05 +02:00
|
|
|
if [ "$freq" = "5" ]; then
|
2023-02-21 23:43:33 +01:00
|
|
|
if ! echo "$ht" | grep -q VHT && [ "$width5ghz" == 80 ]; then
|
|
|
|
echo "ERROR: 5 GHz radio does not support 80 MHz channel width"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2019-09-08 15:09:05 +02:00
|
|
|
if [ -z "$chan5ghz" ]; then
|
|
|
|
echo "WARNING: No 5 GHz channel set! Disabling AP on $radio"
|
|
|
|
else
|
|
|
|
uci set wireless.${radio}.channel="$chan5ghz"
|
2023-02-21 23:43:33 +01:00
|
|
|
uci set wireless.${radio}.htmode="${ht%%HT*}HT${width5ghz}"
|
2019-09-08 15:09:05 +02:00
|
|
|
disabled=0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2023-02-21 23:43:33 +01:00
|
|
|
# set channel and bandwidth for 2.4ghz
|
2019-09-08 15:09:05 +02:00
|
|
|
if [ "$freq" = "2" ]; then
|
|
|
|
if [ -z "$chan2ghz" ]; then
|
|
|
|
echo "WARNING: No 2.4 GHz channel set! Disabling AP on $radio"
|
|
|
|
else
|
|
|
|
uci set wireless.${radio}.channel="$chan2ghz"
|
2023-02-21 23:43:33 +01:00
|
|
|
uci set wireless.${radio}.htmode="${ht%%HT*}HT${width2ghz}"
|
2019-09-08 15:09:05 +02:00
|
|
|
disabled=0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# set essid
|
|
|
|
uci set wireless.w${freq}ap.ssid="$essid"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# enable or disable ap interface appropriately. The radios 'disabled'-option is not touched
|
|
|
|
uci set wireless.w${freq}ap.disabled="$disabled"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
apply() {
|
2019-11-23 21:43:02 +01:00
|
|
|
uci -q commit wireless
|
|
|
|
return 0
|
2019-09-08 15:09:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
revert() {
|
2019-11-23 21:43:02 +01:00
|
|
|
uci -q revert wireless
|
|
|
|
return 0
|
2019-09-08 15:09:05 +02:00
|
|
|
}
|