<div dir="ltr"><div><div><div>Hi all,<br><br></div>I agree with Dan, we should send the unlock csim command. I should be able to test and fix it this afternoon.<br><br></div>BR,<br></div>Carlo<br></div><br><div class="gmail_quote"><div dir="ltr">On Wed, 15 Mar 2017 at 02:40 Dan Williams <<a href="mailto:dcbw@redhat.com">dcbw@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, 2017-03-15 at 00:19 +0100, Aleksander Morgado wrote:<br class="gmail_msg">
> Wrap the AT+CSIM=XX commands between lock (CSIM=1) and<br class="gmail_msg">
> unlock (CSIM=0) operations.<br class="gmail_msg">
><br class="gmail_msg">
> This seems to avoid the TTY lockup seen in several different Telit<br class="gmail_msg">
> modules.<br class="gmail_msg">
><br class="gmail_msg">
> <a href="https://bugs.freedesktop.org/show_bug.cgi?id=100205" rel="noreferrer" class="gmail_msg" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=100205</a><br class="gmail_msg">
><br class="gmail_msg">
> Reported-by: Penalva, Salvador <<a href="mailto:Salvador.Penalva@digi.com" class="gmail_msg" target="_blank">Salvador.Penalva@digi.com</a>><br class="gmail_msg">
> ---<br class="gmail_msg">
><br class="gmail_msg">
> Hey Salvador, Carlo and Daniele,<br class="gmail_msg">
><br class="gmail_msg">
> Can you guys review and test this patch? It looks like it solved the<br class="gmail_msg">
> issue I saw myself.<br class="gmail_msg">
><br class="gmail_msg">
> The AT command reference for the Telit LE866 does say that the<br class="gmail_msg">
> AT+CSIM commands need to be enclosed within lock/unlock operations<br class="gmail_msg">
> like these.<br class="gmail_msg">
<br class="gmail_msg">
If the LOCK succeeds, then don't we need to UNLOCK if some intermediate<br class="gmail_msg">
step fails?  It looks like we'll just leave it in locked state if any<br class="gmail_msg">
step like say PIN or PIN2 calls<br class="gmail_msg">
load_unlock_retries_context_complete_and_free().<br class="gmail_msg">
<br class="gmail_msg">
Dan<br class="gmail_msg">
<br class="gmail_msg">
> ---<br class="gmail_msg">
>  plugins/telit/mm-broadband-modem-telit.c | 60<br class="gmail_msg">
> ++++++++++++++++++++++++++++++++<br class="gmail_msg">
>  1 file changed, 60 insertions(+)<br class="gmail_msg">
><br class="gmail_msg">
> diff --git a/plugins/telit/mm-broadband-modem-telit.c<br class="gmail_msg">
> b/plugins/telit/mm-broadband-modem-telit.c<br class="gmail_msg">
> index b1679ae4..8bc9d1e5 100644<br class="gmail_msg">
> --- a/plugins/telit/mm-broadband-modem-telit.c<br class="gmail_msg">
> +++ b/plugins/telit/mm-broadband-modem-telit.c<br class="gmail_msg">
> @@ -452,6 +452,8 @@ modem_load_supported_bands (MMIfaceModem *self,<br class="gmail_msg">
>  /*******************************************************************<br class="gmail_msg">
> **********/<br class="gmail_msg">
>  /* Load unlock retries (Modem interface) */<br class="gmail_msg">
><br class="gmail_msg">
> +#define CSIM_LOCK_STR               "+CSIM=1"<br class="gmail_msg">
> +#define CSIM_UNLOCK_STR             "+CSIM=0"<br class="gmail_msg">
>  #define CSIM_QUERY_PIN_RETRIES_STR  "+CSIM=10,0020000100"<br class="gmail_msg">
>  #define CSIM_QUERY_PUK_RETRIES_STR  "+CSIM=10,002C000100"<br class="gmail_msg">
>  #define CSIM_QUERY_PIN2_RETRIES_STR "+CSIM=10,0020008100"<br class="gmail_msg">
> @@ -460,10 +462,12 @@ modem_load_supported_bands (MMIfaceModem *self,<br class="gmail_msg">
><br class="gmail_msg">
>  typedef enum {<br class="gmail_msg">
>      LOAD_UNLOCK_RETRIES_STEP_FIRST,<br class="gmail_msg">
> +    LOAD_UNLOCK_RETRIES_STEP_LOCK,<br class="gmail_msg">
>      LOAD_UNLOCK_RETRIES_STEP_PIN,<br class="gmail_msg">
>      LOAD_UNLOCK_RETRIES_STEP_PUK,<br class="gmail_msg">
>      LOAD_UNLOCK_RETRIES_STEP_PIN2,<br class="gmail_msg">
>      LOAD_UNLOCK_RETRIES_STEP_PUK2,<br class="gmail_msg">
> +    LOAD_UNLOCK_RETRIES_STEP_UNLOCK,<br class="gmail_msg">
>      LOAD_UNLOCK_RETRIES_STEP_LAST<br class="gmail_msg">
>  } LoadUnlockRetriesStep;<br class="gmail_msg">
><br class="gmail_msg">
> @@ -500,6 +504,25 @@ modem_load_unlock_retries_finish (MMIfaceModem<br class="gmail_msg">
> *self,<br class="gmail_msg">
>  }<br class="gmail_msg">
><br class="gmail_msg">
>  static void<br class="gmail_msg">
> +csim_unlock_ready (MMBaseModem              *self,<br class="gmail_msg">
> +                   GAsyncResult             *res,<br class="gmail_msg">
> +                   LoadUnlockRetriesContext *ctx)<br class="gmail_msg">
> +{<br class="gmail_msg">
> +    const gchar *response;<br class="gmail_msg">
> +    GError      *error = NULL;<br class="gmail_msg">
> +<br class="gmail_msg">
> +    /* Ignore errors */<br class="gmail_msg">
> +    response = mm_base_modem_at_command_finish (self, res, &error);<br class="gmail_msg">
> +    if (!response) {<br class="gmail_msg">
> +        mm_warn ("Couldn't unlock SIM card: %s", error->message);<br class="gmail_msg">
> +        g_error_free (error);<br class="gmail_msg">
> +    }<br class="gmail_msg">
> +<br class="gmail_msg">
> +    ctx->step++;<br class="gmail_msg">
> +    load_unlock_retries_step (ctx);<br class="gmail_msg">
> +}<br class="gmail_msg">
> +<br class="gmail_msg">
> +static void<br class="gmail_msg">
>  csim_query_ready (MMBaseModem *self,<br class="gmail_msg">
>                    GAsyncResult *res,<br class="gmail_msg">
>                    LoadUnlockRetriesContext *ctx)<br class="gmail_msg">
> @@ -542,6 +565,7 @@ csim_query_ready (MMBaseModem *self,<br class="gmail_msg">
>              mm_unlock_retries_set (ctx->retries,<br class="gmail_msg">
> MM_MODEM_LOCK_SIM_PUK2, unlock_retries);<br class="gmail_msg">
>              break;<br class="gmail_msg">
>          default:<br class="gmail_msg">
> +            g_assert_not_reached ();<br class="gmail_msg">
>              break;<br class="gmail_msg">
>      }<br class="gmail_msg">
><br class="gmail_msg">
> @@ -551,12 +575,40 @@ next_step:<br class="gmail_msg">
>  }<br class="gmail_msg">
><br class="gmail_msg">
>  static void<br class="gmail_msg">
> +csim_lock_ready (MMBaseModem              *self,<br class="gmail_msg">
> +                 GAsyncResult             *res,<br class="gmail_msg">
> +                 LoadUnlockRetriesContext *ctx)<br class="gmail_msg">
> +{<br class="gmail_msg">
> +    const gchar *response;<br class="gmail_msg">
> +    GError      *error = NULL;<br class="gmail_msg">
> +<br class="gmail_msg">
> +    response = mm_base_modem_at_command_finish (self, res, &error);<br class="gmail_msg">
> +    if (!response) {<br class="gmail_msg">
> +        g_prefix_error (&error, "Couldn't lock SIM card: ");<br class="gmail_msg">
> +        g_simple_async_result_take_error (ctx->result, error);<br class="gmail_msg">
> +        load_unlock_retries_context_complete_and_free (ctx);<br class="gmail_msg">
> +        return;<br class="gmail_msg">
> +    }<br class="gmail_msg">
> +<br class="gmail_msg">
> +    ctx->step++;<br class="gmail_msg">
> +    load_unlock_retries_step (ctx);<br class="gmail_msg">
> +}<br class="gmail_msg">
> +<br class="gmail_msg">
> +static void<br class="gmail_msg">
>  load_unlock_retries_step (LoadUnlockRetriesContext *ctx)<br class="gmail_msg">
>  {<br class="gmail_msg">
>      switch (ctx->step) {<br class="gmail_msg">
>          case LOAD_UNLOCK_RETRIES_STEP_FIRST:<br class="gmail_msg">
>              /* Fall back on next step */<br class="gmail_msg">
>              ctx->step++;<br class="gmail_msg">
> +        case LOAD_UNLOCK_RETRIES_STEP_LOCK:<br class="gmail_msg">
> +            mm_base_modem_at_command (MM_BASE_MODEM (ctx->self),<br class="gmail_msg">
> +                                      CSIM_LOCK_STR,<br class="gmail_msg">
> +                                      CSIM_QUERY_TIMEOUT,<br class="gmail_msg">
> +                                      FALSE,<br class="gmail_msg">
> +                                      (GAsyncReadyCallback)<br class="gmail_msg">
> csim_lock_ready,<br class="gmail_msg">
> +                                      ctx);<br class="gmail_msg">
> +            break;<br class="gmail_msg">
>          case LOAD_UNLOCK_RETRIES_STEP_PIN:<br class="gmail_msg">
>              mm_base_modem_at_command (MM_BASE_MODEM (ctx->self),<br class="gmail_msg">
>                                        CSIM_QUERY_PIN_RETRIES_STR,<br class="gmail_msg">
> @@ -589,6 +641,14 @@ load_unlock_retries_step<br class="gmail_msg">
> (LoadUnlockRetriesContext *ctx)<br class="gmail_msg">
>                                        (GAsyncReadyCallback)<br class="gmail_msg">
> csim_query_ready,<br class="gmail_msg">
>                                        ctx);<br class="gmail_msg">
>              break;<br class="gmail_msg">
> +        case LOAD_UNLOCK_RETRIES_STEP_UNLOCK:<br class="gmail_msg">
> +            mm_base_modem_at_command (MM_BASE_MODEM (ctx->self),<br class="gmail_msg">
> +                                      CSIM_UNLOCK_STR,<br class="gmail_msg">
> +                                      CSIM_QUERY_TIMEOUT,<br class="gmail_msg">
> +                                      FALSE,<br class="gmail_msg">
> +                                      (GAsyncReadyCallback)<br class="gmail_msg">
> csim_unlock_ready,<br class="gmail_msg">
> +                                      ctx);<br class="gmail_msg">
> +            break;<br class="gmail_msg">
>          case LOAD_UNLOCK_RETRIES_STEP_LAST:<br class="gmail_msg">
>              if (ctx->succeded_requests == 0) {<br class="gmail_msg">
>                  g_simple_async_result_set_error (ctx->result,<br class="gmail_msg">
> --<br class="gmail_msg">
> 2.12.0<br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> ModemManager-devel mailing list<br class="gmail_msg">
> <a href="mailto:ModemManager-devel@lists.freedesktop.org" class="gmail_msg" target="_blank">ModemManager-devel@lists.freedesktop.org</a><br class="gmail_msg">
> <a href="https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel</a><br class="gmail_msg">
</blockquote></div>