Here we have tested on 2 sims, one from Telstra & another from Optus:
{
:global initTimeout 60
:global connectTimeout 60
:global minimumSignalLevel -97
:global switchSIM do={
:local simSlot [/system routerboard modem get sim-slot]
:if ($simSlot= "down") do={
:log info message="Switching to \"up\" sim slot (Telstra)"
/interface lte set [find] apn-profile=telstra
/system routerboard modem set sim-slot=up
} else={
:log info message="Switching to \"down\" sim slot (Optus)"
/interface lte set [find] apn-profile=optus
/system routerboard modem set sim-slot=down
}
}
:global initialize do={
:global initTimeout
:local i 0
:while ($i < $initTimeout) do={
:if ([:len [/interface lte find ]] > 0) do={
:return true
}
:set $i ($i+1)
:delay 1s
}
:return false
}
:global waitConnect do={
:global connectTimeout
:local i 0
:while ($i < $connectTimeout) do={
:if ([/interface lte get [find name="lte1"] running] = true) do={
:return true
}
:set $i ($i+1)
:delay 1s
}
:return false
}
:if ([$initialize] = true) do={
:if ([$waitConnect] = true) do={
:local info [/interface lte info lte1 once as-value]
:local rssi ($info->"rssi")
:if ($rssi < $minimumSignalLevel) do={
:log info message=("Current RSSI ".$rssi." < ".$minimumSignalLevel.". Trying to switch active sim slot.")
$switchSIM
}
} else={
:log info message="GSM network is not connected. Trying to switch active sim slot."
$switchSIM
}
} else={
:log info message="LTE modem did not appear, trying power-reset"
/system routerboard usb power-reset duration=5s
}
}
And then a scheduler to run this script after a certain period of time:
/system scheduler add interval=3m on-event=failoverScript name="SIM Switch"
Hope this will help many geeks