Hi Denis and Sergey,

On 17/08/2020 21.54, Denis Kenzior wrote:
diff --git a/plugins/gemalto.c b/plugins/gemalto.c
index 238c7cc4..321c8c1b 100644
--- a/plugins/gemalto.c
+++ b/plugins/gemalto.c
@@ -222,6 +222,8 @@ static void sim_state_cb(gboolean present, gpointer user_data)
      struct ofono_modem *modem = user_data;
      struct gemalto_data *data = ofono_modem_get_data(modem);
+    DBG("");
+
      at_util_sim_state_query_free(data->sim_state_query);
      data->sim_state_query = NULL;
@@ -241,6 +243,8 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
      struct ofono_modem *modem = user_data;
      struct gemalto_data *data = ofono_modem_get_data(modem);
+    DBG("");
+
      if (!ok) {
          g_at_chat_unref(data->app);
          data->app = NULL;
@@ -451,6 +455,8 @@ static void gemalto_modem_ready(GAtResult *result, gpointer user_data)
      data->modem_ready_id = 0;
      data->trial_cmd_id = 0;
+    g_at_chat_cancel_all(data->app);
+    g_at_chat_unregister_all(data->app);

These get called automatically on unref below, assuming  this is the last (it should be) reference.

      g_at_chat_unref(data->app);

Instead of this dance of opening / closing the chat in order to force-cancel the 'AT' command queued in gemalto_enable(), maybe there should be something in GAtChat itself to handle this case.  Either a 'force cancel the top of the queue because I know the modem is broken' or maybe some form of 'send this on the port until it responds properly'.  Alternatively, you could simply use GAtIO and a timer to write stuff to the port until it responds and only create the chat at that time.

There's already something a bit similar in the form of g_at_chat_set_wakeup_command().  It was used on the old Neo Freerunner modem which would go to 'sleep' after several seconds of inactivity.  So the subsequent AT command would get eaten.  You basically had to poke it with an empty command, have it timeout / return OK and then you could go on with submitting AT commands again.  But I don't think it is a good fit for this particular case.

There's also the retry logic used on quectel modems with auto-detection of baud rates:
https://git.kernel.org/pub/scm/network/ofono/ofono.git/tree/plugins/quectel.c#n1082

// Martin
_______________________________________________
ofono mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to