<div dir="ltr">> <span style="color:rgb(33,33,33)">So why is current_sms_mem1_storage UNKNOWN? At which point did it</span><br class="gmail_msg" style="color:rgb(33,33,33)"><span style="color:rgb(33,33,33)">> fail, if it did? Did it fail doing AT+CPMS?</span><div><span style="color:rgb(33,33,33)"><br></span></div><div><span style="color:rgb(33,33,33)">Correct. AT+CPMS? returns with SIM Busy. It's something that will be better addressed when "delay till #QSS: 3" will be implemented.<br><br>> </span><span style="color:rgb(33,33,33)">I agree that we shouldn't call any CPMS command passing "unknown" as</span></div><span style="color:rgb(33,33,33)">> storage, but defaulting to "SM" isn't a good approach either. [...]</span><div><font color="#212121">> </font><span style="color:rgb(33,33,33)">If it is UNKNOWN because init_current_storages() failed, we should</span><br class="gmail_msg" style="color:rgb(33,33,33)"><span style="color:rgb(33,33,33)">> also error out when trying to set_default_storage()</span><font color="#212121"><br></font><div><span style="color:rgb(33,33,33)"><br></span></div><div><span style="color:rgb(33,33,33)">I understand that. So, set_default_storage should return error directly when it finds that mem1 is UNKNOWN. Is that right?</span></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, 23 Mar 2017 at 17:16 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">On Thu, Mar 23, 2017 at 2:29 PM, Carlo Lobrano <<a href="mailto:c.lobrano@gmail.com" class="gmail_msg" target="_blank">c.lobrano@gmail.com</a>> wrote:<br class="gmail_msg">
> Let mem1_str defaulting to NULL when current_sms_mem1_storage is<br class="gmail_msg">
> MM_SMS_STORAGE_UNKNOWN<br class="gmail_msg">
><br class="gmail_msg">
> modem_messaging_set_default_storage considers mem1 storage<br class="gmail_msg">
> string valid if *not NULL*, but, previously, when we could not get<br class="gmail_msg">
> current_sms_mem1_storage value right, mem1_str defaulted to "unknown"<br class="gmail_msg">
> and that string was used in +CPMS command, resulting in an ERROR.<br class="gmail_msg">
><br class="gmail_msg">
<br class="gmail_msg">
The current_sms_mem1_storage shouldn't be UNKNOWN unless:<br class="gmail_msg">
  * init_current_storages() hasn't been run yet<br class="gmail_msg">
  * init_current_storages () failed.<br class="gmail_msg">
<br class="gmail_msg">
So why is current_sms_mem1_storage UNKNOWN? At which point did it<br class="gmail_msg">
fail, if it did? Did it fail doing AT+CPMS? in<br class="gmail_msg">
modem_messaging_init_current_storages()? Or is it that<br class="gmail_msg">
set_default_storage() was called before init_current_storages() was<br class="gmail_msg">
executed?<br class="gmail_msg">
<br class="gmail_msg">
I agree that we shouldn't call any CPMS command passing "unknown" as<br class="gmail_msg">
storage, but defaulting to "SM" isn't a good approach either. We<br class="gmail_msg">
actually test which are the supported storages at some point<br class="gmail_msg">
(modem_messaging_load_supported_storages()) to avoid assuming any of<br class="gmail_msg">
them is always available.<br class="gmail_msg">
<br class="gmail_msg">
If it is UNKNOWN because init_current_storages() failed, we should<br class="gmail_msg">
also error out when trying to set_default_storage()<br class="gmail_msg">
<br class="gmail_msg">
> ---<br class="gmail_msg">
>  src/mm-broadband-modem.c | 9 ++++++---<br class="gmail_msg">
>  1 file changed, 6 insertions(+), 3 deletions(-)<br class="gmail_msg">
><br class="gmail_msg">
> diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c<br class="gmail_msg">
> index 17b3253..776e6d1 100644<br class="gmail_msg">
> --- a/src/mm-broadband-modem.c<br class="gmail_msg">
> +++ b/src/mm-broadband-modem.c<br class="gmail_msg">
> @@ -5587,7 +5587,7 @@ modem_messaging_set_default_storage (MMIfaceModemMessaging *_self,<br class="gmail_msg">
>      MMBroadbandModem *self = MM_BROADBAND_MODEM (_self);<br class="gmail_msg">
>      gchar *cmd;<br class="gmail_msg">
>      GSimpleAsyncResult *result;<br class="gmail_msg">
> -    gchar *mem1_str;<br class="gmail_msg">
> +    gchar *mem1_str = NULL;<br class="gmail_msg">
>      gchar *mem_str;<br class="gmail_msg">
><br class="gmail_msg">
>      result = g_simple_async_result_new (G_OBJECT (self),<br class="gmail_msg">
> @@ -5599,11 +5599,14 @@ modem_messaging_set_default_storage (MMIfaceModemMessaging *_self,<br class="gmail_msg">
>      self->priv->current_sms_mem2_storage = storage;<br class="gmail_msg">
><br class="gmail_msg">
>      /* We provide the current sms storage for mem1 if not UNKNOWN */<br class="gmail_msg">
> -    mem1_str = g_ascii_strup (mm_sms_storage_get_string (self->priv->current_sms_mem1_storage), -1);<br class="gmail_msg">
> +    if (self->priv->current_sms_mem1_storage != MM_SMS_STORAGE_UNKNOWN) {<br class="gmail_msg">
> +        mem1_str = g_ascii_strup (mm_sms_storage_get_string (self->priv->current_sms_mem1_storage), -1);<br class="gmail_msg">
> +    }<br class="gmail_msg">
><br class="gmail_msg">
>      mem_str = g_ascii_strup (mm_sms_storage_get_string (storage), -1);<br class="gmail_msg">
>      cmd = g_strdup_printf ("+CPMS=\"%s\",\"%s\",\"%s\"",<br class="gmail_msg">
> -                           mem1_str ? mem1_str : "",<br class="gmail_msg">
> +                           /* Empty value is not accepted and SM is the default one */<br class="gmail_msg">
> +                           mem1_str ? mem1_str : "SM",<br class="gmail_msg">
>                             mem_str,<br class="gmail_msg">
>                             mem_str);<br class="gmail_msg">
>      mm_base_modem_at_command (MM_BASE_MODEM (self),<br class="gmail_msg">
> --<br class="gmail_msg">
> 2.9.3<br class="gmail_msg">
><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">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
--<br class="gmail_msg">
Aleksander<br class="gmail_msg">
<a href="https://aleksander.es" rel="noreferrer" class="gmail_msg" target="_blank">https://aleksander.es</a><br class="gmail_msg">
</blockquote></div>