<div dir="ltr"><div dir="ltr" class="gmail_msg"><div dir="ltr" class="gmail_msg">Hi all,<br><br>Sorry for the late reply, but I was double checking this change because of the last paragraph in +CSIM reference:<br><br>> After the locking of the SIM-ME interface (AT+CSIM=1) the SIM will be<br>> accessible only by AT+CSIM commands (#QSS: 0). The GSM and GPRS services<br>> will be automatically de-registered to avoid the TE commands alter the GSM<br>> application. They will be automatically reconditioned after the unlocking of the<br>> SIM-ME interface. After the unlocking of the SIM-ME interface if PIN is required<br>> it will be necessary to enter it another time.<br><br>But this does not seems to affect the behaviour of the modem, which still works fine.<br>In my environment I can't reproduce the issue this patch fixes (tty locked), but I do not see any side effect, so for me it's ok.<br><br><br>But, while this patch does not cause regression, I did observe a problem testing this use case: when SIM is locked and then unlocked, with SIM hot swap enabled, we receive an unsolicited "#QSS: 1", which is not related to any physical SIM insertion, and release the modem:<br><br><br>mar 16 09:55:00 d2092 ModemManager[542]: <debug> (ttyACM0): --> 'AT+CSQ<CR>'<br>mar 16 09:55:00 d2092 ModemManager[542]: <debug> (ttyACM0): <-- '<CR><LF>'<br>mar 16 09:55:00 d2092 ModemManager[542]: <debug> (ttyACM0): <-- '+CSQ: 9,4<CR><LF><CR><LF>OK<CR><LF>'<br>mar 16 09:55:00 d2092 ModemManager[542]: <debug> (ttyACM0) device open count is 3 (close)<br>mar 16 09:55:00 d2092 ModemManager[542]: <debug> Modem /org/freedesktop/ModemManager1/Modem/0: signal quality updated (29)<br>mar 16 09:55:00 d2092 ModemManager[542]: <debug> Periodic signal quality checks rescheduled (interval = 30s)<br>mar 16 09:55:02 d2092 ModemManager[542]: <debug> (ttyACM3): <-- '<CR><LF>+CIEV: service,1<CR><LF>'<br>mar 16 09:55:02 d2092 ModemManager[542]: <debug> (ttyACM3): <-- '<CR><LF>+CIEV: roam,0<CR><LF>'<br>mar 16 09:55:05 d2092 ModemManager[542]: <debug> (ttyACM0) device open count is 4 (open)<br>mar 16 09:55:05 d2092 ModemManager[542]: <debug> (ttyACM0): --> 'AT+CCLK?<CR>'<br>mar 16 09:55:05 d2092 ModemManager[542]: <debug> (ttyACM0): <-- '<CR><LF>'<br>mar 16 09:55:05 d2092 ModemManager[542]: <debug> (ttyACM0): <-- '+CCLK: "17/03/16,09:55:05+04"<CR><LF><CR><LF>OK<CR><LF>'<br>mar 16 09:55:05 d2092 ModemManager[542]: <debug> (ttyACM0) device open count is 3 (close)<br>mar 16 09:55:09 d2092 ModemManager[542]: <debug> (ttyACM3): <-- '<CR><LF>#QSS: 1<CR><LF>'<br>mar 16 09:55:09 d2092 ModemManager[542]: <info> QSS: SIM inserted<br>mar 16 09:55:09 d2092 ModemManager[542]: <debug> Releasing SIM hot swap ports context<br><br>This happens with master ModemManger too.<br><br>I'm working on this now, probably a solution would be to borrow Aleksander patch about #QSS: 3, in order to keep an internal state of the SIM presence and just ignore #QSS: 1 when we already know that SIM is inserted.<br class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"></div><br class="gmail_msg"></div></div><div dir="ltr" class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Wed, 15 Mar 2017 at 23:49 Aleksander Morgado <<a href="mailto:aleksander@aleksander.es" class="gmail_msg" target="_blank">aleksander@aleksander.es</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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 Dan & everyone,<br class="gmail_msg">
<br class="gmail_msg">
This v2 just adds a NOTE at the beginning of the section specifying that the UNLOCK step must always be run if LOCK is run.<br class="gmail_msg">
<br class="gmail_msg">
---<br class="gmail_msg">
plugins/telit/mm-broadband-modem-telit.c | 69 +++++++++++++++++++++++++++++++-<br class="gmail_msg">
1 file changed, 68 insertions(+), 1 deletion(-)<br class="gmail_msg">
<br class="gmail_msg">
diff --git a/plugins/telit/mm-broadband-modem-telit.c b/plugins/telit/mm-broadband-modem-telit.c<br class="gmail_msg">
index b1679ae4..6ef340f1 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">
@@ -450,8 +450,17 @@ modem_load_supported_bands (MMIfaceModem *self,<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
/*****************************************************************************/<br class="gmail_msg">
-/* Load unlock retries (Modem interface) */<br class="gmail_msg">
+/* Load unlock retries (Modem interface)<br class="gmail_msg">
+ *<br class="gmail_msg">
+ * NOTE: the logic must make sure that LOAD_UNLOCK_RETRIES_STEP_UNLOCK is always<br class="gmail_msg">
+ * run if LOAD_UNLOCK_RETRIES_STEP_LOCK has been run. Currently, the logic just<br class="gmail_msg">
+ * runs all intermediate steps ignoring errors (i.e. not completing the<br class="gmail_msg">
+ * operation if something fails), so the LOAD_UNLOCK_RETRIES_STEP_UNLOCK is<br class="gmail_msg">
+ * always run.<br class="gmail_msg">
+ */<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 +469,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 +511,25 @@ modem_load_unlock_retries_finish (MMIfaceModem *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 +572,7 @@ csim_query_ready (MMBaseModem *self,<br class="gmail_msg">
mm_unlock_retries_set (ctx->retries, 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 +582,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) 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 +648,14 @@ load_unlock_retries_step (LoadUnlockRetriesContext *ctx)<br class="gmail_msg">
(GAsyncReadyCallback) 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) 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">
</blockquote></div></div></div>