[PATCH] mm-broadband-modem-mbim: support hot swapping
Aleksander Morgado
aleksander at aleksander.es
Thu Jun 29 08:51:38 UTC 2017
Hey Eric,
+Carlo in CC
Carlo, would also like your opinion on this.
On 28/06/17 23:46, Eric Caruso wrote:
> 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));
> + }
>
If I'm not mistaken, whenever a sim insert/removal event is detected, we should just call mm_broadband_modem_update_sim_hot_swap_detected(), which will trigger a full modem re-probe. In this case the method is only being called for the case where the SIM is inserted, not for when the SIM is removed.
> + 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);
> }
>
>
--
Aleksander
https://aleksander.es
More information about the ModemManager-devel
mailing list