Hotswapping/reprobing SIMcard

Aleksander Morgado aleksander at aleksander.es
Fri Dec 2 17:11:00 UTC 2016


Hey,

>
> I'm working on an application which utilizes 4 simcards connected to 2
> Sierra Wireless MC7304 modems, to manage an internet connection across
> internet providers / country borders / etc.
>
> Simcards are separated by a GPIO-pin (high/low) to change simslots.
>

I've worked myself with such a system. In my case it was 4 different
modems with 2 SIM cards each.

> The goal is to disable a modem, set simcard in low-power-mode change the
> gpio-pin, set simcard in power-state-on and enable the modem, which will
> save time and prevent the modemmanager-interface from changing.
>
>
> But, currently the only way I've found to change between simslots with
> libmm-glib/mmcli is to fully reset the modem after changing the gpio-pin
> with an AT!RESET.
>

That is what I originally did myself: offline, switch sim with gpio, online.

>
> Case 1: the first simslot is empty the modem goes to state: FAILED => reset,
>

Yes.

>
> Case 2: re-detect the new simcard after modem-low-power-mode needs a reset
> as well,
>

You may want to check ModemManager git master, there is some logic to
support hotswapping SIM cards in there. The guys at Telit did it for
their devices, we may need to extend it for QMI as well.

>
> first case is fine, we are not interested in using the empty simslot so that
> switch can be ignored after initialization, but changing between available
> simcards "on-the-fly" is one of the points of the whole system, so not
> having to reset the modem is much preferred.
>
>
> an example I've been testing with is manually swapping a single simcard (see
> output below, sorry it's quite large) while manually powering down the
> modem/simslot, using qmicli along with mmcli and at-commands.
>

This would require the modem to re-run the initialization step. The
logic supporting hot-swapping is doing that.

>
> [NOTE]
>
>
> we added --uim-power-down and --uim-power-up to qmicli to switch the
> simslot-power on/off, and it's working as intended.
>

Oh, please send the patch to the libqmi-devel mailing list :)

>
> [/NOTE]
>
>
> A working manual example is:
>
>
> Detecting the modem and simcard =>
>
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ sudo qmicli -d /dev/cdc-wdm2
> --dms-uim-get-iccid
> [/dev/cdc-wdm2] UIM ICCID retrieved:
> ICCID: '8945020184920077811'
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -L
> Found 1 modems:
> /org/freedesktop/ModemManager1/Modem/0 [Sierra Wireless, Incorporated]
> MC7304
>
> listing modem 0 info =>
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -m 0
>
> /org/freedesktop/ModemManager1/Modem/0 (device id
> '8bd0cad71e5b53259d0fce6e98dc209d822eb6a7')
>   -------------------------
>   Hardware |   manufacturer: 'Sierra Wireless, Incorporated'
>            |          model: 'MC7304'
>            |       revision: 'SWI9X15C_05.05.58.00 r27038 carmd-fwbuild1
> 2015/03/04 21:30:23'
>            |      supported: 'gsm-umts
>            |                  lte
>            |                  gsm-umts, lte'
>            |        current: 'gsm-umts, lte'
>            |   equipment id: '356853051353789'
>   -------------------------
>   System   |         device: '/sys/devices/pci0000:00/0000:00:14.0/usb3/3-7'
>            |        drivers: 'option1, qmi_wwan'
>            |         plugin: 'Sierra'
>            |   primary port: 'cdc-wdm1'
>            |          ports: 'ttyUSB4 (at), ttyUSB2 (qcdm), cdc-wdm1 (qmi),
> cdc-wdm2 (qmi), wwan1 (net), wwan0 (net)'
>   -------------------------
>   Numbers  |           own : 'unknown'
>   -------------------------
>   Status   |           lock: 'sim-pin'
>            | unlock retries: 'sim-pin (3), sim-pin2 (0), sim-puk (10),
> sim-puk2 (10)'
>            |          state: 'locked'
>            |    power state: 'on'
>            |    access tech: 'unknown'
>            | signal quality: '0' (cached)
>   -------------------------
>   Modes    |      supported: 'allowed: 2g, 3g, 4g; preferred: none'
>            |        current: 'allowed: 2g, 3g, 4g; preferred: none'
>   -------------------------
>   Bands    |      supported: 'dcs, egsm, pcs, g850, u2100, u1900, u800,
> u850, u900, eutran-i, eutran-iii, eutran-vii, eutran-viii, eutran-xx'
>            |        current: 'dcs, egsm, pcs, g850, u2100, u1900, u850,
> u900, eutran-i, eutran-iii, eutran-vii, eutran-viii, eutran-xx'
>   -------------------------
>   IP       |      supported: 'ipv4, ipv6, ipv4v6'
>   -------------------------
>   SIM      |           path: '/org/freedesktop/ModemManager1/SIM/0'
>
>   -------------------------
>   Bearers  |          paths: 'none'
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -i 0
> SIM '/org/freedesktop/ModemManager1/SIM/0'
>   -------------------------
>   Properties |          imsi : 'unknown'
>              |            id : '8945020184920077811'
>              |   operator id : 'unknown'
>              | operator name : 'unknown'
>
>
> simcard is pinlocked, unlocking =>
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -i 0 --pin=XXXX
> successfully sent PIN code to the SIM
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -i 0
> SIM '/org/freedesktop/ModemManager1/SIM/0'
>   -------------------------
>   Properties |          imsi : 'unknown'
>              |            id : '8945020184920077811'
>              |   operator id : 'unknown'
>              | operator name : 'unknown'
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -m 0
> /org/freedesktop/ModemManager1/Modem/0 (device id
> '8bd0cad71e5b53259d0fce6e98dc209d822eb6a7')
>   -------------------------
>   Hardware |   manufacturer: 'Sierra Wireless, Incorporated'
>            |          model: 'MC7304'
>            |       revision: 'SWI9X15C_05.05.58.00 r27038 carmd-fwbuild1
> 2015/03/04 21:30:23'
>            |      supported: 'gsm-umts
>            |                  lte
>            |                  gsm-umts, lte'
>            |        current: 'gsm-umts, lte'
>            |   equipment id: '356853051353789'
>   -------------------------
>   System   |         device: '/sys/devices/pci0000:00/0000:00:14.0/usb3/3-7'
>            |        drivers: 'option1, qmi_wwan'
>            |         plugin: 'Sierra'
>            |   primary port: 'cdc-wdm1'
>            |          ports: 'ttyUSB4 (at), ttyUSB2 (qcdm), cdc-wdm1 (qmi),
> cdc-wdm2 (qmi), wwan1 (net), wwan0 (net)'
>   -------------------------
>   Numbers  |           own : 'unknown'
>   -------------------------
>   Status   |           lock: 'sim-puk2'
>            | unlock retries: 'sim-pin (3), sim-pin2 (0), sim-puk (10),
> sim-puk2 (10)'
>            |          state: 'enabled'
>            |    power state: 'on'
>            |    access tech: 'unknown'
>            | signal quality: '59' (recent)
>   -------------------------
>   Modes    |      supported: 'allowed: 2g, 3g, 4g; preferred: none'
>            |        current: 'allowed: 2g, 3g, 4g; preferred: none'
>   -------------------------
>   Bands    |      supported: 'dcs, egsm, pcs, g850, u2100, u1900, u800,
> u850, u900, eutran-i, eutran-iii, eutran-vii, eutran-viii, eutran-xx'
>            |        current: 'dcs, egsm, pcs, g850, u2100, u1900, u850,
> u900, eutran-i, eutran-iii, eutran-vii, eutran-viii, eutran-xx'
>   -------------------------
>   IP       |      supported: 'ipv4, ipv6, ipv4v6'
>   -------------------------
>   3GPP     |           imei: '356853051353789'
>            |  enabled locks: 'sim'
>            |    operator id: 'unknown'
>            |  operator name: 'unknown'
>            |   subscription: 'unknown'
>            |   registration: 'idle'
>   -------------------------
>   SIM      |           path: '/org/freedesktop/ModemManager1/SIM/0'
>
>   -------------------------
>   Bearers  |          paths: 'none'
>
>
> All well modem and simcard detected and unlocked/enabled, but when changing
> the simcard:
>
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -m 0 -d
> successfully disabled the modem
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ sudo qmicli -d /dev/cdc-wdm2
> --uim-power-down
> [/dev/cdc-wdm2] Successfully performed SIM power down
>
> ****** MANUALLY SWAPPING SIMCARD ******
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ sudo qmicli -d /dev/cdc-wdm2
> --uim-power-up
> [/dev/cdc-wdm2] Successfully performed SIM power up
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ sudo qmicli -d /dev/cdc-wdm2
> --dms-uim-get-iccid
> [/dev/cdc-wdm2] UIM ICCID retrieved:
> ICCID: '8945061304160073201'
>
>
> ICCID is now changed i.e. new simcard is detected =>
>
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -m 0 -e
> successfully enabled the modem
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -m 0
>
> /org/freedesktop/ModemManager1/Modem/0 (device id
> '8bd0cad71e5b53259d0fce6e98dc209d822eb6a7')
>   -------------------------
>   Hardware |   manufacturer: 'Sierra Wireless, Incorporated'
>            |          model: 'MC7304'
>            |       revision: 'SWI9X15C_05.05.58.00 r27038 carmd-fwbuild1
> 2015/03/04 21:30:23'
>            |      supported: 'gsm-umts
>            |                  lte
>            |                  gsm-umts, lte'
>            |        current: 'gsm-umts, lte'
>            |   equipment id: '356853051353789'
>   -------------------------
>   System   |         device: '/sys/devices/pci0000:00/0000:00:14.0/usb3/3-7'
>            |        drivers: 'option1, qmi_wwan'
>            |         plugin: 'Sierra'
>            |   primary port: 'cdc-wdm1'
>            |          ports: 'ttyUSB4 (at), ttyUSB2 (qcdm), cdc-wdm1 (qmi),
> cdc-wdm2 (qmi), wwan1 (net), wwan0 (net)'
>   -------------------------
>   Numbers  |           own : 'unknown'
>   -------------------------
>   Status   |           lock: 'sim-puk2'
>            | unlock retries: 'sim-pin (3), sim-pin2 (0), sim-puk (10),
> sim-puk2 (10)'
>            |          state: 'enabled'
>            |    power state: 'on'
>            |    access tech: 'unknown'
>            | signal quality: '59' (cached)
>   -------------------------
>   Modes    |      supported: 'allowed: 2g, 3g, 4g; preferred: none'
>            |        current: 'allowed: 2g, 3g, 4g; preferred: none'
>   -------------------------
>   Bands    |      supported: 'dcs, egsm, pcs, g850, u2100, u1900, u800,
> u850, u900, eutran-i, eutran-iii, eutran-vii, eutran-viii, eutran-xx'
>            |        current: 'dcs, egsm, pcs, g850, u2100, u1900, u850,
> u900, eutran-i, eutran-iii, eutran-vii, eutran-viii, eutran-xx'
>   -------------------------
>   IP       |      supported: 'ipv4, ipv6, ipv4v6'
>   -------------------------
>   3GPP     |           imei: '356853051353789'
>            |  enabled locks: 'sim'
>            |    operator id: 'unknown'
>            |  operator name: 'unknown'
>            |   subscription: 'unknown'
>            |   registration: 'idle'
>   -------------------------
>   SIM      |           path: '/org/freedesktop/ModemManager1/SIM/0'
>
>   -------------------------
>   Bearers  |          paths: 'none'
>
> X at X:~/dev/ModemManager/ModemManager-1.6.4$ ./cli/mmcli -i 0
> SIM '/org/freedesktop/ModemManager1/SIM/0'
>   -------------------------
>   Properties
> |          imsi : 'unknown'
> |            id : '8945020184920077811'
> |   operator id : 'unknown'
> | operator name : 'unknown'
>
>
> qmicli shows the new simcard detected, but mmcli shows the old simcard still
> attached,
>
> is it possible to re-probe the simcard after the simcard-slot has been
> powered down/up without doing a full modem reset with mmcli/libmm ??
>

Yes, again, please check the hotplugging support in git master. The
idea is that when the SIM goes away we mark the modem as "failed" and
when the SIM comes back, we re-run initialization, which will re-query
SIM details. For this, we need support for QMI hot swapping
notifications.

-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list