[PATCH] mm-broadband-modem-mbim: support hot swapping
Eric Caruso
ejcaruso at chromium.org
Wed Jun 28 21:46:23 UTC 2017
If an MBIM modem supports unsolicited notifications for
subscriber ready status, we can use it to detect when SIM cards
have been removed and reinserted. Upon detection we should re-
probe the modem so that we can configure it for the new SIM.
---
src/mm-broadband-modem-mbim.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c
index 0d1126d4..c95255d9 100644
--- a/src/mm-broadband-modem-mbim.c
+++ b/src/mm-broadband-modem-mbim.c
@@ -88,6 +88,9 @@ struct _MMBroadbandModemMbimPrivate {
/* Access technology updates */
MbimDataClass available_data_classes;
MbimDataClass highest_available_data_class;
+
+ /* For checking whether the SIM has been hot swapped */
+ MbimSubscriberReadyState last_ready_state;
};
/*****************************************************************************/
@@ -2041,8 +2044,18 @@ basic_connect_notification_subscriber_ready_status (MMBroadbandModemMbim *self,
if (ready_state == MBIM_SUBSCRIBER_READY_STATE_INITIALIZED)
mm_iface_modem_update_own_numbers (MM_IFACE_MODEM (self), telephone_numbers);
- /* TODO: handle SIM removal using MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED */
+ if (self->priv->last_ready_state != MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED &&
+ ready_state == MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED) {
+ /* SIM has been removed */
+ mm_iface_modem_update_failed_state (MM_IFACE_MODEM (self),
+ MM_MODEM_STATE_FAILED_REASON_SIM_MISSING);
+ } else if (self->priv->last_ready_state == MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED &&
+ ready_state != MBIM_SUBSCRIBER_READY_STATE_SIM_NOT_INSERTED) {
+ /* SIM has been reinserted */
+ mm_broadband_modem_update_sim_hot_swap_detected (MM_BROADBAND_MODEM (self));
+ }
+ self->priv->last_ready_state = ready_state;
g_strfreev (telephone_numbers);
}
@@ -3165,6 +3178,7 @@ mm_broadband_modem_mbim_new (const gchar *device,
MM_BASE_MODEM_PLUGIN, plugin,
MM_BASE_MODEM_VENDOR_ID, vendor_id,
MM_BASE_MODEM_PRODUCT_ID, product_id,
+ MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, TRUE,
NULL);
}
--
2.12.2
More information about the ModemManager-devel
mailing list