How to Switch Between Physical SIMs and eSIM Profiles on RUTM54 via CLI

Hello,

I’m trying to fully understand how SIM and eSIM switching works on the RUTM54 modem.

Right now, I have 2 physical SIM cards installed. I can easily switch between them via SSH using:

ubus call gsm.modem0 set_sim_slot '{"index":x}'

where x = 1 or 2 depending on which SIM slot I want active.

What I’d like to figure out is how to do the same thing with eSIM. Ideally, I’d like to have:

  • SIM slot 1 (physical)

  • SIM slot 2 (physical)

  • eSIM (with multiple profiles I’ve already set up)

And then be able to switch between all of them in the same way I do with physical SIMs.

Could someone explain the commands needed to activate and swap eSIM profiles on this device, so I can close the gap in my SIM-switching knowledge?

Thanks!

Hi there,

eSIM’s “x” value would start with the number 3, and it goes on depending on how many profiles you have, so 4,5,6,7…

You can also utilize our API calls to switch profiles, more information here: https://developers.teltonika-networks.com/reference/rutm54/7.11.4/v1.3.1/sim-switch

Regards,
M.

Thanks, Matas. That clarifies the indexing for eSIM profiles.

I have a follow-up question based on further testing. The ubus call gsm.modem0 set_sim_slot command successfully switches the SIM, but the selection does not persist through a reboot. After the modem is power-cycled, it reverts to the default SIM slot.

Do you know what the equivalent command in the ubus gsm space would be to make this change survive a reboot? Is there a separate “commit” or “save” command that needs to be executed to write the change to non-volatile memory?

Greetings,

My proposal would be to edit the /etc/rc.local file, which is the startup script. Any commands within the script will be executed automatically with the device bootup.

You can edit the file via the CLI. How to access it can be found here: Command Line Interfaces - Teltonika Networks Wiki

After you successfully log in to the SSH, enter the command vi /etc/rc.local → After you’re in the file, press i on your keyboard, which should allow you to edit the file. Afterwards, add this line to the script:
ubus call gsm.modem0 set_sim_slot <your SIM slot>
Finally, to save, press ESC on your keyboard, and write :wq which should save & exit from the file. And you’re done!

You may also execute the file manually whenever you’d like by entering sh /etc/rc.local in the same exact SSH (CLI) interface.

Regards,
M.

Hello Matas:

After writing a script that executes ubus call gsm.modem0 set_sim_slot '{"index":x}'. I’ve found that it does not work beyond 3. When I do 4 (which would correspond for eSIM profile no.2) it does not execute the swap.

What would be the correct ubus command to execute this swap?

Best,

Esteban

Greetings,

Thanks for getting back.

You would need to look into uci commands - more specifically, uci set simcard.@sim[2].primary='1'

If you write uci show | grep sim into the SSH, you should receive available UCI variables that you can change with the uci set command.

Basically, the [2] in the initial command I gave you, is the index of the SIM card that you’re changing, and the '1' at the end is whether it’s primary or not.

So in my example, I’m setting the 2nd SIM card as primary, but, I’ll also have to set the previous default SIM card as non-primary, so for example uci set simcard.@sim[1].primary='0'

After the commands are done, simply input uci commit to commit the changes, and then do gsmctl -Q to restart the modem.

Regards,
M.

Hi Matas,

That worked! Thanks!

Should I also apply this chain-of-commands to the /etc/rc.local file?

So for example if I want to switch from SIM[2] to SIM[3], do I add these to /etc/rc.local:

uci set simcard.@sim[2].primary='0'
uci set simcard.@sim[3].primary='1'
uci commit simcard
gsmctl -Q

Thanks again!

Glad to hear it worked!

If you want these to run on device startup - yes, add these to the rc.local file in that case. Else - write a script file, run it whenever you feel like switching.

Regards,
M.