aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-12-01 20:20:26 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:14:31 +0100
commitc345f5fe6361f7659c93c31502fbcbced32c99a9 (patch)
tree4b5a69194ff53f0e866ae6f0f44f62ee9a55bd52
parent0c64e08f853ad01cd4e459c4f57e9d8469b20286 (diff)
cinterion: re-enabled Cinterion plugin
Just dummy plugin for now.
-rw-r--r--plugins/Makefile.am36
-rw-r--r--plugins/mm-broadband-modem-cinterion.c83
-rw-r--r--plugins/mm-broadband-modem-cinterion.h51
-rw-r--r--plugins/mm-plugin-cinterion.c218
-rw-r--r--plugins/mm-plugin-cinterion.h1
5 files changed, 206 insertions, 183 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 63215e43..f0d7a460 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -32,7 +32,8 @@ PLUGIN_COMMON_LINKER_FLAGS = \
########################################
pkglib_LTLIBRARIES = \
- libmm-plugin-generic.la
+ libmm-plugin-generic.la \
+ libmm-plugin-cinterion.la
#pkglib_LTLIBRARIES = \
# libmm-plugin-generic.la \
@@ -53,8 +54,7 @@ pkglib_LTLIBRARIES = \
# libmm-plugin-linktop.la \
# libmm-plugin-samsung.la \
# libmm-plugin-wavecom.la \
-# libmm-plugin-iridium.la \
-# libmm-plugin-cinterion.la
+# libmm-plugin-iridium.la
# Generic
libmm_plugin_generic_la_SOURCES = \
@@ -230,25 +230,25 @@ libmm_plugin_generic_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
#libmm_plugin_samsung_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
#libmm_plugin_samsung_la_LIBADD = $(builddir)/libicera-utils.la
#
-## Cinterion (previously Siemens) modem
-#libmm_plugin_cinterion_la_SOURCES = \
-# mm-plugin-cinterion.c \
-# mm-plugin-cinterion.h \
-# mm-modem-cinterion-gsm.c \
-# mm-modem-cinterion-gsm.h
-#libmm_plugin_cinterion_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
-#libmm_plugin_cinterion_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
-#
+
+# Cinterion (previously Siemens) modem
+libmm_plugin_cinterion_la_SOURCES = \
+ mm-plugin-cinterion.c \
+ mm-plugin-cinterion.h \
+ mm-broadband-modem-cinterion.c \
+ mm-broadband-modem-cinterion.h
+libmm_plugin_cinterion_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
+libmm_plugin_cinterion_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
+
## Iridium satellite modem
#libmm_plugin_iridium_la_SOURCES = \
-# mm-plugin-iridium.c \
-# mm-plugin-iridium.h \
-# mm-modem-iridium-gsm.c \
-# mm-modem-iridium-gsm.h
+# mm-plugin-iridium.c \
+# mm-plugin-iridium.h \
+# mm-modem-iridium-gsm.c \
+# mm-modem-iridium-gsm.h
#libmm_plugin_iridium_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS)
#libmm_plugin_iridium_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS)
-#
-#
+
#
#udevrulesdir = $(UDEV_BASE_DIR)/rules.d
#udevrules_DATA = \
diff --git a/plugins/mm-broadband-modem-cinterion.c b/plugins/mm-broadband-modem-cinterion.c
new file mode 100644
index 00000000..1c61ba5b
--- /dev/null
+++ b/plugins/mm-broadband-modem-cinterion.c
@@ -0,0 +1,83 @@
+/* -*- 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) 2011 Ammonit Measurement GmbH
+ * Copyright (C) 2011 Google Inc.
+ * Author: Aleksander Morgado <aleksander@lanedo.com>
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <ctype.h>
+
+#include "ModemManager.h"
+#include "mm-modem-helpers.h"
+#include "mm-serial-parsers.h"
+#include "mm-log.h"
+
+#include "mm-broadband-modem-cinterion.h"
+
+G_DEFINE_TYPE (MMBroadbandModemCinterion, mm_broadband_modem_cinterion, MM_TYPE_BROADBAND_MODEM)
+
+struct _MMBroadbandModemCinterionPrivate {
+ gpointer dummy;
+};
+
+/*****************************************************************************/
+
+MMBroadbandModemCinterion *
+mm_broadband_modem_cinterion_new (const gchar *device,
+ const gchar *driver,
+ const gchar *plugin,
+ guint16 vendor_id,
+ guint16 product_id)
+{
+ return g_object_new (MM_TYPE_BROADBAND_MODEM_CINTERION,
+ MM_BASE_MODEM_DEVICE, device,
+ MM_BASE_MODEM_DRIVER, driver,
+ MM_BASE_MODEM_PLUGIN, plugin,
+ MM_BASE_MODEM_VENDOR_ID, vendor_id,
+ MM_BASE_MODEM_PRODUCT_ID, product_id,
+ NULL);
+}
+
+
+static void
+mm_broadband_modem_cinterion_init (MMBroadbandModemCinterion *self)
+{
+ /* Initialize private data */
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
+ MM_TYPE_BROADBAND_MODEM_CINTERION,
+ MMBroadbandModemCinterionPrivate);
+}
+
+static void
+finalize (GObject *object)
+{
+ G_OBJECT_CLASS (mm_broadband_modem_cinterion_parent_class)->finalize (object);
+}
+
+
+static void
+mm_broadband_modem_cinterion_class_init (MMBroadbandModemCinterionClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (object_class, sizeof (MMBroadbandModemCinterionPrivate));
+
+ /* Virtual methods */
+ object_class->finalize = finalize;
+}
diff --git a/plugins/mm-broadband-modem-cinterion.h b/plugins/mm-broadband-modem-cinterion.h
new file mode 100644
index 00000000..53e95b4f
--- /dev/null
+++ b/plugins/mm-broadband-modem-cinterion.h
@@ -0,0 +1,51 @@
+/* -*- 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) 2011 Ammonit Measurement GmbH
+ * Copyright (C) 2011 Google Inc.
+ * Author: Aleksander Morgado <aleksander@lanedo.com>
+ */
+
+#ifndef MM_BROADBAND_MODEM_CINTERION_H
+#define MM_BROADBAND_MODEM_CINTERION_H
+
+#include "mm-broadband-modem.h"
+
+#define MM_TYPE_BROADBAND_MODEM_CINTERION (mm_broadband_modem_cinterion_get_type ())
+#define MM_BROADBAND_MODEM_CINTERION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_CINTERION, MMBroadbandModemCinterion))
+#define MM_BROADBAND_MODEM_CINTERION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_CINTERION, MMBroadbandModemCinterionClass))
+#define MM_IS_BROADBAND_MODEM_CINTERION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_CINTERION))
+#define MM_IS_BROADBAND_MODEM_CINTERION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_CINTERION))
+#define MM_BROADBAND_MODEM_CINTERION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_CINTERION, MMBroadbandModemCinterionClass))
+
+typedef struct _MMBroadbandModemCinterion MMBroadbandModemCinterion;
+typedef struct _MMBroadbandModemCinterionClass MMBroadbandModemCinterionClass;
+typedef struct _MMBroadbandModemCinterionPrivate MMBroadbandModemCinterionPrivate;
+
+struct _MMBroadbandModemCinterion {
+ MMBroadbandModem parent;
+ MMBroadbandModemCinterionPrivate *priv;
+};
+
+struct _MMBroadbandModemCinterionClass{
+ MMBroadbandModemClass parent;
+};
+
+GType mm_broadband_modem_cinterion_get_type (void);
+
+MMBroadbandModemCinterion *mm_broadband_modem_cinterion_new (const gchar *device,
+ const gchar *driver,
+ const gchar *plugin,
+ guint16 vendor_id,
+ guint16 product_id);
+
+#endif /* MM_BROADBAND_MODEM_CINTERION_H */
diff --git a/plugins/mm-plugin-cinterion.c b/plugins/mm-plugin-cinterion.c
index 9d0fb529..d1e5fb76 100644
--- a/plugins/mm-plugin-cinterion.c
+++ b/plugins/mm-plugin-cinterion.c
@@ -17,13 +17,15 @@
* Boston, MA 02111-1307, USA.
*
* Copyright (C) 2011 Ammonit Measurement GmbH
+ * Copyright (C) 2011 Google Inc.
* Author: Aleksander Morgado <aleksander@lanedo.com>
*/
#include <string.h>
#include <gmodule.h>
+
#include "mm-plugin-cinterion.h"
-#include "mm-modem-cinterion-gsm.h"
+#include "mm-broadband-modem-cinterion.h"
#include "mm-log.h"
G_DEFINE_TYPE (MMPluginCinterion, mm_plugin_cinterion, MM_TYPE_PLUGIN_BASE)
@@ -31,186 +33,75 @@ G_DEFINE_TYPE (MMPluginCinterion, mm_plugin_cinterion, MM_TYPE_PLUGIN_BASE)
int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
-G_MODULE_EXPORT MMPlugin *
-mm_plugin_create (void)
+static MMBaseModem *
+grab_port (MMPluginBase *base,
+ MMBaseModem *existing,
+ MMPortProbe *probe,
+ GError **error)
{
- return MM_PLUGIN (g_object_new (MM_TYPE_PLUGIN_CINTERION,
- MM_PLUGIN_BASE_NAME, "Cinterion",
- MM_PLUGIN_BASE_SORT_LAST, TRUE,
- NULL));
-}
+ MMBaseModem *modem = NULL;
+ const gchar *name, *subsys, *driver;
+ guint16 vendor = 0, product = 0;
-static guint32
-get_level_for_capabilities (guint32 capabilities)
-{
- if (capabilities & MM_PLUGIN_BASE_PORT_CAP_GSM)
- return 10;
- return 0;
-}
+ subsys = mm_port_probe_get_port_subsys (probe);
+ name = mm_port_probe_get_port_name (probe);
-static gboolean
-check_vendor_cinterion (MMPluginBaseSupportsTask *task)
-{
- MMPluginBase *base;
- GUdevDevice *port;
- const char *subsys, *name;
- guint16 vendor = 0;
+ /* /\* The generic plugin cannot do anything with non-AT ports *\/ */
+ /* if (!mm_port_probe_is_at (probe)) { */
+ /* g_set_error (error, 0, 0, "Ignoring non-AT port"); */
+ /* return NULL; */
+ /* } */
- base = MM_PLUGIN_BASE (mm_plugin_base_supports_task_get_plugin (task));
- port = mm_plugin_base_supports_task_get_port (task);
+ driver = mm_port_probe_get_port_driver (probe);
- /* Try to get device IDs from udev. Note that it is not an error
+ /* Try to get Product IDs from udev. Note that it is not an error
* if we can't get them in our case, as we also support serial
* modems. */
- subsys = g_udev_device_get_subsystem (port);
- name = g_udev_device_get_name (port);
- mm_plugin_base_get_device_ids (base, subsys, name, &vendor, NULL);
-
- /* Vendors: Cinterion (0x1e2d)
- * Siemens (0x0681)
- */
- if (vendor == 0x1e2d || vendor == 0x0681) {
- mm_dbg ("Cinterion/Siemens USB modem detected");
- return TRUE;
+ mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product);
+
+ /* If this is the first port being grabbed, create a new modem object */
+ if (!existing)
+ modem = MM_BASE_MODEM (mm_broadband_modem_cinterion_new (mm_port_probe_get_port_physdev (probe),
+ driver,
+ mm_plugin_get_name (MM_PLUGIN (base)),
+ vendor,
+ product));
+
+ if (!mm_base_modem_grab_port (existing ? existing : modem,
+ subsys,
+ name,
+ MM_PORT_TYPE_UNKNOWN)) {
+ if (modem)
+ g_object_unref (modem);
+ return NULL;
}
- /* We may get Cinterion modems connected in RS232 port, try to get
- * probed Vendor ID string to check */
- if (mm_plugin_base_supports_task_propagate_cached (task)) {
- const gchar *probed_vendor;
- gchar *probed_vendor_strdown;
- gboolean probed_vendor_correct = FALSE;
-
- probed_vendor = mm_plugin_base_supports_task_get_probed_vendor (task);
- if (!probed_vendor)
- return FALSE;
-
- /* Lowercase the vendor string and compare */
- probed_vendor_strdown = g_utf8_strdown (probed_vendor, -1);
- if (strstr (probed_vendor_strdown, "cinterion") ||
- strstr (probed_vendor_strdown, "siemens")) {
- mm_dbg ("Cinterion/Siemens RS232 modem detected");
- probed_vendor_correct = TRUE;
- }
-
- g_free (probed_vendor_strdown);
-
- return probed_vendor_correct;
- }
-
- return FALSE;
-}
-
-static void
-probe_result (MMPluginBase *base,
- MMPluginBaseSupportsTask *task,
- guint32 capabilities,
- gpointer user_data)
-{
- /* Note: the signal contains only capabilities, but we can also query the
- * probed vendor and product strings here. */
-
- /* Check vendor */
- mm_plugin_base_supports_task_complete (task,
- (check_vendor_cinterion (task) ?
- get_level_for_capabilities (capabilities) : 0));
+ return existing ? existing : modem;
}
-static MMPluginSupportsResult
-supports_port (MMPluginBase *base,
- MMModem *existing,
- MMPluginBaseSupportsTask *task)
-{
- GUdevDevice *port;
- guint32 cached = 0;
-
- /* Can't do anything with non-serial ports */
- port = mm_plugin_base_supports_task_get_port (task);
- if (strcmp (g_udev_device_get_subsystem (port), "tty"))
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
-
- /* First thing to check in this plugin is if we got capabilities already.
- * This is because we have a later check of the probed vendor, which is
- * taken also during port probing.
- * Note that we also relaunch a port probe if we got a cached value but no
- * capabilities set (used when trying to detect RS232 modems during
- * re-scans). */
- if (!mm_plugin_base_supports_task_propagate_cached (task) ||
- !mm_plugin_base_supports_task_get_probed_capabilities (task)) {
- /* Kick off a probe */
- if (mm_plugin_base_probe_port (base, task, 100000, NULL))
- return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
-
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
- }
-
- /* Check vendor */
- if (!check_vendor_cinterion (task))
- return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
-
- /* Completed! */
- cached = mm_plugin_base_supports_task_get_probed_capabilities (task);
- mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (cached));
- return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
-}
+/*****************************************************************************/
-static MMModem *
-grab_port (MMPluginBase *base,
- MMModem *existing,
- MMPluginBaseSupportsTask *task,
- GError **error)
+G_MODULE_EXPORT MMPlugin *
+mm_plugin_create (void)
{
- GUdevDevice *port = NULL;
- MMModem *modem = NULL;
- const char *name, *subsys, *sysfs_path;
- guint32 caps;
- guint16 vendor = 0x1e2d;
- guint16 product = 0;
- MMPortType ptype;
-
- port = mm_plugin_base_supports_task_get_port (task);
- g_assert (port);
-
- /* Try to get Product IDs from udev. Note that it is not an error
- * if we can't get them in our case, as we also support serial
- * modems. */
- subsys = g_udev_device_get_subsystem (port);
- name = g_udev_device_get_name (port);
- mm_plugin_base_get_device_ids (base, subsys, name, NULL, &product);
-
- caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
- ptype = mm_plugin_base_probed_capabilities_to_port_type (caps);
- sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
- if (!existing) {
- if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
- modem = mm_modem_cinterion_gsm_new (sysfs_path,
- mm_plugin_base_supports_task_get_driver (task),
- mm_plugin_get_name (MM_PLUGIN (base)),
- vendor,
- product);
- }
-
- if (modem) {
- if (!mm_modem_grab_port (modem, subsys, name, ptype, MM_AT_PORT_FLAG_NONE, NULL, error)) {
- g_object_unref (modem);
- return NULL;
- }
- }
- } else if (get_level_for_capabilities (caps)) {
- modem = existing;
- if (!mm_modem_grab_port (modem, subsys, name, ptype, MM_AT_PORT_FLAG_NONE, NULL, error))
- return NULL;
- }
-
- return modem;
+ static const gchar *subsystems[] = { "tty", NULL };
+ static const gchar *vendor_strings[] = { "cinterion", "siemens", NULL };
+ static const guint16 vendor_ids[] = { 0x1e2d, 0x0681, 0 };
+
+ return MM_PLUGIN (
+ g_object_new (MM_TYPE_PLUGIN_CINTERION,
+ MM_PLUGIN_BASE_NAME, "Cinterion",
+ MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems,
+ MM_PLUGIN_BASE_ALLOWED_VENDOR_STRINGS, vendor_strings,
+ MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids,
+ MM_PLUGIN_BASE_ALLOWED_AT, TRUE,
+ MM_PLUGIN_BASE_SORT_LAST, TRUE,
+ NULL));
}
-/*****************************************************************************/
-
static void
mm_plugin_cinterion_init (MMPluginCinterion *self)
{
- g_signal_connect (self, "probe-result", G_CALLBACK (probe_result), NULL);
}
static void
@@ -218,6 +109,5 @@ mm_plugin_cinterion_class_init (MMPluginCinterionClass *klass)
{
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
- pb_class->supports_port = supports_port;
pb_class->grab_port = grab_port;
}
diff --git a/plugins/mm-plugin-cinterion.h b/plugins/mm-plugin-cinterion.h
index 4847167f..13497653 100644
--- a/plugins/mm-plugin-cinterion.h
+++ b/plugins/mm-plugin-cinterion.h
@@ -24,7 +24,6 @@
#define MM_PLUGIN_CINTERION_H
#include "mm-plugin-base.h"
-#include "mm-generic-gsm.h"
#define MM_TYPE_PLUGIN_CINTERION (mm_plugin_cinterion_get_type ())
#define MM_PLUGIN_CINTERION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_CINTERION, MMPluginCinterion))