Community discussions

MikroTik App
 
DyadyaGenya
Member Candidate
Member Candidate
Topic Author
Posts: 222
Joined: Mon May 08, 2023 10:34 pm

Connection status is not checked

Sun Nov 12, 2023 8:23 pm

I'm trying to check the signal level of the modem, in particular rssi. It's pretty easy to do.
:put ( [/interface lte monitor lte1 as-value once ] -> "rssi")
But I can't check for a signal. In theory, if you check the data type like this
:put [:typeof ( [/interface lte monitor lte1 as-value once ] -> "rssi")]
will be either "num" or "nothing".
But when I do this check
:if ( :typeof [ [/interface lte monitor lte1 as-value once ] -> "rssi"] = "nothing") do={ :put "No rssi"} else={ :put "Yes rssi"}
The “if” condition is constantly triggered so that I don’t set the check: “num” or “nothing”. And this does not depend on whether the modem is turned on or not.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12558
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Connection status is not checked  [SOLVED]

Mon Nov 13, 2023 2:32 pm

Use the correct syntax... and provide RouterOS version, everytime...

:if ([ :typeof [ ([/interface lte monitor lte1 as-value once ] -> "rssi")] = "nothing") do={ :put "No rssi"} else={ :put "Yes rssi"}

If must be a number, check if is a number, not if is nothing (or nil, etc.)

Write on simple way and indexed, is more easy to find errors and problems.
{
    /interface lte
    :local rssi ([monitor lte1 as-value once]->"rssi")
    :if ([:typeof $rssi] = "num") do={
        :put "RSSI is $rssi"
    } else={
        :put "RSSI NOT returned"
    }
}
 
DyadyaGenya
Member Candidate
Member Candidate
Topic Author
Posts: 222
Joined: Mon May 08, 2023 10:34 pm

Re: Connection status is not checked

Mon Nov 13, 2023 9:00 pm

Use the correct syntax...
Thank you.I haven't used Mikrotik for six months. I forget, plus inattention.
and provide RouterOS version, everytime...
Will try
If must be a number, check if is a number, not if is nothing (or nil, etc.)
What difference does it make what to check: a number or nothing?
Write on simple way and indexed, is more easy to find errors and problems.
I thought that the shorter the line, the smaller the size of the script. In many languages, code size is critical. Even Mikrotik has limitations, like 4MB. Although I don’t remember what exactly the restriction was. And I didn't want to introduce an additional variable.

Who is online

Users browsing this forum: No registered users and 8 guests