telit: fallback to AT commands in case of MBIM loading revision failure

Some firmware versions return an empty string for the revision when
using the device caps MBIM request, so use AT commands as a fallback
in case this happens.
This commit is contained in:
Daniele Palmas
2023-01-30 16:00:45 +01:00
parent a9e841e931
commit 6748fb7c2c
2 changed files with 27 additions and 2 deletions
@@ -141,15 +141,16 @@ load_revision_finish (MMIfaceModem *self,
}
static void
parent_load_revision_ready (MMIfaceModem *self,
load_revision_ready_shared (MMIfaceModem *self,
GAsyncResult *res,
GTask *task)
{
GError *error = NULL;
gchar *revision = NULL;
revision = iface_modem_parent->load_revision_finish (self, res, &error);
revision = mm_shared_telit_modem_load_revision_finish (self, res, &error);
if (!revision) {
/* give up */
g_task_return_error (task, error);
g_object_unref (task);
return;
@@ -159,6 +160,29 @@ parent_load_revision_ready (MMIfaceModem *self,
g_object_unref (task);
}
static void
parent_load_revision_ready (MMIfaceModem *self,
GAsyncResult *res,
GTask *task)
{
gchar *revision = NULL;
revision = iface_modem_parent->load_revision_finish (self, res, NULL);
if (!revision || !strlen (revision)) {
/* Some firmware versions do not properly populate the revision in the
* MBIM response, so try using the AT ports */
g_free (revision);
mm_shared_telit_modem_load_revision (
self,
(GAsyncReadyCallback)load_revision_ready_shared,
task);
return;
}
mm_shared_telit_store_revision (MM_SHARED_TELIT (self), revision);
g_task_return_pointer (task, revision, g_free);
g_object_unref (task);
}
static void
load_revision (MMIfaceModem *self,
GAsyncReadyCallback callback,
@@ -633,6 +633,7 @@ test_telit_parse_swpkgv_response (void)
{"\r\n16.38.571-P0F.224700\r\nM0F.223004-B001\r\nP0F.224700\r\nA0F.223004-B001\r\n\r\nOK\r\n", "16.38.571-P0F.224700"},
/* real example from LE910C1-EUX */
{"\r\n25.30.224-B001-P0F.224700\r\nM0F.223004-B001\r\nP0F.224700\r\nA0F.223004-B001\r\n\r\nOK\r\n", "25.30.224-B001-P0F.224700"},
{"\r\n45.00.010-B022-P0R.001600\r\nM0R.010000-B022\r\nP0R.001600\r\nA0R.000000-B022\r\n\r\nOK\r\n", "45.00.010-B022-P0R.001600"},
};
guint i;