Version 1 (modified by 22 months ago) (diff) | ,
---|
Switch SIM
Switch SIM ref here
{ # Setup and read current values :global simSlot [/system routerboard sim get sim-slot] :global timeoutLTE 60 :global timeoutConnect 60 :log info message="sim slot $simSlot" # 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 } :log info message="isLTEinit $isLTEinit" # 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 } :log info message="isLTEconnect $isConnected" # Check if LTE is connected :if ($isConnected=false) do={ # Check which SIM slot is used :if ($simSlot="down") do={ # If "down" slot, switch to up :log info message="LTE down, switching slot to UP" /system routerboard sim set sim-slot=up } :if ($simSlot="up") do={ # If "up" slot, switch to down :log info message="LTE down, switching slot to DOWN" /system routerboard sim set sim-slot=down } :log info message="LTE interface did not connect to network, switch sim done wait for next schedule" } else={ :log info message="LTE interface UP" } } else={ :log info message="LTE modem did not appear, trying power-reset" /system routerboard usb power-reset duration=5s } }