diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-04-09 10:48:17 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-04-09 12:43:42 +0200 |
commit | 664636ed36c4bb3f6b6b6c275fdee595f806004c (patch) | |
tree | 6304afb247f23c99898caec801d1255f534345bc | |
parent | dff23f57b3e829e5abe6008b6b21e45d1297eade (diff) |
infineon: setup plugin skeleton
-rw-r--r-- | plugins/Makefile.am | 14 | ||||
-rw-r--r-- | plugins/infineon/mm-broadband-bearer-infineon.c | 84 | ||||
-rw-r--r-- | plugins/infineon/mm-broadband-bearer-infineon.h | 59 | ||||
-rw-r--r-- | plugins/infineon/mm-broadband-modem-infineon.c | 126 | ||||
-rw-r--r-- | plugins/infineon/mm-broadband-modem-infineon.h | 47 | ||||
-rw-r--r-- | plugins/infineon/mm-plugin-infineon.c | 81 | ||||
-rw-r--r-- | plugins/infineon/mm-plugin-infineon.h | 46 |
7 files changed, 456 insertions, 1 deletions
diff --git a/plugins/Makefile.am b/plugins/Makefile.am index b3ff3065..af9d7ff9 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -68,7 +68,8 @@ pkglib_LTLIBRARIES = \ libmm-plugin-zte.la \ libmm-plugin-sierra.la \ libmm-plugin-mbm.la \ - libmm-plugin-via.la + libmm-plugin-via.la \ + libmm-plugin-infineon.la # Generic libmm_plugin_generic_la_SOURCES = \ @@ -338,6 +339,17 @@ libmm_plugin_via_la_SOURCES = \ libmm_plugin_via_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) libmm_plugin_via_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS) +# Infineon modem +libmm_plugin_infineon_la_SOURCES = \ + infineon/mm-plugin-infineon.c \ + infineon/mm-plugin-infineon.h \ + infineon/mm-broadband-modem-infineon.c \ + infineon/mm-broadband-modem-infineon.h \ + infineon/mm-broadband-bearer-infineon.c \ + infineon/mm-broadband-bearer-infineon.h +libmm_plugin_infineon_la_CPPFLAGS = $(PLUGIN_COMMON_COMPILER_FLAGS) +libmm_plugin_infineon_la_LDFLAGS = $(PLUGIN_COMMON_LINKER_FLAGS) + # Additional files to include in the distribution EXTRA_DIST = \ $(udevrules_DATA) diff --git a/plugins/infineon/mm-broadband-bearer-infineon.c b/plugins/infineon/mm-broadband-bearer-infineon.c new file mode 100644 index 00000000..287846b7 --- /dev/null +++ b/plugins/infineon/mm-broadband-bearer-infineon.c @@ -0,0 +1,84 @@ +/* -*- 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) 2013 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <config.h> + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <ctype.h> +#include <arpa/inet.h> + +#include <ModemManager.h> +#define _LIBMM_INSIDE_MM +#include <libmm-glib.h> + +#include "mm-base-modem-at.h" +#include "mm-broadband-bearer-infineon.h" +#include "mm-log.h" +#include "mm-modem-helpers.h" + +G_DEFINE_TYPE (MMBroadbandBearerInfineon, mm_broadband_bearer_infineon, MM_TYPE_BROADBAND_BEARER) + +/*****************************************************************************/ + +MMBearer * +mm_broadband_bearer_infineon_new_finish (GAsyncResult *res, + GError **error) +{ + GObject *bearer; + GObject *source; + + source = g_async_result_get_source_object (res); + bearer = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error); + g_object_unref (source); + + if (!bearer) + return NULL; + + /* Only export valid bearers */ + mm_bearer_export (MM_BEARER (bearer)); + + return MM_BEARER (bearer); +} + +void +mm_broadband_bearer_infineon_new (MMBroadbandModemInfineon *modem, + MMBearerProperties *config, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + g_async_initable_new_async ( + MM_TYPE_BROADBAND_BEARER_INFINEON, + G_PRIORITY_DEFAULT, + cancellable, + callback, + user_data, + MM_BEARER_MODEM, modem, + MM_BEARER_CONFIG, config, + NULL); +} + +static void +mm_broadband_bearer_infineon_init (MMBroadbandBearerInfineon *self) +{ +} + +static void +mm_broadband_bearer_infineon_class_init (MMBroadbandBearerInfineonClass *klass) +{ +} diff --git a/plugins/infineon/mm-broadband-bearer-infineon.h b/plugins/infineon/mm-broadband-bearer-infineon.h new file mode 100644 index 00000000..1cd127e9 --- /dev/null +++ b/plugins/infineon/mm-broadband-bearer-infineon.h @@ -0,0 +1,59 @@ +/* -*- 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) 2013 Aleksander Morgado <aleksander@gnu.org> + */ + +#ifndef MM_BROADBAND_BEARER_INFINEON_H +#define MM_BROADBAND_BEARER_INFINEON_H + +#include <glib.h> +#include <glib-object.h> + +#define _LIBMM_INSIDE_MM +#include <libmm-glib.h> + +#include "mm-broadband-bearer.h" +#include "mm-broadband-modem-infineon.h" + +#define MM_TYPE_BROADBAND_BEARER_INFINEON (mm_broadband_bearer_infineon_get_type ()) +#define MM_BROADBAND_BEARER_INFINEON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_BEARER_INFINEON, MMBroadbandBearerInfineon)) +#define MM_BROADBAND_BEARER_INFINEON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_BEARER_INFINEON, MMBroadbandBearerInfineonClass)) +#define MM_IS_BROADBAND_BEARER_INFINEON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_BEARER_INFINEON)) +#define MM_IS_BROADBAND_BEARER_INFINEON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_BEARER_INFINEON)) +#define MM_BROADBAND_BEARER_INFINEON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_BEARER_INFINEON, MMBroadbandBearerInfineonClass)) + +typedef struct _MMBroadbandBearerInfineon MMBroadbandBearerInfineon; +typedef struct _MMBroadbandBearerInfineonClass MMBroadbandBearerInfineonClass; +typedef struct _MMBroadbandBearerInfineonPrivate MMBroadbandBearerInfineonPrivate; + +struct _MMBroadbandBearerInfineon { + MMBroadbandBearer parent; + MMBroadbandBearerInfineonPrivate *priv; +}; + +struct _MMBroadbandBearerInfineonClass { + MMBroadbandBearerClass parent; +}; + +GType mm_broadband_bearer_infineon_get_type (void); + +/* Default 3GPP bearer creation implementation */ +void mm_broadband_bearer_infineon_new (MMBroadbandModemInfineon *modem, + MMBearerProperties *config, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +MMBearer *mm_broadband_bearer_infineon_new_finish (GAsyncResult *res, + GError **error); + +#endif /* MM_BROADBAND_BEARER_INFINEON_H */ diff --git a/plugins/infineon/mm-broadband-modem-infineon.c b/plugins/infineon/mm-broadband-modem-infineon.c new file mode 100644 index 00000000..584ddee9 --- /dev/null +++ b/plugins/infineon/mm-broadband-modem-infineon.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) 2013 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <config.h> + +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <ctype.h> + +#include "ModemManager.h" +#include "mm-serial-parsers.h" +#include "mm-log.h" +#include "mm-errors-types.h" +#include "mm-iface-modem.h" +#include "mm-broadband-bearer-infineon.h" +#include "mm-broadband-modem-infineon.h" + +static void iface_modem_init (MMIfaceModem *iface); + +G_DEFINE_TYPE_EXTENDED (MMBroadbandModemInfineon, mm_broadband_modem_infineon, MM_TYPE_BROADBAND_MODEM, 0, + G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)) + +/*****************************************************************************/ +/* Create Bearer (Modem interface) */ + +static MMBearer * +modem_create_bearer_finish (MMIfaceModem *self, + GAsyncResult *res, + GError **error) +{ + MMBearer *bearer; + + bearer = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)); + mm_dbg ("New Infineon bearer created at DBus path '%s'", mm_bearer_get_path (bearer)); + + return g_object_ref (bearer); +} + +static void +broadband_bearer_infineon_new_ready (GObject *source, + GAsyncResult *res, + GSimpleAsyncResult *simple) +{ + MMBearer *bearer = NULL; + GError *error = NULL; + + bearer = mm_broadband_bearer_infineon_new_finish (res, &error); + if (!bearer) + g_simple_async_result_take_error (simple, error); + else + g_simple_async_result_set_op_res_gpointer (simple, + bearer, + (GDestroyNotify)g_object_unref); + g_simple_async_result_complete (simple); + g_object_unref (simple); +} + +static void +modem_create_bearer (MMIfaceModem *self, + MMBearerProperties *properties, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *result; + + result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + modem_create_bearer); + + mm_dbg ("Creating Infineon bearer..."); + mm_broadband_bearer_infineon_new (MM_BROADBAND_MODEM_INFINEON (self), + properties, + NULL, /* cancellable */ + (GAsyncReadyCallback)broadband_bearer_infineon_new_ready, + result); +} + +/*****************************************************************************/ + +MMBroadbandModemInfineon * +mm_broadband_modem_infineon_new (const gchar *device, + const gchar **drivers, + const gchar *plugin, + guint16 vendor_id, + guint16 product_id) +{ + return g_object_new (MM_TYPE_BROADBAND_MODEM_INFINEON, + MM_BASE_MODEM_DEVICE, device, + MM_BASE_MODEM_DRIVERS, drivers, + 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_infineon_init (MMBroadbandModemInfineon *self) +{ +} + +static void +iface_modem_init (MMIfaceModem *iface) +{ + iface->create_bearer = modem_create_bearer; + iface->create_bearer_finish = modem_create_bearer_finish; +} + +static void +mm_broadband_modem_infineon_class_init (MMBroadbandModemInfineonClass *klass) +{ +} diff --git a/plugins/infineon/mm-broadband-modem-infineon.h b/plugins/infineon/mm-broadband-modem-infineon.h new file mode 100644 index 00000000..1b4ee5a2 --- /dev/null +++ b/plugins/infineon/mm-broadband-modem-infineon.h @@ -0,0 +1,47 @@ +/* -*- 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) 2013 Aleksander Morgado <aleksander@gnu.org> + */ + +#ifndef MM_BROADBAND_MODEM_INFINEON_H +#define MM_BROADBAND_MODEM_INFINEON_H + +#include "mm-broadband-modem.h" + +#define MM_TYPE_BROADBAND_MODEM_INFINEON (mm_broadband_modem_infineon_get_type ()) +#define MM_BROADBAND_MODEM_INFINEON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_INFINEON, MMBroadbandModemInfineon)) +#define MM_BROADBAND_MODEM_INFINEON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_INFINEON, MMBroadbandModemInfineonClass)) +#define MM_IS_BROADBAND_MODEM_INFINEON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_INFINEON)) +#define MM_IS_BROADBAND_MODEM_INFINEON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_INFINEON)) +#define MM_BROADBAND_MODEM_INFINEON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_INFINEON, MMBroadbandModemInfineonClass)) + +typedef struct _MMBroadbandModemInfineon MMBroadbandModemInfineon; +typedef struct _MMBroadbandModemInfineonClass MMBroadbandModemInfineonClass; + +struct _MMBroadbandModemInfineon { + MMBroadbandModem parent; +}; + +struct _MMBroadbandModemInfineonClass{ + MMBroadbandModemClass parent; +}; + +GType mm_broadband_modem_infineon_get_type (void); + +MMBroadbandModemInfineon *mm_broadband_modem_infineon_new (const gchar *device, + const gchar **drivers, + const gchar *plugin, + guint16 vendor_id, + guint16 product_id); + +#endif /* MM_BROADBAND_MODEM_INFINEON_H */ diff --git a/plugins/infineon/mm-plugin-infineon.c b/plugins/infineon/mm-plugin-infineon.c new file mode 100644 index 00000000..0a0a8e11 --- /dev/null +++ b/plugins/infineon/mm-plugin-infineon.c @@ -0,0 +1,81 @@ +/* -*- 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) 2013 Aleksander Morgado <aleksander@gnu.org> + */ + +#include <string.h> +#include <gmodule.h> + +#define _LIBMM_INSIDE_MM +#include <libmm-glib.h> + +#include "mm-broadband-modem-infineon.h" +#include "mm-plugin-infineon.h" +#include "mm-log.h" + +G_DEFINE_TYPE (MMPluginInfineon, mm_plugin_infineon, MM_TYPE_PLUGIN) + +int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; +int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; + +static MMBaseModem * +create_modem (MMPlugin *self, + const gchar *sysfs_path, + const gchar **drivers, + guint16 vendor, + guint16 product, + GList *probes, + GError **error) +{ + return MM_BASE_MODEM (mm_broadband_modem_infineon_new (sysfs_path, + drivers, + mm_plugin_get_name (self), + vendor, + product)); +} + +/*****************************************************************************/ + +G_MODULE_EXPORT MMPlugin * +mm_plugin_create (void) +{ + static const gchar *subsystems[] = { "tty", NULL }; + static const guint16 vendor_ids[] = { 0x1519, 0 }; + + return MM_PLUGIN ( + g_object_new (MM_TYPE_PLUGIN_INFINEON, + MM_PLUGIN_NAME, "Infineon", + MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems, + MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids, + MM_PLUGIN_ALLOWED_AT, TRUE, + NULL)); +} + +static void +mm_plugin_infineon_init (MMPluginInfineon *self) +{ +} + +static void +mm_plugin_infineon_class_init (MMPluginInfineonClass *klass) +{ + MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass); + + plugin_class->create_modem = create_modem; +} diff --git a/plugins/infineon/mm-plugin-infineon.h b/plugins/infineon/mm-plugin-infineon.h new file mode 100644 index 00000000..d0f8e470 --- /dev/null +++ b/plugins/infineon/mm-plugin-infineon.h @@ -0,0 +1,46 @@ +/* -*- 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) 2013 Aleksander Morgado <aleksander@gnu.org> + */ + +#ifndef MM_PLUGIN_INFINEON_H +#define MM_PLUGIN_INFINEON_H + +#include "mm-plugin.h" + +#define MM_TYPE_PLUGIN_INFINEON (mm_plugin_infineon_get_type ()) +#define MM_PLUGIN_INFINEON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_INFINEON, MMPluginInfineon)) +#define MM_PLUGIN_INFINEON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_INFINEON, MMPluginInfineonClass)) +#define MM_IS_PLUGIN_INFINEON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_INFINEON)) +#define MM_IS_PLUGIN_INFINEON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_INFINEON)) +#define MM_PLUGIN_INFINEON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_INFINEON, MMPluginInfineonClass)) + +typedef struct { + MMPlugin parent; +} MMPluginInfineon; + +typedef struct { + MMPluginClass parent; +} MMPluginInfineonClass; + +GType mm_plugin_infineon_get_type (void); + +G_MODULE_EXPORT MMPlugin *mm_plugin_create (void); + +#endif /* MM_PLUGIN_INFINEON_H */ |