Page 1 of 1

frequency changer

Posted: Sun Jun 21, 2009 1:28 pm
by Andrej90
I had some problems with disturbance signal and i had to make this script.It works on router where interface is set in AP mode.
This is timeschedule and it's interval is 10 sec and call a script timeschange
:do {:global ping "[ping 62.240.12.12 count=1]"} while($ping=1); 
/system scheduler enable schedule-freqchange;
/system scheduler disable timeschedule
It pings until there is one timeout.Then enables schedule-freqchange and disable timeschedule.
When the schedule-freqchange is enabled it calls a freqchange script
:if([/interface wireless get wlan1 frequency]=5000) do={ /interface wireless set wlan1 frequency=5470; /ping 62.240.12.12 count=10; /system scheduler enable timeschedule; /system scheduler disable schedule-freqchange } else={/interface wireless set wlan1 frequency=5000;  /ping 62.240.12.12 count=10; /system scheduler enable timeschedule; /system scheduler disable schedule-freqchange}
The part when the frequency is changed and after that you can see ping command.It's used as delay time.We know when the frequency is changed, it needs some time to get connected and that's why i set a ping command.To give that time.Otherwise it's going to change frequency in circles

Give me some comment about this one :)

Re: frequency changer

Posted: Sun Jun 21, 2009 1:48 pm
by fosben
what about
:delay 5s
and netwatch on up/down events can replace your schedule... and possibly your time delaying problem..

Re: frequency changer

Posted: Sun Jun 21, 2009 1:53 pm
by Andrej90
Haha.Because I'm new in this stuff ping was the first thing that get on my mind :) Yeah i could use :delay :)
Frst i tried to put all in one script but it couldn't work that way.Maybe u have some sugestions ? Or this is alright ?
Thx

Re: frequency changer

Posted: Sun Jun 21, 2009 2:00 pm
by fosben
here you go
/tool netwatch
add comment="" disabled=no down-script=\
    ":if([/interface wireless get wlan1 frequency]=5000) do={ /interface wireless set wlan1 frequency=5470 } else={/interface wireless set wlan1 frequency=5000}" host=\
    62.240.12.12 interval=1m timeout=1s up-script=""
netwatch interval set to 1 minute, but you can change that to 10 sec if you want to...

Re: frequency changer

Posted: Sun Jun 21, 2009 2:06 pm
by Andrej90
yeah it's better than mine.But it's the same thing.Is there any disturbance on processor, because of ping command??

Re: frequency changer

Posted: Sun Jun 21, 2009 2:10 pm
by fosben
its the same as yours because it is yours ;)

I suggest you use the netwatch one, since its easier to look at and to change/disable etc (just one click in /tool netwatch).. but I also suggest that you fix the frequency issues, cause this is like an emergency fix for your problem and should only be used temp...

Re: frequency changer

Posted: Sun Jun 21, 2009 2:14 pm
by Andrej90
The problem is in other peoples mind.Can you get me.I only can move that station somewhere else.Disturbance are because of othere providers.He copy my mac address of that interface and point his anthena in mine.And cut of my signal.Then I change it on another frequency and it's better.

Re: frequency changer

Posted: Wed Jul 22, 2009 1:55 pm
by thavinci
fosben:


Im having troubles as its not doing anything...
How do i fault find it?

In the Down section of Netwatch item i have following code:
:if([/interface wireless get wlan1 frequency]=5180) do={ /interface wireless set wlan1 frequency=4920 } else={/interface wireless set wlan1 frequency=5180}
Im testing this in a testing environment and triggering it by changing host ip address to a invalid one to get it to trigger and change the frequency on wlan1, yet it does nothing.

Re: frequency changer

Posted: Wed Jul 22, 2009 2:04 pm
by thavinci
Ok i found the problem, was missing space after if statement.


However i do have another question, how can i turn this into something that will keep changing frequencies till it finds an available one that works?



Regards.