Page 1 of 1

Script to switch wlan between ap-bridge and station

Posted: Sun May 21, 2023 5:27 am
by lamclennan
Looking to write a script to swap the wlan interface to ap bridge when it's not running. i.e. permit configuration via wifi

AP i'm using only has one radio so need a way to update the security profile depending of the network i wish to connect. Assume there isn't an easier way or script existing after looking on Google and forums.

Effectively a script that checks the wlan interface status.
If wlan not running and has been more than one minute offline with uptime less than 2 minutes else if offline more than 10 minutes; set to mode bridge-ap, placeholder ssid "ConfigureMePls" and placeholder security profile to bring up other virtual APs.

Keen for thoughts. Else i'll write it in post here when it's done.

Re: Script to switch wlan between ap-bridge and station

Posted: Sun May 21, 2023 9:34 am
by lamclennan
:if ([ /interface wireless get [find name="wlan1"] value-name=running ] = false) do={
:if ([ /interface wireless get [find name="wlan1"] value-name=mode ] != "ap-bridge") do={
:log info "Switching WiFi mode back from station to ap bridge to bring up interface";
:do { /interface wireless set [find name="wlan1"] ssid="ConfigureMePls" };
:do { /interface wireless set [find name="wlan1"] security-profile="configure" };
:do { /interface wireless set [find name="wlan1"] mode=ap-bridge };
};
};

Re: Script to switch wlan between ap-bridge and station

Posted: Sun May 21, 2023 10:15 am
by holvoetn
Since you use legacy wifi...
Ever considered using connect list ?
Might be easier then all this config switching.
Obviously only usable if you know the networks to connect to BUT add your own cell phone wifi hotspot as one and you will always have one.

https://help.mikrotik.com/docs/display/ ... onnectList

Re: Script to switch wlan between ap-bridge and station

Posted: Sun May 21, 2023 7:11 pm
by rextended
The most logical thing is to add a virtual wifi interface (ap-bridge) that activates when the main interface hasn't registered to wifi for x minutes...