u-blox plugin: SIM hot-swap implementation
Thanks for ModemManager.
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.
What is done
All of my patches are available in this branch. It's very raw for pr, so I publish it here.
Description
I define 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) this will produce an error:
GLib-GObject-WARNING **: gsignal.c:xxx: instance `yyy' has no handler with id `zzz'
And I have no idea, how to debug this.
I will be glad to any help or comments, thanks in advance.