Dual SIM slots and "--set-primary-sim-slot" UI

Aleksander Morgado aleksander at aleksander.es
Wed Apr 21 19:35:27 UTC 2021


Hey!

>
> I got myself a new toy in the form of a board with dual SIM slots and a
> Quectel RG502Q-EA modem.  Which are hardware features I haven't had
> access to before.
>
> So I wanted to play with the dual SIM slot support in MM.  The short
> version is: It works like a charm!
>

Nice!

> The UI confused me at first, though.
>
> I had this:
>
>    -----------------------------------
>    3GPP EPS |  initial bearer ip type: ipv4v6
>    -----------------------------------
>    SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/0
>             |          sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/0 (active)
>             |                          slot 2: /org/freedesktop/ModemManager1/SIM/1
>    -----------------------------------
>    Bearer   |                   paths: /org/freedesktop/ModemManager1/Bearer/0
>  root at finn:~# mmcli -i 0
>    -------------------------------
>    General    |              path: /org/freedesktop/ModemManager1/SIM/0
>    -------------------------------
>    Properties |            active: yes
>               |              imsi: 24201308500xxxx
>               |             iccid: 8947000020070700yyyy
>               |       operator id: 24201
>               |     operator name: TELENOR
>  root at finn:~# mmcli -i 1
>    -------------------------------
>    General    |              path: /org/freedesktop/ModemManager1/SIM/1
>    -------------------------------
>    Properties |            active: no
>               |             iccid: 8947030512101100zzzz
>
>
> Wanted to switch the active/primary SIM to /org/freedesktop/ModemManager1/SIM/1,
> so I did:
>
>  root at finn:~# mmcli -m any --set-primary-sim-slot=1
>  successfully requested primary SIM switch in modem
>
> which of course didn't work.  For reasons that were not obvious to me at
> all. I got the "Doh!" moment only after after resetting the modem and
> ending up with the SIM paths
>
>  /org/freedesktop/ModemManager1/SIM/2
>  /org/freedesktop/ModemManager1/SIM/3
>
> and got:
>
>  root at finn:~# mmcli -v -m any --set-primary-sim-slot=3
>  [20 Apr 2021, 21:45:51] [Debug] ModemManager process found at ':1.5'
>  [20 Apr 2021, 21:45:51] [Debug] Will look for first available modem
>  [20 Apr 2021, 21:45:51] [Debug] Modem found at '(null)'
>
>  error: couldn't request primary SIM switch: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.InvalidArgs: Cannot switch sim: requested SIM slot number is out of bounds'
>
> So this worked like I wanted it to:
>
>  root at finn:~# mmcli -v -m any --set-primary-sim-slot=2
>  [20 Apr 2021, 21:46:02] [Debug] ModemManager process found at ':1.5'
>  [20 Apr 2021, 21:46:02] [Debug] Will look for first available modem
>  [20 Apr 2021, 21:46:02] [Debug] Modem found at '(null)'
>
>  successfully requested primary SIM switch in modem
>
> And switched the active slot from /org/freedesktop/ModemManager1/SIM/2
> to /org/freedesktop/ModemManager1/SIM/3:
>
>    -----------------------------------
>    3GPP EPS |     initial bearer path: /org/freedesktop/ModemManager1/Bearer/1
>             |  initial bearer ip type: ipv4v6
>    -----------------------------------
>    SIM      |        primary sim path: /org/freedesktop/ModemManager1/SIM/3
>             |          sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/2
>             |                          slot 2: /org/freedesktop/ModemManager1/SIM/3 (active)
>
>
>  root at finn:~# mmcli -i 2
>    -------------------------------
>    General    |              path: /org/freedesktop/ModemManager1/SIM/2
>    -------------------------------
>    Properties |            active: no
>               |              imsi: 24201308500xxxx
>               |             iccid: 8947000020070700yyyy
>               |       operator id: 24201
>               |     operator name: TELENOR
>  root at finn:~# mmcli -i 3
>    -------------------------------
>    General    |              path: /org/freedesktop/ModemManager1/SIM/3
>   -------------------------------
>    Properties |            active: yes
>               |              imsi: 24201305013wwww
>               |             iccid: 8947030512101100zzzz
>               |       operator id: 24201
>               |     operator name: TELENOR
>
>
> I understand now that the --set-primary-sim-slot parameter refers to the
> fixed modem slot numbers 1 and 2, regardless of which index the SIM is
> mapped to.

Exactly, yes.

> So --sim=3 and --set-primary-sim-slot=2 refer to the same
> SIM card.  As do --sim=2 and --set-primary-sim-slot=1.
>

Yes, the DBus object number for the SIM is independent from the SIM
slot number. If you switch slots 10 times, the DBus object numbers
will go increasing all the time, while the slot numbers would still be
the same.

> OK, I accept that slots and cards are two different objects, with their
> own namespace.  But I really found this confusing at first. Not sure
> what I'd want instead, though ;-) Just mentioning it here to document my
> stupidity, in the hope it helps others struggling with the same issue.
>

Haha :D My impression is that this is just something you need to get
used to. The DBus object numbers for the SIM objects, or for the modem
objects for that matter, represent a given SIM card or modem at a
given time. If there is a SIM switch operation, or a modem reboot, the
DBus object numbers will bump.

> And of course to have an excuse to thank you again for the excellent
> work on ModemManager.  Having stuff like that SIM slot switch just work
> out-of-the-box is really impressing me.  Thanks!
>

Great!

One thing though.

In the version you tested, I can see that both SIM cards have the full
SIM information, including MCCMNC, operator id and such. The way we
load that info in the "non active" SIM is a bit... bad. What we did
was internally switch to the non-active SIM card without telling
anyone, load the info, and then switch back to the original SIM. This
works in 90% of the cases, but there are multiple cases where it
doesn't. E.g. if using Sierra's AUTO-SIM logic, this hidden SIM switch
makes the modem reboot  (!) and we have also found several race
conditions because well, fullly initializing the SIM may take time,
and even the firmware itself may have inconsistent states reported.
So, we've disabled that; there is no longer a hidden SIM switch to
load the non-active SIM info. Now we will only provide the info we can
gather from the SIM without switching to it: presence (whether there
is a SIM or not) and ICCID. This change is in git master right now,
and I'm thinking whether we should also backport it to MM 1.16 as
well.

> Now on to testing QMAP and session multiplexing over qmi_wwan :-)
>

Nice! Let me know if you find issues.

> Guess I have to build a version with that support first - the above was
> tested on OpenWrt master with its default MM version (1.16.2.).  My test
> hardware is a ZyXEL NR7101 outdoor CPE, BTW.
>

You'll need git master, yes.

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list