u-blox plugin: SIM hot-swap implementation
I want to implement a SIM hot-swap feature for u-blox modems(I have SARA-U2 unit), but I have issues and need some help or advise, if possible. I found this feature supported in Telit modems plugin and try to do things similarly.
Description
There are several steps to make SIM hot swap option enabled:
-
Check SIM hot insertion configuration using
+UDCONF=50
command.- If this command returns
+UDCONF=50,1
, the hot insertion is already configured, so we do not need to enable it, goto step 4. - Otherwise, the hot insertion is not configured, so we need to enable it, goto step 2.
- If this command returns
-
Configure SIM hotplug option using
+UDCONF=50,1
command.- This command configures the SIM hot insertion feature.
- The command setting is saved in NVM and will be effective at the next power on (modem reset is required).
-
Perform modem silent reset using
+CFUN=15
command.- MT silent reset (with detach from network and saving of NVM parameters), without reset of the SIM card.
-
Setup
CIEV: 12,(X)
unsolicited response codes processing. These messages allow us to know if SIM is (un)plugged.- Configure the indication of the status of a SIM card(
+CIEV
URC) using+CMER=1,0,0,1,0
command.
- Configure the indication of the status of a SIM card(
What went wrong
Last commit contains a dirty hack with modem reset on every SIM hot-swap. It works, but I am pretty sure, that it is an overkill and bad solution.
In telit plugin there just a mm_broadband_modem_update_sim_hot_swap_detected
call without any resets. I suppose it's not enough in case of u-blox plugin because without modem reset( if I comment line 1010), on any SIM hot-insert/remove this will produce an error:
GLib-GObject-WARNING **: gsignal.c:xxx: instance `yyy' has no handler with id `zzz'
After this warning, MM does not recognize modem correctly:
Modem couldn't be initialized: Couldn't check unlock status: SIM not inserted
warning is produced. So, this results failed
modem state.
MM logs for this (without modem reset): log reduced, log debug
I have no idea, how to debug this.
Comments
There were some comments in the issue:
-
Is +UDCONF=50 specific to a single u-blox device, or generic for all?
- This command is available for several products:
TOBY-L4 TOBY-L200-02S TOBY-L200-03S TOBY-L201-02S TOBY-L210-02S TOBY-L210-03S TOBY-L210-62S TOBY-L220 TOBY-L280 MPCI-L200-02S MPCI-L200-03S MPCI-L201-02S MPCI-L210-02S MPCI-L210-03S MPCI-L220 MPCI-L280 LARA-R2 TOBY-R2 SARA-U2 LISA-U200-01S LISA-U200-02S LISA-U200-03S LISA-U200-52S LISA-U200-62S LISA-U200-83S LISA-U201 LISA-U230 LISA-U260 LISA-U270
and not generic for all :( - For some modules (
LARA-R2, TOBY-R2, SARA-U2, LISA-U2
) for the correct behavior of the SIM hot insertion feature, the SIM card detection feature must be enabled too.
- This command is available for several products:
-
Is the module re-enumerated after
+CFUN=15
?- Module is not re-enumerate after
+CFUN=15
after module connection when SIM hot-swap is not configured (log).
- Module is not re-enumerate after
mmcli -M
/org/freedesktop/ModemManager1/Modem/0 [u-blox] SARA-U201
(-) /org/freedesktop/ModemManager1/Modem/0 [u-blox] SARA-U201
(+) /org/freedesktop/ModemManager1/Modem/0 [u-blox] SARA-U201
- Module is re-enumerated after
+CFUN=15
in runtime when SIM hot-swap is detected.