[PATCH] telit: implement the network time interface for Telit modems
Jason Simmons
jsimmons at chromium.org
Wed Mar 11 16:11:50 PDT 2015
This is a new revision of the patch incorporating your feedback.
Add support for querying the real-time clock to the Telit plugin.
Tested with a Telit HE910 modem.
---
.gitignore | 1 +
plugins/Makefile.am | 15 +++
plugins/telit/mm-broadband-modem-telit.c | 101 +++++++++++++++++++-
plugins/telit/mm-modem-helpers-telit.c | 97 +++++++++++++++++++
plugins/telit/mm-modem-helpers-telit.h | 29 ++++++
plugins/telit/tests/test-modem-helpers-telit.c | 126
+++++++++++++++++++++++++
6 files changed, 368 insertions(+), 1 deletion(-)
create mode 100644 plugins/telit/mm-modem-helpers-telit.c
create mode 100644 plugins/telit/mm-modem-helpers-telit.h
create mode 100644 plugins/telit/tests/test-modem-helpers-telit.c
diff --git a/.gitignore b/.gitignore
index 08366fd..3c020e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -160,6 +160,7 @@ Makefile.in
/plugins/test-modem-helpers-cinterion*
/plugins/test-modem-helpers-icera*
/plugins/test-modem-helpers-mbm*
+/plugins/test-modem-helpers-telit*
/plugins/test-service-*
/test/lsudev
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 1e30b1a..7759e7f 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -540,12 +540,27 @@ libmm_plugin_via_la_LDFLAGS =
$(PLUGIN_COMMON_LINKER_FLAGS)
libmm_plugin_telit_la_SOURCES = \
telit/mm-plugin-telit.c \
telit/mm-plugin-telit.h \
+ telit/mm-modem-helpers-telit.c \
+ telit/mm-modem-helpers-telit.h \
telit/mm-broadband-modem-telit.c \
telit/mm-broadband-modem-telit.h
libmm_plugin_telit_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
libmm_plugin_telit_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
udevrules_DATA += telit/77-mm-telit-port-types.rules
+noinst_PROGRAMS += test-modem-helpers-telit
+test_modem_helpers_telit_SOURCES = \
+ telit/mm-modem-helpers-telit.c \
+ telit/mm-modem-helpers-telit.h \
+ telit/tests/test-modem-helpers-telit.c
+test_modem_helpers_telit_CPPFLAGS = \
+ -I$(top_srcdir)/plugins/telit \
+ $(PLUGIN_COMMON_COMPILER_FLAGS)
+test_modem_helpers_telit_LDADD = \
+ $(top_builddir)/libmm-glib/libmm-glib.la \
+ $(top_builddir)/src/libmodem-helpers.la
+test_modem_helpers_telit_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
+
# MTK
libmm_plugin_mtk_la_SOURCES = \
mtk/mm-plugin-mtk.c \
diff --git a/plugins/telit/mm-broadband-modem-telit.c
b/plugins/telit/mm-broadband-modem-telit.c
index 5e1dbff..f102549 100644
--- a/plugins/telit/mm-broadband-modem-telit.c
+++ b/plugins/telit/mm-broadband-modem-telit.c
@@ -27,14 +27,18 @@
#include "mm-log.h"
#include "mm-errors-types.h"
#include "mm-modem-helpers.h"
+#include "mm-modem-helpers-telit.h"
#include "mm-base-modem-at.h"
#include "mm-iface-modem.h"
+#include "mm-iface-modem-time.h"
#include "mm-broadband-modem-telit.h"
static void iface_modem_init (MMIfaceModem *iface);
+static void iface_modem_time_init (MMIfaceModemTime *iface);
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemTelit, mm_broadband_modem_telit,
MM_TYPE_BROADBAND_MODEM, 0,
- G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM,
iface_modem_init));
+ G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM,
iface_modem_init)
+ G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME,
iface_modem_time_init));
/*****************************************************************************/
/* Load access technologies (Modem interface) */
@@ -175,6 +179,90 @@ load_access_technologies (MMIfaceModem *self,
}
/*****************************************************************************/
+/* Load network time (Time interface) */
+
+static gchar *
+modem_time_load_network_time_finish (MMIfaceModemTime *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ const gchar *response;
+ gchar *result = NULL;
+
+ response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res,
error);
+ if (response)
+ mm_telit_parse_cclk_response (response, &result, NULL, error);
+ return result;
+}
+
+static void
+modem_time_load_network_time (MMIfaceModemTime *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ mm_base_modem_at_command (MM_BASE_MODEM (self),
+ "+CCLK?",
+ 3,
+ FALSE,
+ callback,
+ user_data);
+}
+
+/*****************************************************************************/
+/* Load network timezone (Time interface) */
+
+static MMNetworkTimezone *
+modem_time_load_network_timezone_finish (MMIfaceModemTime *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ const gchar *response;
+ MMNetworkTimezone *tz = NULL;
+
+ response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res,
NULL);
+ if (response)
+ mm_telit_parse_cclk_response (response, NULL, &tz, error);
+ return tz;
+}
+
+static void
+modem_time_load_network_timezone (MMIfaceModemTime *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ mm_base_modem_at_command (MM_BASE_MODEM (self),
+ "+CCLK?",
+ 3,
+ FALSE,
+ callback,
+ user_data);
+}
+
+/*****************************************************************************/
+/* Check support (Time interface) */
+
+static gboolean
+modem_time_check_support_finish (MMIfaceModemTime *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return !!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res,
error);
+}
+
+static void
+modem_time_check_support (MMIfaceModemTime *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ mm_base_modem_at_command (MM_BASE_MODEM (self),
+ "+CCLK?",
+ 3,
+ TRUE,
+ callback,
+ user_data);
+}
+
+/*****************************************************************************/
MMBroadbandModemTelit *
mm_broadband_modem_telit_new (const gchar *device,
@@ -205,6 +293,17 @@ iface_modem_init (MMIfaceModem *iface)
}
static void
+iface_modem_time_init (MMIfaceModemTime *iface)
+{
+ iface->check_support = modem_time_check_support;
+ iface->check_support_finish = modem_time_check_support_finish;
+ iface->load_network_time = modem_time_load_network_time;
+ iface->load_network_time_finish = modem_time_load_network_time_finish;
+ iface->load_network_timezone = modem_time_load_network_timezone;
+ iface->load_network_timezone_finish =
modem_time_load_network_timezone_finish;
+}
+
+static void
mm_broadband_modem_telit_class_init (MMBroadbandModemTelitClass *klass)
{
}
diff --git a/plugins/telit/mm-modem-helpers-telit.c
b/plugins/telit/mm-modem-helpers-telit.c
new file mode 100644
index 0000000..19f6625
--- /dev/null
+++ b/plugins/telit/mm-modem-helpers-telit.c
@@ -0,0 +1,97 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*/
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2015 Google Inc.
+ *
+ */
+
+#include <ModemManager.h>
+#define _LIBMM_INSIDE_MM
+#include <libmm-glib.h>
+
+#include "mm-modem-helpers.h"
+#include "mm-modem-helpers-telit.h"
+
+/*****************************************************************************/
+/* +CCLK response parser */
+
+gboolean
+mm_telit_parse_cclk_response (const char *response,
+ gchar **iso8601p,
+ MMNetworkTimezone **tzp,
+ GError **error)
+{
+ GRegex *r;
+ GMatchInfo *match_info = NULL;
+ GError *match_error = NULL;
+ guint year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
+ gint tz = 0;
+ gboolean ret = FALSE;
+
+ g_assert (iso8601p || tzp); /* at least one */
+
+ /* Sample reply: +CCLK: "15/03/05,14:14:26-32" */
+ r = g_regex_new ("[+]CCLK:
\"(\\d+)/(\\d+)/(\\d+),(\\d+):(\\d+):(\\d+)([-+]\\d+)\"", 0, 0, NULL);
+ g_assert (r != NULL);
+
+ if (!g_regex_match_full (r, response, -1, 0, 0, &match_info,
&match_error)) {
+ if (match_error) {
+ g_propagate_error (error, match_error);
+ g_prefix_error (error, "Could not parse +CCLK results: ");
+ } else {
+ g_set_error_literal (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't match +CCLK reply");
+ }
+ } else {
+ /* Remember that g_match_info_get_match_count() includes match #0
*/
+ g_assert (g_match_info_get_match_count (match_info) >= 8);
+
+ if (mm_get_uint_from_match_info (match_info, 1, &year) &&
+ mm_get_uint_from_match_info (match_info, 2, &month) &&
+ mm_get_uint_from_match_info (match_info, 3, &day) &&
+ mm_get_uint_from_match_info (match_info, 4, &hour) &&
+ mm_get_uint_from_match_info (match_info, 5, &minute) &&
+ mm_get_uint_from_match_info (match_info, 6, &second) &&
+ mm_get_int_from_match_info (match_info, 7, &tz)) {
+ /* adjust year */
+ year += 2000;
+ /*
+ * tz = timezone offset in 15 minute intervals
+ */
+ if (iso8601p) {
+ /* Return ISO-8601 format date/time string */
+ *iso8601p = mm_new_iso8601_time (year, month, day, hour,
+ minute, second,
+ TRUE, (tz * 15));
+ }
+ if (tzp) {
+ *tzp = mm_network_timezone_new ();
+ mm_network_timezone_set_offset (*tzp, tz * 15);
+ }
+
+ ret = TRUE;
+ } else {
+ g_set_error_literal (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Failed to parse +CCLK reply");
+ }
+ }
+
+ if (match_info)
+ g_match_info_free (match_info);
+ g_regex_unref (r);
+
+ return ret;
+}
diff --git a/plugins/telit/mm-modem-helpers-telit.h
b/plugins/telit/mm-modem-helpers-telit.h
new file mode 100644
index 0000000..7b45242
--- /dev/null
+++ b/plugins/telit/mm-modem-helpers-telit.h
@@ -0,0 +1,29 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*/
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2015 Google Inc.
+ */
+
+#ifndef MM_MODEM_HELPERS_TELIT_H
+#define MM_MODEM_HELPERS_TELIT_H
+
+#include <libmm-glib.h>
+
+/*****************************************************************************/
+/* +CCLK response parser */
+
+gboolean mm_telit_parse_cclk_response (const gchar *response,
+ gchar **iso8601p,
+ MMNetworkTimezone **tzp,
+ GError **error);
+
+#endif /* MM_MODEM_HELPERS_TELIT_H */
diff --git a/plugins/telit/tests/test-modem-helpers-telit.c
b/plugins/telit/tests/test-modem-helpers-telit.c
new file mode 100644
index 0000000..162a1c9
--- /dev/null
+++ b/plugins/telit/tests/test-modem-helpers-telit.c
@@ -0,0 +1,126 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*/
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2015 Google Inc.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <locale.h>
+
+#include "mm-log.h"
+#include "mm-modem-helpers-telit.h"
+
+/*****************************************************************************/
+/* Test +CCLK responses */
+
+typedef struct {
+ const gchar *str;
+ gboolean ret;
+ gboolean test_iso8601;
+ gboolean test_tz;
+ gchar *iso8601;
+ gint32 offset;
+} CclkTest;
+
+static const CclkTest cclk_tests[] = {
+ { "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, TRUE, FALSE,
+ "2014-08-05T04:00:21+10:00", 600 },
+ { "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, FALSE, TRUE,
+ "2014-08-05T04:00:21+10:00", 600 },
+ { "+CCLK: \"14/08/05,04:00:21+40\"", TRUE, TRUE, TRUE,
+ "2014-08-05T04:00:21+10:00", 600 },
+
+ { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, FALSE,
+ "2015-02-28T20:30:40-08:00", -480 },
+ { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, FALSE, TRUE,
+ "2015-02-28T20:30:40-08:00", -480 },
+ { "+CCLK: \"15/02/28,20:30:40-32\"", TRUE, TRUE, TRUE,
+ "2015-02-28T20:30:40-08:00", -480 },
+
+ { "+CCLK: \"XX/XX/XX,XX:XX:XX+XX\"", FALSE, TRUE, FALSE,
+ NULL, MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN },
+
+ { NULL, FALSE, FALSE, FALSE, NULL, MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN }
+};
+
+static void
+test_cclk (void)
+{
+ guint i;
+
+ for (i = 0; cclk_tests[i].str; i++) {
+ GError *error = NULL;
+ gchar *iso8601 = NULL;
+ MMNetworkTimezone *tz = NULL;
+ gboolean ret;
+
+ ret = mm_telit_parse_cclk_response (cclk_tests[i].str,
+ cclk_tests[i].test_iso8601 ?
&iso8601 : NULL,
+ cclk_tests[i].test_tz ? &tz :
NULL,
+ &error);
+
+ g_assert (ret == cclk_tests[i].ret);
+ g_assert (ret == (error ? FALSE : TRUE));
+
+ g_clear_error (&error);
+
+ if (cclk_tests[i].test_iso8601)
+ g_assert_cmpstr (cclk_tests[i].iso8601, ==, iso8601);
+
+ if (cclk_tests[i].test_tz) {
+ g_assert (mm_network_timezone_get_offset (tz) ==
cclk_tests[i].offset);
+ g_assert (mm_network_timezone_get_dst_offset (tz) ==
MM_NETWORK_TIMEZONE_OFFSET_UNKNOWN);
+ g_assert (mm_network_timezone_get_leap_seconds (tz) ==
MM_NETWORK_TIMEZONE_LEAP_SECONDS_UNKNOWN);
+ }
+
+ if (iso8601)
+ g_free (iso8601);
+
+ if (tz)
+ g_object_unref (tz);
+ }
+}
+
+/*****************************************************************************/
+
+void
+_mm_log (const char *loc,
+ const char *func,
+ guint32 level,
+ const char *fmt,
+ ...)
+{
+#if defined ENABLE_TEST_MESSAGE_TRACES
+ /* Dummy log function */
+ va_list args;
+ gchar *msg;
+
+ va_start (args, fmt);
+ msg = g_strdup_vprintf (fmt, args);
+ va_end (args);
+ g_print ("%s\n", msg);
+ g_free (msg);
+#endif
+}
+
+int main (int argc, char **argv)
+{
+ setlocale (LC_ALL, "");
+
+ g_type_init ();
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/MM/telit/cclk", test_cclk);
+
+ return g_test_run ();
+}
--
2.2.0.rc0.207.ga3a616c
On Wed, Mar 11, 2015 at 11:41 AM, Aleksander Morgado <
aleksander at aleksander.es> wrote:
> Hey,
>
> On Wed, Mar 11, 2015 at 6:49 PM, Jason Simmons <jsimmons at chromium.org>
> wrote:
> > Add support for querying the real-time clock to the Telit plugin.
> > Tested with a Telit HE910 modem.
> > ---
> > plugins/telit/mm-broadband-modem-telit.c | 174
> > ++++++++++++++++++++++++++++++-
> > 1 file changed, 173 insertions(+), 1 deletion(-)
> >
> > diff --git a/plugins/telit/mm-broadband-modem-telit.c
> > b/plugins/telit/mm-broadband-modem-telit.c
> > index 5e1dbff..429a735 100644
> > --- a/plugins/telit/mm-broadband-modem-telit.c
> > +++ b/plugins/telit/mm-broadband-modem-telit.c
> > @@ -29,12 +29,15 @@
> > #include "mm-modem-helpers.h"
> > #include "mm-base-modem-at.h"
> > #include "mm-iface-modem.h"
> > +#include "mm-iface-modem-time.h"
> > #include "mm-broadband-modem-telit.h"
> >
> > static void iface_modem_init (MMIfaceModem *iface);
> > +static void iface_modem_time_init (MMIfaceModemTime *iface);
> >
> > G_DEFINE_TYPE_EXTENDED (MMBroadbandModemTelit, mm_broadband_modem_telit,
> > MM_TYPE_BROADBAND_MODEM, 0,
> > - G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM,
> > iface_modem_init));
> > + G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM,
> > iface_modem_init)
> > + G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME,
> > iface_modem_time_init));
> >
> >
> >
> /*****************************************************************************/
> > /* Load access technologies (Modem interface) */
> > @@ -175,6 +178,164 @@ load_access_technologies (MMIfaceModem *self,
> > }
> >
> >
> >
> /*****************************************************************************/
> > +/* Load network time (Time interface) */
> > +
> > +static gboolean
> > +parse_cclk_reply (const char *response,
> > + gchar **iso8601p,
> > + MMNetworkTimezone **tzp,
> > + GError **error)
>
> Could you put this in a mm-modem-helpers-telit.c|h set of files in the
> telit plugin, and add unit tests? You can check e.g. how that is done
> in the Huawei plugin for the ^TIME response parsers.
>
> > +{
> > + GRegex *r;
> > + GMatchInfo *match_info = NULL;
> > + GError *match_error = NULL;
> > + guint year = 0, month = 0, day = 0, hour = 0, minute = 0, second =
> 0;
> > + gint tz = 0;
> > + gboolean ret = FALSE;
> > +
> > + g_assert (iso8601p || tzp); /* at least one */
> > +
> > + /* Sample reply: +CCLK: "15/03/05,14:14:26-32" */
> > + r = g_regex_new ("[+]CCLK:
> > \"(\\d+)/(\\d+)/(\\d+),(\\d+):(\\d+):(\\d+)([-+]\\d+)\"", 0, 0, NULL);
> > + g_assert (r != NULL);
> > +
> > + if (!g_regex_match_full (r, response, -1, 0, 0, &match_info,
> > &match_error)) {
> > + if (match_error) {
> > + g_propagate_error (error, match_error);
> > + g_prefix_error (error, "Could not parse +CCLK results: ");
> > + } else {
> > + g_set_error_literal (error,
> > + MM_CORE_ERROR,
> > + MM_CORE_ERROR_FAILED,
> > + "Couldn't match +CCLK reply");
> > + }
> > + } else {
> > + /* Remember that g_match_info_get_match_count() includes match
> #0
> > */
> > + g_assert (g_match_info_get_match_count (match_info) >= 8);
> > +
> > + if (mm_get_uint_from_match_info (match_info, 1, &year) &&
> > + mm_get_uint_from_match_info (match_info, 2, &month) &&
> > + mm_get_uint_from_match_info (match_info, 3, &day) &&
> > + mm_get_uint_from_match_info (match_info, 4, &hour) &&
> > + mm_get_uint_from_match_info (match_info, 5, &minute) &&
> > + mm_get_uint_from_match_info (match_info, 6, &second) &&
> > + mm_get_int_from_match_info (match_info, 7, &tz)) {
> > + /* adjust year */
> > + year += 2000;
> > + /*
> > + * tz = timezone offset in 15 minute intervals
> > + */
> > + if (iso8601p) {
> > + /* Return ISO-8601 format date/time string */
> > + *iso8601p = mm_new_iso8601_time (year, month, day, hour,
> > + minute, second,
> > + TRUE, (tz * 15));
> > + }
> > + if (tzp) {
> > + *tzp = mm_network_timezone_new ();
> > + mm_network_timezone_set_offset (*tzp, tz * 15);
> > + }
> > +
> > + ret = TRUE;
> > + } else {
> > + g_set_error_literal (error,
> > + MM_CORE_ERROR,
> > + MM_CORE_ERROR_FAILED,
> > + "Failed to parse +CCLK reply");
> > + }
> > + }
> > +
> > + if (match_info)
> > + g_match_info_free (match_info);
> > + g_regex_unref (r);
> > +
> > + return ret;
> > +}
> > +
> > +static gchar *
> > +modem_time_load_network_time_finish (MMIfaceModemTime *self,
> > + GAsyncResult *res,
> > + GError **error)
> > +{
> > + const gchar *response;
> > + gchar *result = NULL;
> > +
> > + response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self),
> res,
> > error);
> > + if (response)
> > + parse_cclk_reply (response, &result, NULL, error);
> > + return result;
> > +}
> > +
> > +static void
> > +modem_time_load_network_time (MMIfaceModemTime *self,
> > + GAsyncReadyCallback callback,
> > + gpointer user_data)
> > +{
> > + mm_base_modem_at_command (MM_BASE_MODEM (self),
> > + "+CCLK?",
> > + 3,
> > + FALSE,
> > + callback,
> > + user_data);
> > +}
> > +
> >
> +/*****************************************************************************/
> > +/* Load network timezone (Time interface) */
> > +
> > +static MMNetworkTimezone *
> > +modem_time_load_network_timezone_finish (MMIfaceModemTime *self,
> > + GAsyncResult *res,
> > + GError **error)
> > +{
> > + const gchar *response;
> > + MMNetworkTimezone *tz = NULL;
> > +
> > + response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self),
> res,
> > NULL);
> > + if (response)
> > + parse_cclk_reply (response, NULL, &tz, error);
> > + return tz;
> > +}
> > +
> > +static void
> > +modem_time_load_network_timezone (MMIfaceModemTime *self,
> > + GAsyncReadyCallback callback,
> > + gpointer user_data)
> > +{
> > + mm_base_modem_at_command (MM_BASE_MODEM (self),
> > + "+CCLK?",
> > + 3,
> > + FALSE,
> > + callback,
> > + user_data);
> > +}
> > +
> >
> +/*****************************************************************************/
> > +/* Check support (Time interface) */
> > +
> > +static gboolean
> > +modem_time_check_support_finish (MMIfaceModemTime *self,
> > + GAsyncResult *res,
> > + GError **error)
> > +{
> > + g_debug("modem_time_check_support_finish");
>
> That previous log message is not useful, please remove it.
>
> > + return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT
> > (res), error);
>
> This is wrong. I see that it's also wrong in the novatel plugin, which
> does basically the same check.
> The correct way to finish() an at_command() operation is to call
> at_command_finish(). So, the proper code should be:
>
> return !!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res,
> error);
>
> This is, return TRUE if mm_base_modem_at_command_finish() returned a
> valid non-error string.
>
> Fixed that for Novatel:
>
> http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=46b2aeae531ea47d3cf3d455305c40694d4f60b7
>
> With this change, we don't assume how
> mm_base_modem_at_command_finish() treats the GAsyncResult.
>
> > +}
> > +
> > +static void
> > +modem_time_check_support (MMIfaceModemTime *self,
> > + GAsyncReadyCallback callback,
> > + gpointer user_data)
> > +{
> > + g_debug("modem_time_check_support");
>
> That previous log message is not useful, please remove it.
>
> > + mm_base_modem_at_command (MM_BASE_MODEM (self),
> > + "+CCLK?",
> > + 3,
> > + TRUE,
> > + callback,
> > + user_data);
> > +}
> > +
> >
> +/*****************************************************************************/
> >
> > MMBroadbandModemTelit *
> > mm_broadband_modem_telit_new (const gchar *device,
> > @@ -205,6 +366,17 @@ iface_modem_init (MMIfaceModem *iface)
> > }
> >
> > static void
> > +iface_modem_time_init (MMIfaceModemTime *iface)
> > +{
> > + iface->check_support = modem_time_check_support;
> > + iface->check_support_finish = modem_time_check_support_finish;
> > + iface->load_network_time = modem_time_load_network_time;
> > + iface->load_network_time_finish =
> modem_time_load_network_time_finish;
> > + iface->load_network_timezone = modem_time_load_network_timezone;
> > + iface->load_network_timezone_finish =
> > modem_time_load_network_timezone_finish;
> > +}
> > +
> > +static void
> > mm_broadband_modem_telit_class_init (MMBroadbandModemTelitClass *klass)
> > {
> > }
> > --
> > 2.2.0.rc0.207.ga3a616c
> >
> >
> > _______________________________________________
> > ModemManager-devel mailing list
> > ModemManager-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
> >
>
>
>
> --
> Aleksander
> https://aleksander.es
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/modemmanager-devel/attachments/20150311/0510f4ca/attachment-0001.html>
More information about the ModemManager-devel
mailing list