Community discussions

 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Script to get RSRP and then do...

Sun Aug 11, 2019 8:32 am

Hi.

I tried to get RSRP value from LTE interface and then do somethings using "if" conditions.

I want to personalyze the numbers of leds (on/off) depending of the signal levels.

I know that you can enable this function using this:
/system leds
add interface=lte1 leds=led1,led2,led3,led4,led5 modem-signal-treshold=-91 type=modem-signal
But I want get something more personalized.

Regards.
Image
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1302
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Script to get RSRP and then do...

Sun Aug 11, 2019 10:47 am

I did some experiment on my hAP lite to represent Wifi signal strength.

Have a look here:
viewtopic.php?t=142132
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Mon Aug 12, 2019 2:31 am

It's a very very interesting code. The problem is that I can't "get" the value name "RSRP".

Regards.
You do not have the required permissions to view the files attached to this post.
Image
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Mon Aug 12, 2019 2:44 am

I found this code that "captures the value" and sends to logs:
/interface lte info lte1 once do={
:log info "RSRP:= $"rsrp""}
The problem is that I not want flood the log of my device with the value of the signal strengh.

Regards.
Image
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Wed Aug 28, 2019 6:45 pm

Ok, I have news. Finally I found the way to capture the RSRP value and set it to a variable:
/interface lte info lte1 once do={:global rsrp1 $"rsrp"};
LtAP has 5 leds for signal strengh that are led1,led2,led3,led4 and led5 respectivelly

Now with the variable rsrp1 that is the signal strengh I need the following:

Between -120 and -111 only led1 on.
Between -110 and -101 led1 and led2 on.
Between -100 and -91 led1, led2 and led3 on.
Between -90 and -81 led1, led2, led3 and led4 on.
major and equal that -80 the 5 leds on.

If none on these condisions are true, set 5 leds off.

I'm very newbie with scripting in general and I will appretiate your help.

Regards.
Image
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Wed Aug 28, 2019 7:58 pm

For now I have this code:
#Create "runLoop" variable
:global runLoop true
#Do the following:
:do {
#See the info of LTE interface
	/interface lte info lte1 once do={
	#Capture RSRP value and save as "RSRP1" variable
		:global rsrp1 $"rsrp"
		#Prevents high CPU utilization
		:delay 100ms
		#End tasks
	}
	#Run it while runLoop variable is true
} while=($runLoop)
Image
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Wed Aug 28, 2019 9:43 pm

Now, I created a code but the log is crazy!
{
:global runloop true
:do {
/interface lte info lte1 once do={
:global rsrp1 $"rsrp"
:delay 100ms
:if ($rsrp1 >= -80) do={
/system leds set 1 leds=led1,led2,led3,led4,led5 type=on
} else={
:if (($rsrp1 >= -90) && ($rsrp1 <= -81)) do={
/system leds set 1 leds=led1,led2,led3,led4 type=on
} else={
:if (($rsrp1 >= -100) && ($rsrp1 <= -91)) do={
/system leds set 1 leds=led1,led2,led3 type=on
} else={
:if (($rsrp1 >= -110) && ($rsrp1 <= -101)) do={
/system leds set 1 leds=led1,led2 type=on
} else={
:if (($rsrp1 >= -120) && ($rsrp1 <= -111)) do={
/system leds set 1 leds=led1 type=on
} else={
/system leds set 1 leds=led1,led2,led3,led4,led5 type=off
}
}
}
}
}
}
} while=($runloop)
}
Regards.
You do not have the required permissions to view the files attached to this post.
Image
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Wed Aug 28, 2019 9:57 pm

Image

Problem is not in syntax in mark place but before.. just "New Terminal" is not good to works with multi-line scripts.
You have a lot :do loop inside other loop. This is not a way.
Remember about one rule in scripting/programming:
Image

a working is this:
{

# Set global $rsrp
#/interface lte info lte1 once do={:global RsrpLte1 $"RsrpLte1"}; # receive "-87dBm"
global RsrpLte1 "-79dBm";
set $RsrpLte1 [/pick $RsrpLte1 0 [/find $RsrpLte1 dBm]];
put $RsrpLte1; # Now it is "-87" without dBm word

#Testing line
/if ($RsrpLte1 > "-80") do={put "$RsrpLte1 is bigger then -80"} else={put "other: $RsrpLte1"};

:if ($RsrpLte1 >= -80) do={
  #/system leds set 1 leds=led1,led2,led3,led4,led5 type=on
  put "5led *****";
  } else={
  :if (($RsrpLte1 <= -81) && ($RsrpLte1 >= -90)) do={
    #/system leds set 1 leds=led1,led2,led3,led4 type=on
    put "4led ****";
    } else={
    :if (($RsrpLte1 <= -91) && ($RsrpLte1 >= -100)) do={
      #/system leds set 1 leds=led1,led2,led3 type=on
      put "3led ***";
      } else={
      :if (($RsrpLte1 <= -101) && ($RsrpLte1 >= -110)) do={
        #/system leds set 1 leds=led1,led2 type=on
        put "2led **";
        } else={
        :if (($RsrpLte1 <= -111) && ($RsrpLte1 >= -120)) do={
          #/system leds set 1 leds=led1 type=on
          put "1led *"
          } else={
          #/system leds set 1 leds=led1,led2,led3,led4,led5 type=off;
          put "off";
        }
      }
    }
  }
}

}
Change many stuff. Now work one time. The Scheduler should run this script every 1 minute. Maybe create a global RsrpLte1History1 ... RsrpLte1History5 and if RsrpLte1AVG we use then this will be more stable and in final way we can use it to other stuff like change a SIM port to other one.

The best setup to testing debug and create a ROS script is:
Image

And maybe better will be add at start condition to start blinking LED only when uptime is bigger then 3 minutes. This not do conflict when you powerup RB and he will be strange blinking :)
Last edited by SiB on Thu Aug 29, 2019 12:55 am, edited 1 time in total.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Thu Aug 29, 2019 12:32 am

Your script not run on my routerboard.

Anyway now is working perfectly except because my log is full while it's running the script.

No way to "say" that not log when I change the led values?

Regards.
Image
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Thu Aug 29, 2019 12:55 am

Your script not run on my routerboard.
Why? Any error, screenshot?
All uniq for hardware stuff are #commented and should works on any RouterOS
Means you should change this:
From this:
#/interface lte info lte1 once do={:global RsrpLte1 $"RsrpLte1"}; # receive "-87dBm"
global RsrpLte1 "-79dBm";
to this
/interface lte info lte1 once do={:global RsrpLte1 $"RsrpLte1"}; # receive "-87dBm"
#global RsrpLte1 "-79dBm";
Please add this into WinBox > System > Script and run it from CLI (WinBox > New Terminal > /system script run NameOfScript ; )
.
Anyway now is working perfectly except because my log is full while it's running the script.
No way to "say" that not log when I change the led values?
If possible then only from WinBox > System > Logging but I not see the LED topic. Search on forum or write e-mail to support.
.
@Jotne in post have some interesting stuff about new option in controling LED. Action is not on/off but BLINKING the LEDs then ge GENERATE many those logs I think. Maybe (s)he can give you answer.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Thu Aug 29, 2019 1:10 am

Sorry, I confussed. The script runs, but no has any effect (Or at least I can't see it).

I attach a screen capture.

I researched about logging, but I think that is not possible because these kind of action can favor malicious activity on routerboards.

Regards.
You do not have the required permissions to view the files attached to this post.
Image
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Thu Aug 29, 2019 1:18 am

I just haven't this hardware and cannot check the Array of RSRP.

Script is working fine. Just uncomment the #/led.... I comment all it because it's breake at my hardware. Insted I create display "3 Led ***".
And please paste and edit script inside WinBox > System > Script, not terminal.
.
Sorry, I confussed. The script runs, but no has any effect (Or at least I can't see it).
.
You not write my post - just check my previouse screenshot, if you don't know where to look then follow the helpers:
Screenshot_3.jpg
Your Part of your screenshot - at the bottom of running script you have results. I just PUT display text "5 Led *****".
Bez-tytułu.png
Code who not work in my scenario but should work in your.
Check this out:
{

# Set global $rsrp
/interface lte info lte1 once do={:global RsrpLte1 $"RsrpLte1"}; # receive "-87dBm"
#global RsrpLte1 "-79dBm";
set $RsrpLte1 [/pick $RsrpLte1 0 [/find $RsrpLte1 dBm]];
put $RsrpLte1; # Now it is "-87" without dBm word

#Testing line
#/if ($RsrpLte1 > "-80") do={put "$RsrpLte1 is bigger then -80"} else={put "other: $RsrpLte1"};

:if ($RsrpLte1 >= -80) do={
  /system leds set 1 leds=led1,led2,led3,led4,led5 type=on
  put "5 Led *****";
  } else={
  :if (($RsrpLte1 <= -81) && ($RsrpLte1 >= -90)) do={
    /system leds set 1 leds=led1,led2,led3,led4 type=on
    put "4 Led ****";
    } else={
    :if (($RsrpLte1 <= -91) && ($RsrpLte1 >= -100)) do={
      /system leds set 1 leds=led1,led2,led3 type=on
      put "3 Led ***";
      } else={
      :if (($RsrpLte1 <= -101) && ($RsrpLte1 >= -110)) do={
        /system leds set 1 leds=led1,led2 type=on
        put "2 Led **";
        } else={
        :if (($RsrpLte1 <= -111) && ($RsrpLte1 >= -120)) do={
          /system leds set 1 leds=led1 type=on
          put "1 Led *"
          } else={
          /system leds set 1 leds=led1,led2,led3,led4,led5 type=off;
          put "- Led";
        }
      }
    }
  }
}

}
You do not have the required permissions to view the files attached to this post.
Last edited by SiB on Sat Aug 31, 2019 12:26 pm, edited 4 times in total.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Thu Aug 29, 2019 9:14 am

Your "/system leds..." command not work. From where you receive it? You tested it?
Screenshot_6.jpg
You do not have the required permissions to view the files attached to this post.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Thu Aug 29, 2019 2:20 pm

Your "/system leds..." command not work. From where you receive it? You tested it?
Screenshot_6.jpg
If I disable the previous assignments made by me, I can use scripts in my LtAP. In my case, I no have problems with it.

Later I will test again the code removing the comments character in the code using script section.

Thanks a lot and regards.
Image
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Thu Aug 29, 2019 3:22 pm

I see at Brochure of your RB LtAP LTE kit and in default state whose LED to do?
Screenshot_9.jpg
You can show some screenshot from WinBox > System > LEDs or some /system leds print detail ?
You do not have the required permissions to view the files attached to this post.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Fri Aug 30, 2019 1:34 am

The default state is all LEDs off except the power led. By default, LED section in Winbox is empty.

Regards.
Image
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Fri Aug 30, 2019 3:27 am

Ok. Finally I runned your script and the results are in the screenshot_6

If I modify the script changing the comment symbol and run, the results are in the screenshoot_7
Your script not run on my routerboard.
From this:
#/interface lte info lte1 once do={:global RsrpLte1 $"RsrpLte1"}; # receive "-87dBm"
global RsrpLte1 "-79dBm";
to this
/interface lte info lte1 once do={:global RsrpLte1 $"RsrpLte1"}; # receive "-87dBm"
#global RsrpLte1 "-79dBm";
Regards.
You do not have the required permissions to view the files attached to this post.
Image
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Fri Aug 30, 2019 5:00 am

I modified my code and now only modify the LED properties when only if necessary:
{
:global ledsafter 10
:global ledsbefore 20
:global runloop true
:do {
/interface lte info lte1 once do={
:global rsrp1 $"rsrp"
:delay 100ms
:if ($rsrp1 >= -80) do={
:global ledsbefore 5
:if ($ledsafter = $ledsbefore) do={
:put "nothing to do"
} else={
/system leds set 1 leds=led1,led2,led3,led4,led5 type=on
:global ledsafter 5
}
} else={
:delay 100ms
:if (($rsrp1 >= -90) && ($rsrp1 <= -81)) do={
:global ledsbefore 4
:if ($ledsafter = $ledsbefore) do={
:put "nothing to do"
} else={
/system leds set 1 leds=led1,led2,led3,led4 type=on
:global ledsafter 4
}
} else={
:delay 100ms
:if (($rsrp1 >= -100) && ($rsrp1 <= -91)) do={
:global ledsbefore 3
:if ($ledsafter = $ledsbefore) do={
:put "nothing to do"
} else={
/system leds set 1 leds=led1,led2,led3 type=on
:global ledsafter 3
}
} else={
:delay 100ms
:if (($rsrp1 >= -110) && ($rsrp1 <= -101)) do={
:global ledsbefore 2
:if ($ledsafter = $ledsbefore) do={
:put "nothing to do"
} else={
/system leds set 1 leds=led1,led2 type=on
:global ledsafter 2
}
} else={
:delay 100ms
:if (($rsrp1 >= -120) && ($rsrp1 <= -111)) do={
:global ledsbefore 1
:if ($ledsafter = $ledsbefore) do={
:put "nothing to do"
} else={
/system leds set 1 leds=led1 type=on
:global ledsafter 1
}
} else={
:global ledsbefore 0
:if ($ledsafter = $ledsbefore) do={
:put "nothing to do"
} else={
/system leds set 1 leds=led1,led2,led3,led4,led5 type=off
:global ledsafter 0
}
}
}
}
}
}
}
} while=($runloop)
}
The theme is when it modifies the LED propieties, I use "ledbefore" to set the quantity of leds that are on and then with "ledafter" it check if the quantity of leds has changed. With this only logs can flood it when the signal changes many times just between 2 different signal levels.

As you can see on screenshot_8, my script i'm running on terminal, the CPU consuption is not too much, the quantity of leds on are correct, the logs are not flooding it and the signal level on the variable, match with the shown on status interface.

With this I can say that works well, but anyway I receive suggesions about it.

Regards.
You do not have the required permissions to view the files attached to this post.
Image
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1302
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Script to get RSRP and then do...

Fri Aug 30, 2019 9:14 am

@krafg

I tried to read your script, but it was very hard to understand do to formatting.
Please use tab for each loop when you make script. I have modified for you.
Try to copy past it to notapad++ and you see what I mean.
{
:global ledsafter 10
:global ledsbefore 20
:global runloop true
:do {
	/interface lte info lte1 once do={
		:global rsrp1 $"rsrp"
		:delay 100ms
		:if ($rsrp1 >= -80) do={
			:global ledsbefore 5
			:if ($ledsafter = $ledsbefore) do={
				:put "nothing to do"
			} else={
				/system leds set 1 leds=led1,led2,led3,led4,led5 type=on
				:global ledsafter 5
			}
		} else={
			:delay 100ms
			:if (($rsrp1 >= -90) && ($rsrp1 <= -81)) do={
				:global ledsbefore 4
				:if ($ledsafter = $ledsbefore) do={
					:put "nothing to do"
				} else={
					/system leds set 1 leds=led1,led2,led3,led4 type=on
					:global ledsafter 4
				}
			} else={
				:delay 100ms
				:if (($rsrp1 >= -100) && ($rsrp1 <= -91)) do={
					:global ledsbefore 3
					:if ($ledsafter = $ledsbefore) do={
						:put "nothing to do"
					} else={
						/system leds set 1 leds=led1,led2,led3 type=on
						:global ledsafter 3
					}
				} else={
					:delay 100ms
					:if (($rsrp1 >= -110) && ($rsrp1 <= -101)) do={
						:global ledsbefore 2
						:if ($ledsafter = $ledsbefore) do={
							:put "nothing to do"
						} else={
							/system leds set 1 leds=led1,led2 type=on
							:global ledsafter 2
						}
					} else={
						:delay 100ms
						:if (($rsrp1 >= -120) && ($rsrp1 <= -111)) do={
							:global ledsbefore 1
							:if ($ledsafter = $ledsbefore) do={
								:put "nothing to do"
							} else={
								/system leds set 1 leds=led1 type=on
								:global ledsafter 1
							}
						} else={
							:global ledsbefore 0
							:if ($ledsafter = $ledsbefore) do={
								:put "nothing to do"
							} else={
								/system leds set 1 leds=led1,led2,led3,led4,led5 type=off
								:global ledsafter 0
							}
						}
					}
				}
			}
		}
	}
} while=($runloop)
}
It also looks like many of the loop are equal, just different values. You should try to make a function of it.
:delay 100ms
:if (($rsrp1 >= -120) && ($rsrp1 <= -111)) do={
	:global ledsbefore 1
	:if ($ledsafter = $ledsbefore) do={
		:put "nothing to do"
	} else={
		/system leds set 1 leds=led1 type=on
		:global ledsafter 1
	}
}
PS First { and last } can be removed. They are only needed when cut/past to terminal. In script it works fine without.
Last edited by krisjanisj on Fri Aug 30, 2019 10:34 am, edited 1 time in total.
Reason: Leave one line free above and below [code][/code] block for it to properly work
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Sat Aug 31, 2019 3:12 am

At start, VERY THANKS for cooperate and screenshot's.
.
The theme is when it modifies the LED properties, I use "ledbefore" to set the quantity of leds that are on and then with "ledafter" it check if the quantity of leds has changed. With this only logs can flood it when the signal changes many times just between 2 different signal levels.
Just create other, separated LogAction for System+Info topics, you can still see them in separate list of logs. To not duplicate it in default info just add !system.
Example: Tested on editing script who do the system+info change.
SystemLogging.jpg
.
the logs are not flooding it
Done. No more duplicate of the same activation LED settings, only if LED count be change then it change. Look below.
.
As you can see on screenshot_8, my script i'm running on terminal, the CPU consuption is not too much
Mutch better if you run this script in /system scheduler with interval 1s or you must see 120Hz refreshing speed :).
Script can be place inside scheduler or run external /system script with our source code.
.
With this I can say that works well, but anyway I receive suggestions about it.
First Optimization... You change simple 34 lines code into 74 lines do-if-else-loop monster :).

Now this $rsrp1 live only inside do-loop and after exiting script save it as environment. Patch:
-interface lte info lte1 once do={:global rsrp1 $"rsrp"; ...
+local Rsrp ([/interface lte info lte1 once as-value]->"rsrp")
Now we can use $Rsrp in whole area of script and we not must remove "dBm" suffix text.

Use Functions, education examples in viewtopic.php?f=9&t=151539#p746898 , simplest example:
local ChangeLeds do={put "Display $1 leds"}; # $1 - first argument
$ChangeLeds 4; # Run function and say to change leds to on 4
.
Instead creating new and new the same global's just change it value, patch:
-global a "new value 1"
-global a "new value 2"
...
+set $a "new value 3"       
+set $a "new value 4"
# This check is global exist, true only when global exist with any of value:
put ([system script environment find name=a]!="")
# Instead:
-:global runloop true; do {...} while={$runloop}
+do while=(1=1) {delay 1s;...} # Really, Scheduler with 1s interval.
.
Next Release Candidate... works without duplication, base on feedback from $LedsCurrent = LastState, it's only must be global variable . Paste in CLI and check.
global LedsCurrent 0
local LteRsrp -121

local ControlLed do={
  if ($1 != $4) do={ system leds set 1 leds=$2 type=$3 }
  return $1
}

do while=(1=1) {
  delay 1s
  set $LteRsrp ([/interface lte info lte1 once as-value]->"rsrp");
  if ($LteRsrp >= -80) do={set $LedsCurrent [$ControlLed 5 led1,led2,led3,led4,led5 on $LedsCurrent ] };
  if (($LteRsrp >= -90) && ($LteRsrp <= -81)) do={set $LedsCurrent [$ControlLed 4 led1,led2,led3,led4 on $LedsCurrent ] };
  if (($LteRsrp >= -100) && ($LteRsrp <= -91)) do={set $LedsCurrent [$ControlLed 3 led1,led2,led3 on $LedsCurrent ] };
  if (($LteRsrp >= -110) && ($LteRsrp <= -101)) do={set $LedsCurrent [$ControlLed 2 led1,led2 on $LedsCurrent ] };
  if (($LteRsrp >= -120) && ($LteRsrp <= -111)) do={set $LedsCurrent [$ControlLed 1 led1 on $LedsCurrent ] };
  if ($LteRsrp <= -121) do={set $LedsCurrent [$ControlLed 0 led1,led2,led3,led4,led5 off $LedsCurrent ] };
}
.
Additional BTW Questions:
Please put result of:
put [/interface lte get lte1 band]
or maybe this info is at WinBox > Interfaces > LTE > lte1 > General or Status tab (you show the Cellular tab before).
Cell-Monitor exist to search band/cell@BTS but maybe you know how to check current used band.

If you think this is solution for a post then mark this answer.
P.S. I am at Telegram if you not understand the final script.
You do not have the required permissions to view the files attached to this post.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Sat Aug 31, 2019 7:43 pm

@Jotne

Sorry for paste here the script without using tab. For the next time I will have it present. I have Notepad++ and I understand it that you mean. I copied so because I test the codes that I write on terminal an the tab makes that on the terminal shows the available commands to insert by way of help. Anyway thanks.

About the function, more or less I understand the concept, but I not know how to do it.

Regards.
Image
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Sat Aug 31, 2019 7:55 pm

Sorry for paste here the script without using tab. For the next time I will have it present. I have Notepad++ and I understand it that you mean.
In notepad++ you can select few lines and press TAB to create a tab-in-many-row-at-once and SHIFT+TAB to reduce tabs in selected row. Easy.
About the function, more or less I understand the concept, but I not know how to do it.
It's done by me. It must be done after doing that big/long code by you. Read one post up. Final code in red "Next Release Candidate and yes, your code have now 20 lines".
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1302
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Script to get RSRP and then do...

Sat Aug 31, 2019 9:17 pm

In notepad++ you can select few lines and press TAB to create a tab-in-many-row-at-once and SHIFT+TAB to reduce tabs in selected row. Easy.
Did not know. Good tips.
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Sat Aug 31, 2019 9:24 pm

Did not know. Good tips.
More importand it's this one: Settings -> Preferences -> Language -> Tab Settings -> Tab size: 2 + [v] Replace by space.
Now you works at 2 spaces. ROS code are cool.
Of course add plugin with Syntax .rsc file must be added as must be.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Sat Aug 31, 2019 10:24 pm

@SiB
It's good idea separate log info on 2 sections, but I think that in my Syslog server anyway will shows all the logs duplicated.

About executing the script every 1 second, I think that is better too, because I have problems with the startup of the script using on "Start Time" as "startup" when my routerboard boot up. Then, I think that this can solve my problem. Simply I set a new Scheduler with "Start Date" = 01/Jan/2019, "Start Time"= 00:00:00, "Interval"= 00:00:01 and "On event"=(The name of the script)

I tested your "Red Release Candidate Code" and works well. It's insanely optimized for me. The only thing now is how can I do to that this can works when my routerboard boots up. I not know if this part is already done or not.

Thanks a lot for your support and the tips with Notepad++. :D

Regards.
Image
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Sat Aug 31, 2019 11:00 pm

but I think that in my Syslog server anyway will shows all the logs duplicated.
If you have LogAction not type=memory but type=remote and you send MikroTik logs to remote SYSLOG server then it's case for his storage etc.
If you send it to The Dude, the same.
If you say Syslog as MikroTik logs then it's not problem, you have this Lines=100 as default but I always change it to 1000 or more.
RMB on WinBox bar and you can add a memory monitoring etc.
Screenshot_10.jpg
If you say you have duplication in this two sections that measn you not finish my howto and the default >>topics=info type=memory<< still have not exclude rule the "!system". Look at screenshot again.
.
.
About executing the script every 1 second, I think that is better too
Perfect
.
.
I have problems with the startup of the script using on "Start Time" as "startup" when my routerboard boot up. Then, I think that this can solve my problem. Simply I set a new Scheduler with "Start Date" = 01/Jan/2019, "Start Time"= 00:00:00, "Interval"= 00:00:01 and "On event"=(The name of the script)
The only thing now is how can I do to that this can works when my routerboard boots up. I not know if this part is already done or not.
This is common. Script is running as other user, *sys who haven't possibility to create global variable and few other limitation.
You can add this:
"start-time=startup on-event"=(delay 20s; /system script run "The name of the script")
. The script itself must have this enable to other user's like *sys can executed it. This one:
Screenshot_11.jpg
This way you wait until MikroTik stop booting process. At least minimum 10s <- important. Next you run your script who start at proper user and will be works after every boot. I use this method to send e-mail with subject=([/system identity get name]." RePowerOn !") - very usefull notification on power loose in branches.
.
.
I tested your "Red Release Candidate Code" and works well. It's insanely optimized for me.
2 beers, 6h and very big happiness at the end that I can do it :). You welcome. All knowledge are written here as Step by Step to know function tricks.
.
.
Thanks a lot for your support and the tips with Notepad++. :D
Regards.
You welcome. Select proper post as solution.
You do not have the required permissions to view the files attached to this post.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Sun Sep 01, 2019 4:24 am

I put a delay of 40 seconds on scheduler and finally starts OK at boot up!

Now I'm going to check the part of logs.

Many thanks and regards.

Edit:

New code on scheduler:
:global lte1 false
/system leds set 1 leds=led1,led2,led3,led4,led5 type=off
:while ($lte1=false) do={
	do {
		:global interface1 [/interface get [find type=lte name=lte1] name]
		:if ($interface1 = "lte1") do={
			:put "LTE1 is now present"
			:global lte1 true
		}
	} on-error={
		:put "LTE1 is not present"
		:delay 500ms
	}
}
/system script run "RSRP"
It is more precise and secure than simply put a delay.

Now I understand because why simply putting the name of my script in my scheduler it not keeps running. The thing is when in the script try to get RSRP of "lte1" at startup, it returns "no such item" and the script brakes. It occurs because after that routerboard finish his boot, LTE interface keeps booting and take some seconds until all booted up. Now on scheduler, first I check that the LTE interface finish his boot with a "While" and already when boot finish, it runs the script.

With "delay" option if I set it on 20 seconds, the script not runs, but when I setted to 40 seconds, it runs because 40 seconds was enough to wait that LTE interface finish his boot and the script find the item "lte1".

On the other hand, I not knew that can put codes on scheduler, it was very usefull for me. Thanks! I'm newly starting with scripting and I'm newbe on these things.

Regards.
Image
 
User avatar
krafg
Member
Member
Topic Author
Posts: 308
Joined: Sun Jun 28, 2015 7:36 pm

Re: Script to get RSRP and then do...

Sun Sep 01, 2019 11:29 am

@SiB

I see that when I change from LTE to 3G, the leds keeps on. With my code, leds turn off because RSRP value is not longer available and RSSI is the new parameter for signal.

When I program the scheduler to run a script every 1 second, the sector writes increases every second. I not know why. Anyway with the last code that I post for scheduler, now the script starts correctly.

I yet have pending the logs section.
Image
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Sun Sep 01, 2019 2:21 pm

The scheduler can use a own script code - and this is perfect for many stuff. Your code is more and more mature :)
On similar topic the @intensex use those lines of code ( change it to show the idea..)
:local Info [/interface lte info [find name="lte1"] once as-value]
:local isRsrp ($Info->"rsrp") ; :local isRssi ($Info->"rssi")
:if ($simSlot="up") do={ :if ($isRsrp<-105 | $isRssi<-110) do={
Reason is the same, when LTE is not connectet but 4G works then not Rsrp but rssi works.
I'm not sure that just those change will be fine in your schema
-if ($LteRsrp >= -80) do={set $LedsCurrent [$ControlLed 5 led1,led2,led3,led4,led5 on $LedsCurrent ] };
+if ($LteRsrp >= -80 | $LteRssi >= -60) do={set $LedsCurrent [$ControlLed 5 led1,led2,led3,led4,led5 on $LedsCurrent ] };
because we should check if connection is lte > rsrp or not_lte > rssi and then run function. To do that you must provide me info from:
# Check this when LTE not work
put [/interface lte info [find name="lte1"] once as-value]->"rsrp")
put [typeof [/interface lte info [find name="lte1"] once as-value]->"rsrp")]
means when LTE is connected then we from ->rsrp receive value but when 4G then what we receive ?? Please check and publish.

And you should create new own assumptions like before:
.
Now with the variable rsrp1 that is the signal strengh I need the following:

Between -120 and -111 only led1 on.
Between -110 and -101 led1 and led2 on.
Between -100 and -91 led1, led2 and led3 on.
Between -90 and -81 led1, led2, led3 and led4 on.
major and equal that -80 the 5 leds on.

If none on these condisions are true, set 5 leds off.
P.S. I hope at the end you create a 10s movie and past it as gif/movie at some portal to share results :D
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software
 
User avatar
SiB
Member Candidate
Member Candidate
Posts: 171
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Script to get RSRP and then do...

Sun Sep 01, 2019 8:52 pm

About Band and speeds. If your are in City then this post is not important and stuff with signal on LEDs are only good addiction to it.

I have the only one Tower from get UMTS(HSPA+) Band 8 (900Mhz) and LTE Band B3(1800Mhz) + B8(900Mhz). All antennas are at the same tower with distance 3km from me.
I use RB751 with USB LTE E3272 with custom firmware that I can select the Band and technology to connect. I have using the external antenna directed to this tower. This E3272 is in router mode that way RB is only dhcp client of it.
.
Aero 2 (26017) 14154 2 3623426 = LTE1800 B3 FDD
  0/5 RSRP -116(-119|-116) RSSI -81 RSRQ -14(-18|-14) SIND -2(-6|-1)
  5x Speedtest.net (min-max): 100-440ms DL: 4,4-7Mbps Ul: 0,5-0,65Mbps

Aero 2 (26017) 14154 12 3623436 = LTE900 B8 FDD
  1/5 RSRP -99(-100|-99)   RSSI -73 RSRQ -10,1(-14|-8) SIND +3(+2|+6)
  5x Speedtest.net: 20-40ms DL: 0,97-3,9Mbps Ul: 2,8-4,3Mbps

Plus (26001) 1151 62715 75494651 = LTE1800 B3 FDD
  5/5 RSSI -75(-83|-60) RSCP -84(-91|-60) EcIo -6(-15|-7)
  5x Speedtest.net: 36-64ms DL: 3,2-6,2Mbps Ul: 1,9-2,2Mbps
.
Those represent the LTE/UMTS data, signal parameter's and speedtest.net.
You can see I have signal 5/5 bar at HSPA+ 4/2Mb but at LTE I must change Band to have fast download or fast upload.

The most important case is if you not setup step-by-step by individual all this band then you not determine his property like speed.
I know what every band represented and can change it to situation.

I have other operator what have 0,5km antenna from me but he not giving a public IP and internet is with limit on GB with big slowdown after reaching this limit, it's worst then old one V.92 56K fax-modem. Current operator give me 100GB and after reach it (every mount I reach it :) ) then limit me to 10/10Mbps but I must have at LTE Band, not UMTS.
Sometimes I use All band with LTE->UMTS selection but by Huawei WebAPI the MikroTik reach current band/technotogy and send me e-mail if this change in 3 minute time.
In future I change location of external antenna. I plan use ESP8266 to auto-change direction of antenna and two USB LTE modem with own switch them or active USB switch and maybe I reach both at the same time. This is completely other stuff :).

At MikroTik R11e-LTE you cannot directly select the band but you can:
/interface lte cell-monitor lte1
# PHY-CELLID:374 | BAND:B3 | EARFCN:1300
# https://wiki.mikrotik.com/wiki/Manual:Interface/LTE#Using_Cell_lock -> <band> Not in use, leave this blank.
/interface lte at-chat lte1 input="AT*Cell=2,3,,1300,374"
As you see by last two parameters you can select the same stuff like band by selecting physical antenna at your tower.
MTCNA + MTCRE + MTCINE | ~600 users at ~150 RouterBoards in EMEA | Telegram: @SiB_PL | WebChat: Tokonda
WinBox Tip: F6 works as ALT+TAB | Gliffy.com - free network schematic | prnt.sc - free ScreenShot software

Who is online

Users browsing this forum: No registered users and 3 guests