Community discussions

MikroTik App
 
User avatar
Maggiore81
Member
Member
Topic Author
Posts: 367
Joined: Sun Apr 15, 2012 12:10 pm
Location: Italy
Contact:

Wi-Fi on-off switch

Sat Nov 26, 2016 1:19 pm

Hello
is it possible to reprogram in the Hap Lite AC or similar routers, the button to enable or disable the wifi?
Dott. Elia Spadoni
---
Network Administrator
MTCNA, MTCRE, MTCTCE, MTCINE, MTCWE, MTCSE
Spadhausen Internet Provider
Ravenna, ITALY
http://www.spadhausen.com
 
User avatar
w32pamela
Member Candidate
Member Candidate
Posts: 174
Joined: Fri Jul 12, 2013 4:22 pm

Re: Wi-Fi on-off switch

Mon Nov 28, 2016 10:04 pm

In Webfig go to Wireless->Interfaces and click on the button with the "D" or "E" in the first column of the wireless interface you want to disable or enable. "D" will disable and "E" will enable.

In Winbox there won't be a "D" or "E" button. Just highlight the wireless interface you want to change and click the blue check mark to enable or the red X to disable.
 
User avatar
Maggiore81
Member
Member
Topic Author
Posts: 367
Joined: Sun Apr 15, 2012 12:10 pm
Location: Italy
Contact:

Re: Wi-Fi on-off switch

Sat Dec 03, 2016 6:49 pm

I know how to disable end enable the interface. The purpose of programming the button is to tell that to dumb users :D so they can disable the wifi because they think that wifi is not safe!
Dott. Elia Spadoni
---
Network Administrator
MTCNA, MTCRE, MTCTCE, MTCINE, MTCWE, MTCSE
Spadhausen Internet Provider
Ravenna, ITALY
http://www.spadhausen.com
 
etm7469
just joined
Posts: 6
Joined: Wed Apr 22, 2015 10:28 pm
Location: Poland

Re: Wi-Fi on-off switch

Sat Dec 03, 2016 7:19 pm

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
 
User avatar
Maggiore81
Member
Member
Topic Author
Posts: 367
Joined: Sun Apr 15, 2012 12:10 pm
Location: Italy
Contact:

Re: Wi-Fi on-off switch

Sat Dec 03, 2016 7:25 pm

no no scheduler!

My users would like to shutdown the wifi as in the cheap TP LINK routers.
Dott. Elia Spadoni
---
Network Administrator
MTCNA, MTCRE, MTCTCE, MTCINE, MTCWE, MTCSE
Spadhausen Internet Provider
Ravenna, ITALY
http://www.spadhausen.com
 
nelfou
just joined
Posts: 17
Joined: Wed Mar 22, 2017 3:10 pm

Re: Wi-Fi on-off switch

Fri Sep 22, 2017 12:56 pm

Same here.
It'd be nice to be able to customize the hAP button behavior, like having it trigger a script.
We usually don't need WPS while some customers want to be able to easily turn the Wi-Fi on/off.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 24793
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: Wi-Fi on-off switch

Fri Sep 22, 2017 2:03 pm

newer devices have the MODE button that you can use to run any script.
No answer to your question? How to write posts
 
petterg
Member Candidate
Member Candidate
Posts: 226
Joined: Wed Sep 16, 2009 2:55 pm

Re: Wi-Fi on-off switch

Sat Sep 23, 2017 6:30 pm

My home router runs a script that has the intention to enable wlan when someone tries to connect, and disables wlan when no clients are connected. This is scheduled to run every 150seconds. It's not as effective as it sounds. wlan is only disabled 93% of the time when disabled. The reminding 7% of the time it's enabled to check if someone wants to connect. The way it works is:
Enable wireless
sleep for 20 seconds (give clients the possibility to connect if they are there)
if registration table is empty (no clients connected): disable wireless

Windows default wlan scan interval is 60 seconds. If this script runs every X minutes, you frequently will experience that windows will not connect while the wlan is on to check if someone wants to connect. With 150seconds interval, clients usually connects within 70 seconds. In worst case it may take 280 seconds.

Also, I think it's possible to make a button by offering one ethernet port. If you make a microswitch with an ethernet port, where a press of the button will connect the RX and TX pins of the ethernetport, you could use the link up status to trigger a script. I would use a microswitch that only connects the pins while the button is pressed, rather than one that remains connected until button is pressed again.

Finally, if your device has a serial port, I would guess a button could be connected to this as well and trigger a script when pressed.
 
User avatar
jspool
Member
Member
Posts: 425
Joined: Sun Oct 04, 2009 4:06 am
Location: Oregon

Re: Wi-Fi on-off switch

Sat Sep 23, 2017 7:54 pm

Imagine if RouterOS supported Bluetooth! You could scan for specific Bluetooth devices and run scripts based on the results.
 
petterg
Member Candidate
Member Candidate
Posts: 226
Joined: Wed Sep 16, 2009 2:55 pm

Re: Wi-Fi on-off switch

Sun Sep 24, 2017 2:41 pm

I suppose you could even make a sort of switch by inserting a usb stick. If file1 is present on usb storage, run script1. If file2 is present run script2.... Multiple sticks act as different switches.
 
el berto
Member Candidate
Member Candidate
Posts: 213
Joined: Wed Sep 26, 2007 10:53 am

Re: Wi-Fi on-off switch

Mon May 20, 2019 11:30 am

Any update?
I mean through button...
My customers don't want wait for script detection, they say "Netgear wireless routers have external button to enable/disable wifi, why installing MikroTik?"...
 
kelner
just joined
Posts: 8
Joined: Fri Sep 28, 2018 2:10 pm

Re: Wi-Fi on-off switch

Tue Oct 27, 2020 1:00 pm

/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]"; };
}

 
hengst
Frequent Visitor
Frequent Visitor
Posts: 89
Joined: Sun Jan 03, 2010 3:04 pm

Re: Wi-Fi on-off switch

Thu Nov 26, 2020 11:14 am

i found this a nice one using the big button for wifi on/off in the whole building on a Cap(Ac) , and using this Cap(Ac) as Caps manager.

pressing the button will switch off/on all Caps interfaces ( i would set all radio freq of the cap interfaces to static ones also )
user is also sure its off , because leds are all off as well.

:if ([system leds settings get all-leds-off] = "never") do={ /caps-man interface disable [find];
/system leds settings set all-leds-off=immediate
} else={ /caps-man interface enable [find];
/system leds settings set all-leds-off=never
}




/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 "
 
rl2019
just joined
Posts: 3
Joined: Wed Nov 06, 2019 12:58 pm

Re: Wi-Fi on-off switch

Tue Dec 29, 2020 5:13 pm

/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]"; };
}

i tested this script on CAP AC but it work only on wlan1. it's possible to work with wlan2?
 
mkx
Forum Guru
Forum Guru
Posts: 5272
Joined: Thu Mar 03, 2016 10:23 pm

Re: Wi-Fi on-off switch

Tue Dec 29, 2020 7:16 pm

The script only toggles wlan interface #0. You can change script to
{
: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]"; };
}

To operate explicitly named interface. And you can alter script to toggle both interfaces (and the state will follow the first one) this way:
{
    :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]"; };
}
If you changed names from default, then adapt the script accordingly.
BR,
Metod

Who is online

Users browsing this forum: No registered users and 45 guests