Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: typos

...

The second script example shows how to switch between the SIM cards in case a mobile connection is lost on the currently selected one.

Note: Keep in mind that these are just examples of how to utilize dual SIM slots. For real-life production environments, a proper testing should be carried out, so try to optimize them and add new features according to your needs.

...

First, make sure you have correctly set up LTE network parameters (provided by the mobile network operator) for each SIM card. You can use the default APN profile or create two separate ones, follow this link -  LTE#Quicksetupexample. This example uses the default APN profile.

After that, enable data roaming for connecting to other countries data-providers with the following command. This allows us to keep track of roaming status.

...

After changing SIM slots, LTE modem will be restarted. It can take some time (depending on the modem and board around 30 seconds) to fully initialize it, so make sure you test your modem.

...

Now create a script that will run with a scheduler. This script example is going will go through a few key points:

  • Check if the LTE interface is initialized (shows shown in /interface lte list ), otherwise, try a power reset
  • Check if an LTE connection is established (the interface is in a "running" state), otherwise create a log entry and simply wait for the next scheduler
  • Read the currently used LTE slot and make a decision decide whether to change SIM slots based on roaming status

...

Now create a script that will run with a scheduler. This script example is going will go through a few key points:

  • Check if the LTE interface is initialized (shows shown in /interface lte list), otherwise, try a power reset
  • Check if an LTE connection is established (the interface is in a "running" state), otherwise, create a log entry and simply wait for the next scheduler
  • Read the currently used LTE slot and make a decision whether to change SIM slots based on interface status

...

/system scheduler add interval=3m on-event=failoverScript name=Failover

Keep in mind that a "home" SIM card will consume some roaming data because changing SIM slots do does not happen instantly.