aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/telit/mm-modem-helpers-telit.c28
-rw-r--r--plugins/telit/mm-modem-helpers-telit.h11
-rw-r--r--plugins/telit/mm-shared-telit.c45
3 files changed, 78 insertions, 6 deletions
diff --git a/plugins/telit/mm-modem-helpers-telit.c b/plugins/telit/mm-modem-helpers-telit.c
index 86d80cbf..c08fbd7c 100644
--- a/plugins/telit/mm-modem-helpers-telit.c
+++ b/plugins/telit/mm-modem-helpers-telit.c
@@ -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;
+}
diff --git a/plugins/telit/mm-modem-helpers-telit.h b/plugins/telit/mm-modem-helpers-telit.h
index 4bb7fc34..0e41a9a7 100644
--- a/plugins/telit/mm-modem-helpers-telit.h
+++ b/plugins/telit/mm-modem-helpers-telit.h
@@ -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 */
diff --git a/plugins/telit/mm-shared-telit.c b/plugins/telit/mm-shared-telit.c
index 9654b67e..d5032142 100644
--- a/plugins/telit/mm-shared-telit.c
+++ b/plugins/telit/mm-shared-telit.c
@@ -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)
{
+ return g_task_propagate_pointer (G_TASK (res), error);
+}
+
+static void
+load_revision_ready (MMBaseModem *self,
+ GAsyncResult *res,
+ GTask *task)
+{
+ GError *error;
GVariant *result;
- gchar *revision = NULL;
- result = mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, NULL, error);
- if (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);
}
/*****************************************************************************/