/system leds add interface=wlan1 leds=user-led type=wireless-status
/system routerboard mode-button set enabled=yes hold-time=3s..10s on-event=on-mode-button-pressed
/system script add dont-require-permissions=yes name=on-mode-button-pressed owner=system source="{}"
/system script edit 0 value-name=source
Place following code into script body:
{
:local DISABLED;
:log info "MODE Button pressed";
:if ( [ /interface wireless get 0 disabled ] ) do={ :set DISABLED "no"; } else={ :set DISABLED "yes"; };
:log info "Switching WiFi disabled mode to [$DISABLED]";
:do { /interface wireless set 0 disabled=$DISABLED } on-error={ :log info "Can not switch WiFi disabled mode to [$DISABLED]"; };
}
/system routerboard mode-button
set enabled=yes on-event=dark-mode
/system script
add comment=defconf dont-require-permissions=no name=dark-mode owner=admin \
policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
source="\r\
\n :if ([system leds settings get all-leds-off] = \"never\") do={ /caps-m
n interface disable [find];\r\
\n /system leds settings set all-leds-off=immediate \r\
\n } else={ /caps-man interface enable [find];\r\
\n /system leds settings set all-leds-off=never \r\
\n }\r\
\n "
i tested this script on CAP AC but it work only on wlan1. it's possible to work with wlan2?Code: Select all/system leds add interface=wlan1 leds=user-led type=wireless-status /system routerboard mode-button set enabled=yes hold-time=3s..10s on-event=on-mode-button-pressed /system script add dont-require-permissions=yes name=on-mode-button-pressed owner=system source="{}" /system script edit 0 value-name=source Place following code into script body: { :local DISABLED; :log info "MODE Button pressed"; :if ( [ /interface wireless get 0 disabled ] ) do={ :set DISABLED "no"; } else={ :set DISABLED "yes"; }; :log info "Switching WiFi disabled mode to [$DISABLED]"; :do { /interface wireless set 0 disabled=$DISABLED } on-error={ :log info "Can not switch WiFi disabled mode to [$DISABLED]"; }; }
{
:local DISABLED;
:log info "MODE Button pressed";
:if ( [ /interface wireless get [ find name=wlan2 ] disabled ] ) do={ :set DISABLED "no"; } else={ :set DISABLED "yes"; };
:log info "Switching WiFi disabled mode to [$DISABLED]";
:do { /interface wireless set [ find name=wlan2 ] disabled=$DISABLED } on-error={ :log info "Can not switch WiFi disabled mode to [$DISABLED]"; };
}
{
:local DISABLED;
:log info "MODE Button pressed";
:if ( [ /interface wireless get [ find name=wlan1 ] disabled ] ) do={ :set DISABLED "no"; } else={ :set DISABLED "yes"; };
:log info "Switching WiFi disabled mode to [$DISABLED]";
:do { /interface wireless set [ find name=wlan1 ] disabled=$DISABLED } on-error={ :log info "Can not switch wlan1 disabled mode to [$DISABLED]"; };
:do { /interface wireless set [ find name=wlan2 ] disabled=$DISABLED } on-error={ :log info "Can not switch wlan2 disabled mode to [$DISABLED]"; };
}
/system leds
:if ([:len [find where leds=user-led]] < 1) do={add leds=user-led type=on}
:log info "Premuto Pulsante"
/interface wireless
:if ([get [find default-name=wlan1] disabled]) do={
:log info "Wi-Fi Attivato"
set [find] disabled=no
/sys leds set [find where leds=user-led] type=on
} else={
:log info "Wi-Fi Disattivato"
set [find] disabled=yes
/sys leds set [find where leds=user-led] type=off
}
/system routerboard mode-button
set enabled=yes on-event="/system leds\r\
\n:if ([:len [find where leds=user-led]] < 1) do={add leds=user-led type=on}\r\
\n:log info \"Premuto Pulsante\"\r\
\n/interface wireless\r\
\n:if ([get [find default-name=wlan1] disabled]) do={\r\
\n :log info \"Wi-Fi Attivato\"\r\
\n set [find] disabled=no\r\
\n /sys leds set [find where leds=user-led] type=on\r\
\n} else={\r\
\n :log info \"Wi-Fi Disattivato\"\r\
\n set [find] disabled=yes\r\
\n /sys leds set [find where leds=user-led] type=off\r\
\n}\r\
\n"
/system routerboard reset-button
set enabled=yes hold-time=0s..1s on-event=on-mode-button-pressed
/system script
add comment="Enabling/disable Wifi Interface when pressing button" dont-require-permissions=yes name=on-mode-button-pressed owner=system policy=read,write source="{\
\n:local DISABLED;\
\n:log info \"MODE Button pressed\";\
\n:if ( [ /interface wireless get 0 disabled ] ) do={ :set DISABLED \"no\"; } else={ :set DISABLED \"yes\"; };\
\n:log info \"Switching WiFi disabled mode to [\$DISABLED]\";\
\n:do { /interface wireless set 0 disabled=\$DISABLED } on-error={ :log info \"Can not switch WiFi disabled mode to [\$DISABLED]\"; };\
\n}"
:log info "Button Pressed"
/interface wireless
:if ([get [find where default-name=wlan1] disabled]) do={
:log info "Wi-Fi ON"
set [find] disabled=no
} else={
:log info "Wi-Fi OFF"
set [find] disabled=yes
}
/interface wireless set wlan1 disabled=(![get wlan1 disabled])
Okay, so Wine, Coffee, fresh Tuscany air....... and scripting in the garden.I try to teach scripting, it's not a controversy, only English is not my language...
Hello.Perhaps a specific time on off
sheduler 23.00 off 6.00 on
add interval=1d name="wifi off" on-event="/interface disable wlan1" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=oct/27/2016 start-time=23:00:00
add interval=1d name="wifi on" on-event="/interface enable wlan1" policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon \
start-date=oct/27/2016 start-time=06:00:00