Turn Wireless On / Off

Hi,

I’m working in building automation systems and one of the buildings we control has MikroTik installed. Few of our controllers have problems of connection on long terms connections when connected through the Wireless. The only 100% functionnal solution I’ve found is turning on/off the wireless on the MikroTik, which let the controllers “re-discover” the connection. Losing the connection for a few seconds is not critical on these controllers.

I’m not comfortable enough in RouterOS scripting language to script anything functionnal.

I need to execute a script that turn the Wireless OFF for 10 seconds every 1 hour. If I loose power while the Router wireless card is stopped, I need to automatically turn it on back again when the power is back.

Thanks in advance for the help!


Simon Lalumière

you have to create scheduler script that is executed on startup to set wireless interface enabled.

and another one that will do your what you want at set interval.

please see how commands are written in CLI as you dont have anything fancy.

Something like this should work. Set to run on startup and then every hour… I haven’t tested it.

:global firstRun

:if ([ :typeof $firstRun ] = nil ) do={
  /interface enable [find name="wlan1"] 
  :set firstRun false
} else
  /interface disable [find name="wlan1"]
  :delay 10s
  /interface enable [find name="wlan1"]
}

Simon, not sure what you mean by “long terms connections”. In my point of view disabling/enabling the radio is just a workaround and not a fix. If you want to give us more details we could provide you with some ideas, like upgrading software and firmware…

as ohara wrote - while this will work, it is better to get to the root of the problem.

Also, you can look into netwatch, to monitor the link, and then do the “trick” to get wifi back. then your scheduler script have to be executed only on startup if at all.