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?
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.
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.
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?
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.
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.