Thank you @jeff and @dibdot. Both answers do not give the complete solution. The wifi down
and wifi up
commands switch WLAN completely. But I want to switch them independently.
The uci
commands have the result that the interfaces appear to be disabled in the LuCI homepage, but they stay active even if switched off.
If I however combine both commands it will work:
uci -q set wireless.@wifi-iface[1].disabled=1
uci commit wireless
wifi down
wifi up
The disadvantage is that all the WIFI is off for a short time.
I put a small script together (call with switchwlan SSID on|off
):
#!/bin/sh
Interface="$( uci show wireless | grep $1 | cut -d'=' -f1)"
if [ -z "$Interface" ]
then
echo "SSID $1 not found."
else
ucistring=$( echo "${Interface/ssid/disabled}" )
case $2 in
off|Off|OFF|0) uci -q set ${ucistring}=1 ;;
on|On|ON|1) uci -q set ${ucistring}=0 ;;
esac
uci commit wireless
wifi down
sleep 3s
wifi up
fi