We are developing a communications system for an UAV helicopter using mikrotik boards. The heli is equipped with a SR2 with two antennas, one located at the left side of the UAV an the other at the right side, so regardless of heli orientation, we have at least one antenna with clear line of sight.
We use a simple script that is monitoring signal strength, and when it's not a value below zeor, we switch antennas.
Here is the code of the script that makes the switching...
Code: Select all
:global radio "wlanSR2";
:global countdown 0;
:global signal;
:global ant;
:log warning "Connection Lost on $radio";
:set ant [/interface wireless get $radio antenna-mode];
:if (ant = "ant-a") do={
/interface wireless set $radio antenna-mode=ant-b;
}
:if (ant = "ant-b") do={
/interface wireless set $radio antenna-mode=ant-a;
}
:set countdown 10;
:set signal 0;
:while ((countdown != 0) && (! (signal<0))) do={
:delay 500ms;
/interface wireless monitor $radio once do={:set signal $"signal-strength";}
:set countdown ($countdown-1);
:log warning "Waiting connection on $radio. Countdown # $countdown . Signal:$signal";
}
}
The problem is when I try to call this Script from the Monitor script... here's the monitor script code.
Code: Select all
:global radio "wlanSR2";
:global signal;
:global snr;
:global noise;
:global thruput;
:global freq;
:global ccq;
:global voltage;
:global rxvar;
:global txvar;
:global txpower;
:global countdown;
:global ant;
:global divisor 0;
:while (1=1) do={
/interface wireless monitor $radio once do={:set signal $"signal-strength";}
:if (! (signal<0)) do={/system script run cambia}
:led user-led=yes;
:set divisor ($divisor+1);
:if (divisor = 5) do={
/interface wireless monitor $radio once do={
:set signal $"signal-strength";
:set snr $"signal-to-noise";
:set noise $"noise-floor";
:set thruput $"p-throughput";
:set freq $"frequency";
:set ccq $"overall-tx-ccq";
:set txpower [/interface wireless get $radio tx-power];
:set voltage [/system health get voltage];
/interface monitor-traffic $radio once do={
:set rxvar $"rx-bits-per-second";
:set txvar $"tx-bits-per-second";
}
}
:set divisor 0;
:log info "RadioName:$radio-$ant_SNR:$snr_Signal:$signal_Noise:$noise_Thruput:$thruput_Freq:$freq_CCQ:$ccq_Volt:$voltage_RX:$rxvar_TX:$txvar_TxPower:$txpower";
}
:delay 45ms;
:led user-led=no;
:delay 45ms;
}
Anyone knows why?
Thank you in advance.