<div dir="ltr">> What would happen if you completely disable and enable the handlers
> with the method I'm suggesting, and then you just let the #QSS=1
> indication happen? If the modem already had a SIM inserted, an extra
> #QSS=1 wouldn't harm, right? Won't it be just ignored when it's<br>> processed?<br><br>You're right, we don't need to process #QSS=1, but we absolutely need to wait for it before sending any other SIM command.<br><br>Since #QSS=1 arrives in a couple of seconds, even a sleep will do, but if anything goes wrong we will get stuck in the next command (not sure if it is a bug, but it looks like it to me).

<br><br>In the meantime I tried the my proposal and I'm not really sure about how to wait for the unsolicited. I cannot let the thread go on, otherwise we call +CRSM and get stuck, but if I put a simple sleep, we do not process any unsolicited...</div><br><div class="gmail_quote"><div dir="ltr">On Mon, 24 Jul 2017 at 10:59 Aleksander Morgado <<a href="mailto:aleksander@aleksander.es">aleksander@aleksander.es</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey,<br>
<br>
><br>
>> I just reproduced the issue on my hardware, so I can develop a patch for<br>
>> this<br>
><br>
><br>
><br>
> after some analysis, I think that the fix for this issue should count two<br>
> steps<br>
><br>
> 1. When +CSIM=1 is sent, the QSS handler should ignore QSS unsolicited -> I<br>
> brefly solved this with a "is_csim_locked" boolean in MMBroadbandModemTelit<br>
> priv, set by csim_lock_ready and read by the handler.<br>
><br>
> 2. As well as +CSIM=1 causes a #QSS=0, even +CSIM=0 causes a #QSS=1, but<br>
> this time we need to wait for this unsolicited to come before accepting any<br>
> other call to the SIM. Considering that the very next call is +CSRM, we need<br>
> to stop soon after unlocking SIM interface.<br>
><br>
> I think I can do this in csim_unlock_ready, waiting 'till the QSS handler<br>
> receives #QSS=1 (and up to some maximum amount of time, like 3-5 seconds,<br>
> just to be sure), but since this will stop the entire process I preferred to<br>
> share this idea with you before working on it.<br>
><br>
> what do you think?<br>
<br>
I was going to suggest you use<br>
mm_port_serial_at_enable_unsolicited_msg_handler() as that allows you<br>
to temporarily disable/enable an already configured unsolicited<br>
message handler, but in this case you do want to use the handler as<br>
you're expecting the #QSS=1 after +CSIM=0...<br>
<br>
What would happen if you completely disable and enable the handlers<br>
with the method I'm suggesting, and then you just let the #QSS=1<br>
indication happen? If the modem already had a SIM inserted, an extra<br>
#QSS=1 wouldn't harm, right? Won't it be just ignored when it's<br>
processed?<br>
<br>
--<br>
Aleksander<br>
<a href="https://aleksander.es" rel="noreferrer" target="_blank">https://aleksander.es</a><br>
</blockquote></div>