telit: detect modem model from revision

Telit revision string can be used to identify the specific model, which
in turn is useful to specialize the behavior of the plugin.

This change adds revision parsing to detect some telit modems. Initially
it adds the ones that have different behaviors in #BND output parsing
for example.
This commit is contained in:
Carlo Lobrano
2022-03-29 14:18:55 +00:00
committed by Aleksander Morgado
parent 3df96a4255
commit 30a35e6dc3
3 changed files with 79 additions and 7 deletions
+28
View File
@@ -903,3 +903,31 @@ mm_telit_parse_swpkgv_response (const gchar *response)
return version;
}
/*****************************************************************************/
/* MM Telit Model from revision string */
MMTelitModel
mm_telit_model_from_revision (const gchar *revision)
{
guint i;
static const struct {
const gchar *revision_prefix;
MMTelitModel model;
} revision_to_model_map [] = {
{"24.01", MM_TELIT_MODEL_LM940},
{"25.", MM_TELIT_MODEL_LE910C1},
{"32.", MM_TELIT_MODEL_LM960},
{"38.", MM_TELIT_MODEL_FN980},
{"40.", MM_TELIT_MODEL_LN920}
};
g_assert (revision);
for (i = 0; i < G_N_ELEMENTS (revision_to_model_map); ++i) {
if (g_str_has_prefix (revision, revision_to_model_map[i].revision_prefix))
return revision_to_model_map[i].model;
}
return MM_TELIT_MODEL_DEFAULT;
}
+11
View File
@@ -19,6 +19,15 @@
#include <glib.h>
#include "ModemManager.h"
typedef enum {
MM_TELIT_MODEL_DEFAULT,
MM_TELIT_MODEL_FN980,
MM_TELIT_MODEL_LE910C1,
MM_TELIT_MODEL_LM940,
MM_TELIT_MODEL_LM960,
MM_TELIT_MODEL_LN920,
} MMTelitModel;
/* #BND response parsers and request builder */
GArray *mm_telit_parse_bnd_query_response (const gchar *response,
gboolean modem_is_2g,
@@ -67,4 +76,6 @@ GArray *mm_telit_build_modes_list (void);
gchar *mm_telit_parse_swpkgv_response (const gchar *response);
MMTelitModel mm_telit_model_from_revision (const gchar *revision);
#endif /* MM_MODEM_HELPERS_TELIT_H */
+40 -7
View File
@@ -43,6 +43,7 @@ typedef struct {
gboolean ext_4g_bands;
GArray *supported_bands;
GArray *supported_modes;
gchar *software_package_version;
} Private;
static void
@@ -52,6 +53,7 @@ private_free (Private *priv)
g_array_unref (priv->supported_bands);
if (priv->supported_modes)
g_array_unref (priv->supported_modes);
g_free (priv->software_package_version);
g_slice_free (Private, priv);
}
@@ -623,14 +625,31 @@ mm_shared_telit_modem_load_revision_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
GVariant *result;
gchar *revision = NULL;
return g_task_propagate_pointer (G_TASK (res), error);
}
result = mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, NULL, error);
if (result) {
static void
load_revision_ready (MMBaseModem *self,
GAsyncResult *res,
GTask *task)
{
GError *error;
GVariant *result;
result = mm_base_modem_at_sequence_finish (self, res, NULL, &error);
if (!result) {
g_task_return_error (task, error);
g_object_unref (task);
} else {
gchar *revision = NULL;
Private *priv;
priv = get_private (MM_SHARED_TELIT (self));
revision = g_variant_dup_string (result, NULL);
priv->software_package_version = g_strdup (revision);
g_task_return_pointer (task, revision, g_free);
g_object_unref (task);
}
return revision;
}
/*
@@ -689,14 +708,28 @@ mm_shared_telit_modem_load_revision (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GTask *task;
Private *priv;
task = g_task_new (self, NULL, callback, user_data);
priv = get_private (MM_SHARED_TELIT (self));
mm_obj_dbg (self, "loading revision...");
if (priv->software_package_version) {
g_task_return_pointer (task,
g_strdup (priv->software_package_version),
g_free);
g_object_unref (task);
return;
}
mm_base_modem_at_sequence (
MM_BASE_MODEM (self),
revisions,
NULL, /* response_processor_context */
NULL, /* response_processor_context_free */
callback,
user_data);
(GAsyncReadyCallback) load_revision_ready,
task);
}
/*****************************************************************************/