Community discussions

MikroTik App
 
epjvdpalen
just joined
Topic Author
Posts: 16
Joined: Thu May 03, 2018 2:01 pm
Location: The netherlands

capsman wireless standalone flip script asked

Tue Nov 17, 2020 3:48 pm

Hi, anyone can help me?
I'm fairly good with Mikrotik, although not so good with scripting.
Can anyone provide me with an (example) script, that flips the wireless settings on a hap ac lite?

Situation:
- i use capsman extensively on my house/campus
- i have a steel boat that lies alongside my house
- on the outside of the boat a wireless accessoint connects as client ap to my wifi network in the house
- in the steel boat i have a hap ac lite, that connects to my caps manager (192.168.129.254) in my house

In summer i want to go on vacation with the boat
- when i sail to a harbour, the outside client ap connects to the harbour wifi network
- the inside hap ac lite will obviously not find the capsmanager then and needs to provide standalone wireless network
- in wireless settings this can easily be arranged by enabling/disabling CAP for the wireless interface: if cap = enabled, wireless is provided by capsmanager, if not, local wireless settings become active
- i really would like to have a script on the hap ac lite, that polls whether the capsmanager can be found (e.g. ping 192.168.129.254 and work with the result) , and if found: wireless interface cap = enabled, otherwise wireless interface cap = disabled
- in case of disable, local wireless settings will be advertised by the hap ac

anyone? plz? much appreciated!
MT rules! ;-)

UPDATE: Wasn't sure whether to post here or in wireless section, so did both... will remove when answer is provided.

KR, Eric
 
User avatar
inteq
Member
Member
Posts: 406
Joined: Wed Feb 25, 2015 8:15 pm
Location: Romania

Re: capsman wireless standalone flip script asked

Wed Nov 18, 2020 4:30 am

Won't work.
Your hap ac lite will need to enable caps mode to be able to check if it can connect to the manager, disconnecting all wifi clients in the process.
A https://mikrotik.com/product/ltap_mini_lte_kit might work, having a GPS.
You could then script by GPS location.
If at certain coordinate, enable capsman, else disable.
Did not try this kind of setup so is just a theory.
 
Grickos
newbie
Posts: 35
Joined: Thu Aug 06, 2015 2:57 am
Location: Croatia

Re: capsman wireless standalone flip script asked  [SOLVED]

Wed Nov 18, 2020 10:14 am

#:log error "Start script CAp Control"

if ( [/ping 192.168.129.254 count=5 size=64 interval=1s ] =0 ) do={
#:log info "---No Caps Manager---"

if ( [ /interface wireless cap get enabled ] =yes ) do={
/interface wireless cap set enabled=no
:log info "---Disable CAP---"
}
} else={
if ( [ /interface wireless cap get enabled ] =no ) do={
/interface wireless cap set enabled=yes
:log info "---Enable CAP---"
}
}
#:log error "----END CAP script-----"


Start Schedule every 5 minutes, example
 
epjvdpalen
just joined
Topic Author
Posts: 16
Joined: Thu May 03, 2018 2:01 pm
Location: The netherlands

Re: capsman wireless standalone flip script asked

Wed Nov 18, 2020 11:03 am

Kudos Grickos, and thanks for the quick reply!

will try this weekend and let outcome know to you/everybody!
 
epjvdpalen
just joined
Topic Author
Posts: 16
Joined: Thu May 03, 2018 2:01 pm
Location: The netherlands

Re: capsman wireless standalone flip script asked

Wed Nov 18, 2020 12:17 pm

Grickos et al,
Found some time to quickly check. Works like a charm!! THANKS AGAIN.

Note: I added some wireless interface activation, since I noticed that after disabling CAP, the wireless interfaces remained disabled.
Note2: first time one needs to set the 'local SSID' password (e.q. in quickset menu), these are stored in memory so if CAP enables, the normal SSID's are broadcast.
And if CAP disables, 'local Wifi' fires up, the 'local SSID' with 'local password' can be used.
Since pc's, laptops, mobile devices store all SSID/password information, only the first time devices need to be configured.
For the rest automatic change of wifi wil be done by the mobile devices.

Here's my slightly changed script, again with most of it by Grickos. thx mate.

-/-

:log info "START script Wifi control: is CapsMan available?"

if ( [/ping 192.168.129.254 count=5 size=64 interval=1s ] =0 ) do={
:log info "---No Caps Manager available---"
if ( [ /interface wireless cap get enabled ] =yes ) do={
/interface wireless cap set enabled=no
:log error "---Disabling CAP---"
/interface wireless enable wlan1
/interface wireless enable wlan2
:log error "---Enabling local Wifi---"
}
} else={
:log info "---Caps Manager is available---"
if ( [ /interface wireless cap get enabled ] =no ) do={
/interface wireless cap set enabled=yes
:log error "---Enabling CAP---"
}
}
:log info "END script Wifi control"

-/-
 
User avatar
inteq
Member
Member
Posts: 406
Joined: Wed Feb 25, 2015 8:15 pm
Location: Romania

Re: capsman wireless standalone flip script asked

Wed Nov 18, 2020 1:32 pm

I do not get it
You ping the capsman IP and if no response you disable caps mode.
Every X minutes you enable caps mode to check if your device connects to the manager, in the process booting every WiFi device off the network.
That is one weird WiFi experience for devices on that network.
If the client device is connected via cable, it will also loose internet when enabling/disabling caps mode.
 
epjvdpalen
just joined
Topic Author
Posts: 16
Joined: Thu May 03, 2018 2:01 pm
Location: The netherlands

Re: capsman wireless standalone flip script asked

Wed Nov 18, 2020 2:19 pm

Inteq,

This is exactly why first a check is done what current state the cap is in, before changing state.







I do not get it
You ping the capsman IP and if no response you disable caps mode.
Every X minutes you enable caps mode to check if your device connects to the manager, in the process booting every WiFi device off the network.
That is one weird WiFi experience for devices on that network.
If the client device is connected via cable, it will also loose internet when enabling/disabling caps mode.
 
Grickos
newbie
Posts: 35
Joined: Thu Aug 06, 2015 2:57 am
Location: Croatia

Re: capsman wireless standalone flip script asked

Thu Nov 19, 2020 2:17 am

Epjvdpalen,
I'm glad you figured out what to add to the script.
True, Wlan shuts down when the CAP disable.
Someone will need add a script putting Wlan in the bridge and moving from the bridge.
I usually turn off the Log (#) that occurs when running a script. I only release Log changes. -Cap On Cap off. Don't fill me Log spam Every 5 min.
I use these logs when testing, whether the script started, where it stopped and whether it ended. (with "----" to recognize myself as an author in the generic logo, and the color red)
If there are false alarms on the ping, (congested line) set for example / ping 192.168.x.x count = 10 size = 64 interval = 2s. checks 20sec and if none answers, turns off Cap

Sorry for bad english
 
epjvdpalen
just joined
Topic Author
Posts: 16
Joined: Thu May 03, 2018 2:01 pm
Location: The netherlands

Re: capsman wireless standalone flip script asked

Thu Nov 19, 2020 9:23 am

No prob Grickos, everything was understood!
The script will eventually run every 4- 6 hours or so, since this ship can only travel slowly, so not so many log entries will be created and yes, i can always turn them off later. Good suggestion with the # for comments, so scriptlines can be commented out. Was understood as well. (I can read scripts and change them, but totally designing from scratch is something else...)

With respect to the bridge connection: i think (but still have to test further, did not have the time yet) that the initial local configuration will be made first. And when everything works, only then i switch cap on, so the wifi will work from the capsmanager then, keeping the local config stored in the hap ac.

Then, when sailing away, the local config will become active in 4-6 hours. It wil take at least 4-6 hours to reach the nearest harbour.
After a few weeks of holiday, when returning home, cap will be enabled automatically. Worst case it will take 4-6 hours before wifi becomes active via capsman, however upon arriving home, there will be no need for direct in-boat wifi, since we have wifi in house...

Maybe in future, the mikrotik lte with gps positioning is a better alternative, but for now, this will do.

Thx again

Epjvdpalen,
I'm glad you figured out what to add to the script.
True, Wlan shuts down when the CAP disable.
Someone will need add a script putting Wlan in the bridge and moving from the bridge.
I usually turn off the Log (#) that occurs when running a script. I only release Log changes. -Cap On Cap off. Don't fill me Log spam Every 5 min.
I use these logs when testing, whether the script started, where it stopped and whether it ended. (with "----" to recognize myself as an author in the generic logo, and the color red)
If there are false alarms on the ping, (congested line) set for example / ping 192.168.x.x count = 10 size = 64 interval = 2s. checks 20sec and if none answers, turns off Cap

Sorry for bad english

Who is online

Users browsing this forum: MTNick and 22 guests