Community discussions

MikroTik App
 
OnewheelerSA
just joined
Topic Author
Posts: 2
Joined: Wed Nov 25, 2020 6:41 pm

SXT LTE6 - LTE failover script

Wed Nov 25, 2020 10:49 pm

I seem to have a problem with the below script.
I get the following error: expected end of command (line 56 column 2)

The rest of the script works just fine.
Can anyone assist?
{
# Setup and read current values
:global simSlot [/system routerboard modem get sim-slot]
:global timeoutLTE 60
:global timeoutConnect 60

# Wait for LTE to initialize for maximum "timeoutLTE" seconds
:local i 0
:local isLTEinit false
:while ($i<$timeoutLTE) do={
    :foreach n in=[/interface lte find] do={:set $isLTEinit true}
    :if ($isLTEinit=true) do={
        :set $i $timeoutLTE
    }
    :set $i ($i+1)
    :delay 1s
}

# Check if LTE is initialized, or try power-reset the modem
:if ($isLTEinit=true) do={
    # Wait for LTE interface to connect to mobile network for maximum "timeoutConnet" seconds
    :local isConnected false
    :set $i 0
    :while ($i<$timeoutConnect) do={
        :if ([/interface lte get [find name="lte1"] running]=true) do={
            :set $isConnected true
            :set $i $timeoutConnect
        }
        :set $i ($i+1)
        :delay 1s
    }
    # Check if LTE is connected
    if ($isConnected=false) do={
	# Check which SIM slot is used
        :if ($simSlot="a") do={
            # If "down" slot, switch to up
	    :log info message="LTE down, switching slot to UP"
/interface lte set [find] apn-profile=LTE1
	    /system routerboard modem set sim-slot=b
    }
        :if ($simSlot="b") do={
            # If "up" slot, switch to down
	    :log info message="LTE down, switching slot to DOWN"
/interface lte set [find] apn-profile=LTE2
	    /system routerboard modem set sim-slot=a
            }
        } else={
            # Else "running"
            :if ($isConnected=true) do={
                :log info message="LTE UP"
        }
}
    } else={
        :log info message="LTE interface did not connect to network, wait for next scheduler"
    }
} else={
    :log info message="LTE modem did not appear, trying power-reset"
    /system routerboard usb power-reset duration=5s
}
}

Who is online

Users browsing this forum: No registered users and 26 guests