firmware/src/packages/fff/fff-wireless/files/etc/layer3.d/28-wifi

86 lines
2.3 KiB
Plaintext

. /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)
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
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
# Get htmode
ht=$(uci -q get wireless.${radio}.htmode)
if [ -n "$essid" ]; then
# set channel and bandwidth for 5ghz
if [ "$freq" = "5" ]; then
if ! echo "$ht" | grep -q VHT && [ "$width5ghz" == 80 ]; then
echo "ERROR: 5 GHz radio does not support 80 MHz channel width"
return 1
fi
if [ -z "$chan5ghz" ]; then
echo "WARNING: No 5 GHz channel set! Disabling AP on $radio"
else
uci set wireless.${radio}.channel="$chan5ghz"
uci set wireless.${radio}.htmode="${ht%%HT*}HT${width5ghz}"
disabled=0
fi
fi
# set channel and bandwidth for 2.4ghz
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"
uci set wireless.${radio}.htmode="${ht%%HT*}HT${width2ghz}"
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() {
uci -q commit wireless
return 0
}
revert() {
uci -q revert wireless
return 0
}