diff options
-rw-r--r-- | plugins/Makefile.am | 21 | ||||
-rw-r--r-- | plugins/mm-plugin-wavecom.c | 168 | ||||
-rw-r--r-- | plugins/wavecom/mm-broadband-modem-wavecom.c | 60 | ||||
-rw-r--r-- | plugins/wavecom/mm-broadband-modem-wavecom.h | 50 | ||||
-rw-r--r-- | plugins/wavecom/mm-plugin-wavecom.c | 120 | ||||
-rw-r--r-- | plugins/wavecom/mm-plugin-wavecom.h (renamed from plugins/mm-plugin-wavecom.h) | 3 |
6 files changed, 243 insertions, 179 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index f6cd36f2..04678693 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -47,7 +47,8 @@ pkglib_LTLIBRARIES = \ libmm-plugin-hso.la \ libmm-plugin-anydata.la \ libmm-plugin-linktop.la \ - libmm-plugin-simtech.la + libmm-plugin-simtech.la \ + libmm-plugin-wavecom.la #pkglib_LTLIBRARIES = \ # libmm-plugin-generic.la \ @@ -148,15 +149,15 @@ libmm_plugin_hso_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS) #libmm_plugin_sierra_la_LIBADD = \ # $(builddir)/libicera-utils.la -## Wavecom (Sierra Airlink) -#libmm_plugin_wavecom_la_SOURCES = \ -# mm-plugin-wavecom.c \ -# mm-plugin-wavecom.h \ -# mm-modem-wavecom-gsm.c \ -# mm-modem-wavecom-gsm.h -#libmm_plugin_wavecom_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) -#libmm_plugin_wavecom_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS) -# +# Wavecom (Sierra Airlink) +libmm_plugin_wavecom_la_SOURCES = \ + wavecom/mm-plugin-wavecom.c \ + wavecom/mm-plugin-wavecom.h \ + wavecom/mm-broadband-modem-wavecom.c \ + wavecom/mm-broadband-modem-wavecom.h +libmm_plugin_wavecom_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) +libmm_plugin_wavecom_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS) + ## Novatel #libmm_plugin_novatel_la_SOURCES = \ # mm-plugin-novatel.c \ diff --git a/plugins/mm-plugin-wavecom.c b/plugins/mm-plugin-wavecom.c deleted file mode 100644 index 3bd82cbd..00000000 --- a/plugins/mm-plugin-wavecom.c +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- 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. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Copyright (C) 2011 Ammonit Measurement GmbH - * Author: Aleksander Morgado <aleksander@lanedo.com> - */ - -#include <string.h> -#include <gmodule.h> -#include "mm-plugin-wavecom.h" -#include "mm-modem-wavecom-gsm.h" - -G_DEFINE_TYPE (MMPluginWavecom, mm_plugin_wavecom, 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) -{ - return MM_PLUGIN (g_object_new (MM_TYPE_PLUGIN_WAVECOM, - MM_PLUGIN_BASE_NAME, "Wavecom", - NULL)); -} - -static guint32 -get_level_for_capabilities (guint32 capabilities) -{ - if (capabilities & MM_PLUGIN_BASE_PORT_CAP_GSM) - return 10; - return 0; -} - -static void -probe_result (MMPluginBase *base, - MMPluginBaseSupportsTask *task, - guint32 capabilities, - gpointer user_data) -{ - mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (capabilities)); -} - -static MMPluginSupportsResult -supports_port (MMPluginBase *base, - MMModem *existing, - MMPluginBaseSupportsTask *task) -{ - GUdevDevice *port; - const char *subsys, *name; - guint16 vendor = 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; - - subsys = g_udev_device_get_subsystem (port); - name = g_udev_device_get_name (port); - - if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, NULL)) - return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; - - /* Vendor: Wavecom */ - if (vendor != 0x114f) - return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; - - /* Check if a previous probing was already launched in this port */ - if (mm_plugin_base_supports_task_propagate_cached (task)) { - guint32 level; - - /* A previous probing was already done, use its results */ - level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task)); - if (level) { - mm_plugin_base_supports_task_complete (task, level); - return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS; - } - return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; - } - - /* Otherwise 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; -} - -static MMModem * -grab_port (MMPluginBase *base, - MMModem *existing, - MMPluginBaseSupportsTask *task, - GError **error) -{ - GUdevDevice *port = NULL; - MMModem *modem = NULL; - const char *name, *subsys, *sysfs_path; - guint32 caps; - guint16 vendor = 0, product = 0; - MMPortType ptype; - - port = mm_plugin_base_supports_task_get_port (task); - g_assert (port); - - subsys = g_udev_device_get_subsystem (port); - name = g_udev_device_get_name (port); - - if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) { - g_set_error (error, 0, 0, "Could not get modem product ID."); - return NULL; - } - - 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_wavecom_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 void -mm_plugin_wavecom_init (MMPluginWavecom *self) -{ - g_signal_connect (self, "probe-result", G_CALLBACK (probe_result), NULL); -} - -static void -mm_plugin_wavecom_class_init (MMPluginWavecomClass *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/wavecom/mm-broadband-modem-wavecom.c b/plugins/wavecom/mm-broadband-modem-wavecom.c new file mode 100644 index 00000000..b8abcd22 --- /dev/null +++ b/plugins/wavecom/mm-broadband-modem-wavecom.c @@ -0,0 +1,60 @@ +/* -*- 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) 2012 Aleksander Morgado <aleksander@gnu.org> + * 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 <libmm-common.h> + +#include "ModemManager.h" +#include "mm-log.h" +#include "mm-broadband-modem-wavecom.h" + +G_DEFINE_TYPE (MMBroadbandModemWavecom, mm_broadband_modem_wavecom, MM_TYPE_BROADBAND_MODEM); + +/*****************************************************************************/ + +MMBroadbandModemWavecom * +mm_broadband_modem_wavecom_new (const gchar *device, + const gchar *driver, + const gchar *plugin, + guint16 vendor_id, + guint16 product_id) +{ + return g_object_new (MM_TYPE_BROADBAND_MODEM_WAVECOM, + 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_wavecom_init (MMBroadbandModemWavecom *self) +{ +} + +static void +mm_broadband_modem_wavecom_class_init (MMBroadbandModemWavecomClass *klass) +{ +} diff --git a/plugins/wavecom/mm-broadband-modem-wavecom.h b/plugins/wavecom/mm-broadband-modem-wavecom.h new file mode 100644 index 00000000..3bec594d --- /dev/null +++ b/plugins/wavecom/mm-broadband-modem-wavecom.h @@ -0,0 +1,50 @@ +/* -*- 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) 2012 Aleksander Morgado <aleksander@gnu.org> + * + * Author: Aleksander Morgado <aleksander@lanedo.com> + */ + +#ifndef MM_BROADBAND_MODEM_WAVECOM_H +#define MM_BROADBAND_MODEM_WAVECOM_H + +#include "mm-broadband-modem.h" + +#define MM_TYPE_BROADBAND_MODEM_WAVECOM (mm_broadband_modem_wavecom_get_type ()) +#define MM_BROADBAND_MODEM_WAVECOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_WAVECOM, MMBroadbandModemWavecom)) +#define MM_BROADBAND_MODEM_WAVECOM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_WAVECOM, MMBroadbandModemWavecomClass)) +#define MM_IS_BROADBAND_MODEM_WAVECOM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_WAVECOM)) +#define MM_IS_BROADBAND_MODEM_WAVECOM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_WAVECOM)) +#define MM_BROADBAND_MODEM_WAVECOM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_WAVECOM, MMBroadbandModemWavecomClass)) + +typedef struct _MMBroadbandModemWavecom MMBroadbandModemWavecom; +typedef struct _MMBroadbandModemWavecomClass MMBroadbandModemWavecomClass; + +struct _MMBroadbandModemWavecom { + MMBroadbandModem parent; +}; + +struct _MMBroadbandModemWavecomClass{ + MMBroadbandModemClass parent; +}; + +GType mm_broadband_modem_wavecom_get_type (void); + +MMBroadbandModemWavecom *mm_broadband_modem_wavecom_new (const gchar *device, + const gchar *driver, + const gchar *plugin, + guint16 vendor_id, + guint16 product_id); + +#endif /* MM_BROADBAND_MODEM_WAVECOM_H */ diff --git a/plugins/wavecom/mm-plugin-wavecom.c b/plugins/wavecom/mm-plugin-wavecom.c new file mode 100644 index 00000000..d83f96ee --- /dev/null +++ b/plugins/wavecom/mm-plugin-wavecom.c @@ -0,0 +1,120 @@ +/* -*- 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. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Copyright (C) 2011 Ammonit Measurement GmbH + * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org> + * + * Author: Aleksander Morgado <aleksander@lanedo.com> + */ + +#include <string.h> +#include <gmodule.h> + +#include <libmm-common.h> + +#include "mm-plugin-wavecom.h" +#include "mm-broadband-modem-wavecom.h" + +G_DEFINE_TYPE (MMPluginWavecom, mm_plugin_wavecom, MM_TYPE_PLUGIN_BASE) + +int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; +int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; + +/*****************************************************************************/ + +static MMBaseModem * +grab_port (MMPluginBase *base, + MMBaseModem *existing, + MMPortProbe *probe, + GError **error) +{ + MMBaseModem *modem = NULL; + const gchar *name, *subsys; + guint16 vendor = 0, product = 0; + + /* The Wavecom plugin cannot do anything with non-AT ports */ + if (!mm_port_probe_is_at (probe)) { + g_set_error_literal (error, + MM_CORE_ERROR, + MM_CORE_ERROR_UNSUPPORTED, + "Ignoring non-AT port"); + return NULL; + } + + subsys = mm_port_probe_get_port_subsys (probe); + name = mm_port_probe_get_port_name (probe); + + if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) { + g_set_error_literal (error, + MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Could not get modem product ID"); + return NULL; + } + + /* If this is the first port being grabbed, create a new modem object */ + if (!existing) + modem = MM_BASE_MODEM (mm_broadband_modem_wavecom_new (mm_port_probe_get_port_physdev (probe), + mm_port_probe_get_port_driver (probe), + mm_plugin_get_name (MM_PLUGIN (base)), + vendor, + product)); + + if (!mm_base_modem_grab_port (existing ? existing : modem, + subsys, + name, + MM_PORT_TYPE_AT, /* we only allow AT ports here */ + MM_AT_PORT_FLAG_NONE, + error)) { + if (modem) + g_object_unref (modem); + return NULL; + } + + return existing ? existing : modem; +} + +/*****************************************************************************/ + +G_MODULE_EXPORT MMPlugin * +mm_plugin_create (void) +{ + static const gchar *subsystems[] = { "tty", NULL }; + static const guint16 vendor_ids[] = { 0x114f, 0 }; + + return MM_PLUGIN ( + g_object_new (MM_TYPE_PLUGIN_WAVECOM, + MM_PLUGIN_BASE_NAME, "Wavecom", + MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_BASE_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_BASE_ALLOWED_AT, TRUE, + NULL)); +} + +static void +mm_plugin_wavecom_init (MMPluginWavecom *self) +{ +} + +static void +mm_plugin_wavecom_class_init (MMPluginWavecomClass *klass) +{ + MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass); + + pb_class->grab_port = grab_port; +} diff --git a/plugins/mm-plugin-wavecom.h b/plugins/wavecom/mm-plugin-wavecom.h index 5563a370..9b355d5f 100644 --- a/plugins/mm-plugin-wavecom.h +++ b/plugins/wavecom/mm-plugin-wavecom.h @@ -17,6 +17,8 @@ * Boston, MA 02111-1307, USA. * * Copyright (C) 2011 Ammonit Measurement GmbH + * Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org> + * * Author: Aleksander Morgado <aleksander@lanedo.com> */ @@ -24,7 +26,6 @@ #define MM_PLUGIN_WAVECOM_H #include "mm-plugin-base.h" -#include "mm-generic-gsm.h" #define MM_TYPE_PLUGIN_WAVECOM (mm_plugin_wavecom_get_type ()) #define MM_PLUGIN_WAVECOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_WAVECOM, MMPluginWavecom)) |