Hi all!
I also vote for this feature - WiFi On/Off button.
In my case I do not usually use WiFi and wanna switch it on only when needed like some guest comes and need Internet on his/her tablet or phone for example.
In order to overcome the current limitation I made a workaround (I'm new with MT so excuse me if there could be any easier solution):
- Create new bridge interface "WiFiOnOff"
- Assign some loopback ip to "WiFiOnOff" like 127.127.127.127
- Create scripts wlan_on, wlan_off that turn on/off the wlan interface and enable/disable the loopback ip assigned to "WiFiOnOff" interface
- Create wlan_on_off_action_check script that checks if there is a change in the loopback 127.127.127.127 availability and runs correspondingly wlan_on or wlan_off
- Add to scheduler a repeat call to wlan_on_off_action_check let say each 30 seconds
- Show the "WiFiOnOff" interface in the LCD menu
- Whenever one want to enable/disable the WiFi from the LCD do: Interfaces -> scroll to WiFiOnOff (NOT the wlan) -> addresses -> enable or disable -> pin code(if set up)
Not the best solution as you go trough 5 menu steps (and PIN) but still faster than to power on and log into my machine and run winbox or ssh or the port knocking script( that I've made for the same purpose) .
Controlling simultaneously both the wlan interface and the availability of the assigned ip to "WiFiOnOff" interface is needed if for any reason one sets the wifi on/off via any other method not this pseudo-lcd-enable/disable.
If anybody is interested here is my wlan_on_off_action_check script with the portknocking part that need to be omitted if only LCD control is desired:
:local "is_wlan_off"
:set "is_wlan_off" [/interface wireless get wlan1 disabled]
:local "spec_ip_num"
:set "spec_ip_num" [/ip address find network="127.127.127.127" address="127.127.127.127/32" ]
:local "is_spec_ip_off"
:set "is_spec_ip_off" [/ip address get $"spec_ip_num" disabled]
:foreach A in=[/ip firewall address-list find name=WLAN_ON_ALLOWED] do={
if (($"is_wlan_off") && ([/ip firewall address-list get $A list]="WLAN_ON_ALLOWED")) do={
:log info "Enable WLAN due to portknock from $[/ip firewall address-list get $A address]"
/system script run wlan_on
/ip firewall address-list remove $A
}
}
:foreach A in=[/ip firewall address-list find name=WLAN_OFF_ALLOWED] do={
if ((!$"is_wlan_off") && ([/ip firewall address-list get $A list]="WLAN_OFF_ALLOWED")) do={
:log info "Disable WLAN due to portknock from $[/ip firewall address-list get $A address]"
/system script run wlan_off
/ip firewall address-list remove $A
}
}
if ( ($"is_wlan_off") && (!$"is_spec_ip_off") ) do={
:log info "Enable WLAN due to dedicated IP up"
/system script run wlan_on
}
if ( (!$"is_wlan_off") && $"is_spec_ip_off") do={
:log info "Disable WLAN due to dedicated IP down"
/system script run wlan_off
}
wlan_on
:local "spec_ip_num"
:set "spec_ip_num" [/ip address find network="127.127.127.127" address="127.127.127.127/32" ]
/ip address set $"spec_ip_num" disabled=no
/interface wireless enable wlan1
wlan_off
:local "spec_ip_num"
:set "spec_ip_num" [/ip address find network="127.127.127.127" address="127.127.127.127/32" ]
/ip address set $"spec_ip_num" disabled=yes
/interface wireless disable wlan1