Community discussions

MikroTik App
 
lamclennan
just joined
Topic Author
Posts: 18
Joined: Wed Aug 17, 2016 8:14 am
Location: Mungindi

Script to switch wlan between ap-bridge and station

Sun May 21, 2023 5:27 am

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.
 
lamclennan
just joined
Topic Author
Posts: 18
Joined: Wed Aug 17, 2016 8:14 am
Location: Mungindi

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

Sun May 21, 2023 9:34 am

: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 };
};
};
 
holvoetn
Forum Guru
Forum Guru
Posts: 5465
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

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

Sun May 21, 2023 10:15 am

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
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

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

Sun May 21, 2023 7:11 pm

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...

Who is online

Users browsing this forum: No registered users and 19 guests