Community discussions

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

SXT LTE6 - LTE failover script

Thu Nov 26, 2020 7:50 pm

I recently purchased a SXT LTE6 CPE and I am trying to get the DUAL Sim failover to work.

My current script is below. I would like to add something to check for an active internet connection and failover if the connection is inactive.
There also seems to be some issues with this current script around the last 2 else statements.

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 B"
/interface lte set [find] apn-profile=Vodacom
	    /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 A"
/interface lte set [find] apn-profile=MTN
	    /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
}
}
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1888
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: SXT LTE6 - LTE failover script

Mon Nov 30, 2020 8:46 pm

I not like that script.. maybe you prefer other ways:

Some variation of that Dual Script:
The LTAP can switch the Dual SIM when the RSSI was weakness? - MikroTik
LED SIGNAL per RSRP

Better way to react at not working connection:
Simple watchdog: viewtopic.php?f=7&t=153622&hilit=watchdog#p767767
Advance watchdog: viewtopic.php?f=9&t=151492&hilit=watchdog#p768392
Watch LTE parameters: viewtopic.php?f=7&t=155945&p=821262#p821047

Who is online

Users browsing this forum: No registered users and 17 guests