aboutsummaryrefslogtreecommitdiff
path: root/plugins/iridium
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/iridium')
-rw-r--r--plugins/iridium/mm-bearer-iridium.c427
-rw-r--r--plugins/iridium/mm-bearer-iridium.h53
-rw-r--r--plugins/iridium/mm-broadband-modem-iridium.c486
-rw-r--r--plugins/iridium/mm-broadband-modem-iridium.h49
-rw-r--r--plugins/iridium/mm-plugin-iridium.c127
-rw-r--r--plugins/iridium/mm-plugin-iridium.h47
-rw-r--r--plugins/iridium/mm-sim-iridium.c87
-rw-r--r--plugins/iridium/mm-sim-iridium.h52
8 files changed, 1328 insertions, 0 deletions
diff --git a/plugins/iridium/mm-bearer-iridium.c b/plugins/iridium/mm-bearer-iridium.c
new file mode 100644
index 00000000..c38f05e2
--- /dev/null
+++ b/plugins/iridium/mm-bearer-iridium.c
@@ -0,0 +1,427 @@
+/* -*- 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) 2012 Ammonit Measurement GmbH
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <ModemManager.h>
+#include <libmm-common.h>
+
+#include "mm-bearer-iridium.h"
+#include "mm-base-modem-at.h"
+#include "mm-utils.h"
+#include "mm-log.h"
+
+/* Allow up to 200s to get a proper IP connection */
+#define MM_BEARER_IRIDIUM_IP_TIMEOUT_DEFAULT 200
+
+G_DEFINE_TYPE (MMBearerIridium, mm_bearer_iridium, MM_TYPE_BEARER);
+
+/*****************************************************************************/
+/* Connect */
+
+typedef struct {
+ MMPort *data;
+ MMCommonBearerIpConfig *ipv4_config;
+ MMCommonBearerIpConfig *ipv6_config;
+} ConnectResult;
+
+static void
+connect_result_free (ConnectResult *result)
+{
+ if (result->ipv4_config)
+ g_object_unref (result->ipv4_config);
+ if (result->ipv6_config)
+ g_object_unref (result->ipv6_config);
+ g_object_unref (result->data);
+ g_free (result);
+}
+
+typedef struct {
+ MMBearerIridium *self;
+ GSimpleAsyncResult *result;
+ GCancellable *cancellable;
+ GError *saved_error;
+} ConnectContext;
+
+static void
+connect_context_complete_and_free (ConnectContext *ctx)
+{
+ g_simple_async_result_complete_in_idle (ctx->result);
+ if (ctx->saved_error)
+ g_error_free (ctx->saved_error);
+ g_object_unref (ctx->cancellable);
+ g_object_unref (ctx->result);
+ g_object_unref (ctx->self);
+ g_free (ctx);
+}
+
+static gboolean
+connect_finish (MMBearer *self,
+ GAsyncResult *res,
+ MMPort **data,
+ MMCommonBearerIpConfig **ipv4_config,
+ MMCommonBearerIpConfig **ipv6_config,
+ GError **error)
+{
+ ConnectResult *result;
+
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
+ return FALSE;
+
+ result = (ConnectResult *) g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
+ *data = MM_PORT (g_object_ref (result->data));
+ *ipv4_config = (result->ipv4_config ? g_object_ref (result->ipv4_config) : NULL);
+ *ipv6_config = (result->ipv6_config ? g_object_ref (result->ipv6_config) : NULL);
+
+ return TRUE;
+}
+
+static void
+connect_report_ready (MMBaseModem *modem,
+ GAsyncResult *res,
+ ConnectContext *ctx)
+{
+ const gchar *result;
+
+ /* If cancelled, complete */
+ if (g_cancellable_is_cancelled (ctx->cancellable)) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_CANCELLED,
+ "Connection setup operation has been cancelled");
+ connect_context_complete_and_free (ctx);
+ return;
+ }
+
+ /* If we got a proper extended reply, build the new error to be set */
+ result = mm_base_modem_at_command_finish (modem, res, NULL);
+ if (result &&
+ g_str_has_prefix (result, "+CEER: ") &&
+ strlen (result) > 7) {
+ g_simple_async_result_set_error (ctx->result,
+ ctx->saved_error->domain,
+ ctx->saved_error->code,
+ "%s", &result[7]);
+ g_error_free (ctx->saved_error);
+ ctx->saved_error = NULL;
+ connect_context_complete_and_free (ctx);
+ return;
+ }
+
+ /* Take the original error as it was */
+ g_simple_async_result_take_error (ctx->result,
+ ctx->saved_error);
+ ctx->saved_error = NULL;
+ connect_context_complete_and_free (ctx);
+}
+
+static void
+dial_ready (MMBaseModem *modem,
+ GAsyncResult *res,
+ ConnectContext *ctx)
+{
+ MMCommonBearerIpConfig *config;
+ ConnectResult *result;
+
+ /* DO NOT check for cancellable here. If we got here without errors, the
+ * bearer is really connected and therefore we need to reflect that in
+ * the state machine. */
+ mm_base_modem_at_command_finish (modem, res, &(ctx->saved_error));
+ if (ctx->saved_error) {
+ /* Try to get more information why it failed */
+ mm_base_modem_at_command (
+ modem,
+ "+CEER",
+ 3,
+ FALSE,
+ NULL, /* cancellable */
+ (GAsyncReadyCallback)connect_report_ready,
+ ctx);
+ return;
+ }
+
+ /* Port is connected; update the state */
+ mm_port_set_connected (MM_PORT (mm_base_modem_get_port_primary (modem)), TRUE);
+
+ /* Build IP config; always PPP based */
+ config = mm_common_bearer_ip_config_new ();
+ mm_common_bearer_ip_config_set_method (config, MM_BEARER_IP_METHOD_PPP);
+
+ /* Build result */
+ result = g_new0 (ConnectResult, 1);
+ result->data = g_object_ref (mm_base_modem_get_port_primary (modem));
+ result->ipv4_config = config;
+ result->ipv6_config = g_object_ref (config);
+
+ /* Set operation result */
+ g_simple_async_result_set_op_res_gpointer (ctx->result,
+ result,
+ (GDestroyNotify)connect_result_free);
+ connect_context_complete_and_free (ctx);
+}
+
+static void
+service_type_ready (MMBaseModem *modem,
+ GAsyncResult *res,
+ ConnectContext *ctx)
+{
+ GError *error = NULL;
+
+ /* If cancelled, complete */
+ if (g_cancellable_is_cancelled (ctx->cancellable)) {
+ g_simple_async_result_set_error (ctx->result,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_CANCELLED,
+ "Connection setup operation has been cancelled");
+ connect_context_complete_and_free (ctx);
+ return;
+ }
+
+ /* Errors setting the service type will be critical */
+ mm_base_modem_at_command_finish (modem, res, &error);
+ if (error) {
+ g_simple_async_result_take_error (ctx->result, error);
+ connect_context_complete_and_free (ctx);
+ return;
+ }
+
+ /* We just use the default number to dial in the Iridium network. Also note
+ * that we won't specify a specific port to use; Iridium modems only expose
+ * one. */
+ mm_base_modem_at_command (
+ modem,
+ "ATDT008816000025",
+ 60,
+ FALSE,
+ NULL, /* cancellable */
+ (GAsyncReadyCallback)dial_ready,
+ ctx);
+}
+
+static void
+connect (MMBearer *self,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ ConnectContext *ctx;
+ MMBaseModem *modem = NULL;
+
+ g_object_get (self,
+ MM_BEARER_MODEM, &modem,
+ NULL);
+ g_assert (modem);
+
+ /* Don't bother to get primary and check if connected and all that; we
+ * already do this check when sending the ATDT call */
+
+ /* In this context, we only keep the stuff we'll need later */
+ ctx = g_new0 (ConnectContext, 1);
+ ctx->self = g_object_ref (self);
+ ctx->cancellable = g_object_ref (cancellable);
+ ctx->result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ connect);
+
+ /* Bearer service type set to 9600bps (V.110), which behaves better than the
+ * default 9600bps (V.32). */
+ mm_base_modem_at_command (
+ modem,
+ "+CBST=71,0,1",
+ 3,
+ FALSE,
+ NULL, /* cancellable */
+ (GAsyncReadyCallback)service_type_ready,
+ ctx);
+
+ g_object_unref (modem);
+}
+
+/*****************************************************************************/
+/* Disconnect */
+
+static gboolean
+disconnect_finish (MMBearer *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
+}
+
+static void
+primary_flash_ready (MMSerialPort *port,
+ GError *error,
+ GSimpleAsyncResult *result)
+{
+ if (error) {
+ /* Ignore "NO CARRIER" response when modem disconnects and any flash
+ * failures we might encounter. Other errors are hard errors.
+ */
+ if (!g_error_matches (error,
+ MM_CONNECTION_ERROR,
+ MM_CONNECTION_ERROR_NO_CARRIER) &&
+ !g_error_matches (error,
+ MM_SERIAL_ERROR,
+ MM_SERIAL_ERROR_FLASH_FAILED)) {
+ /* Fatal */
+ g_simple_async_result_set_from_error (result, error);
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+ return;
+ }
+ mm_dbg ("Port flashing failed (not fatal): %s", error->message);
+ }
+
+ /* Port is disconnected; update the state. Note: implementations may
+ * already have set the port as disconnected (e.g the 3GPP one) */
+ mm_port_set_connected (MM_PORT (port), FALSE);
+
+ g_simple_async_result_set_op_res_gboolean (result, TRUE);
+ g_simple_async_result_complete (result);
+ g_object_unref (result);
+}
+
+static gboolean
+after_disconnect_sleep_cb (GSimpleAsyncResult *simple)
+{
+ GError *error = NULL;
+ MMAtSerialPort *primary;
+ MMBearer *self;
+ MMBaseModem *modem;
+
+ self = MM_BEARER (g_async_result_get_source_object (G_ASYNC_RESULT (simple)));
+ g_object_get (self,
+ MM_BEARER_MODEM, &modem,
+ NULL);
+ primary = mm_base_modem_get_port_primary (modem);
+
+ /* Propagate errors when reopening the port */
+ if (!mm_serial_port_open (MM_SERIAL_PORT (primary), &error)) {
+ g_simple_async_result_take_error (simple, error);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+ } else {
+ mm_serial_port_flash (MM_SERIAL_PORT (primary),
+ 1000,
+ TRUE,
+ (MMSerialFlashFn)primary_flash_ready,
+ simple);
+ }
+
+ g_object_unref (modem);
+ g_object_unref (self);
+ return FALSE;
+}
+
+static void
+disconnect (MMBearer *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ MMAtSerialPort *primary;
+ MMBaseModem *modem = NULL;
+ GSimpleAsyncResult *result;
+
+ g_object_get (self,
+ MM_BEARER_MODEM, &modem,
+ NULL);
+ g_assert (modem != NULL);
+ primary = mm_base_modem_get_port_primary (modem);
+ g_object_unref (modem);
+
+ if (!mm_port_get_connected (MM_PORT (primary))) {
+ g_simple_async_report_error_in_idle (
+ G_OBJECT (self),
+ callback,
+ user_data,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Couldn't disconnect Iridium: this bearer is not connected");
+ return;
+ }
+
+ /* Just flash the primary port */
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ disconnect);
+
+ /* When we enable the modem we kept one open count in the primary port.
+ * We now need to fully close that one, as if we were disabled, and reopen
+ * it again afterwards. */
+ mm_serial_port_close (MM_SERIAL_PORT (primary));
+ g_warn_if_fail (!mm_serial_port_is_open (MM_SERIAL_PORT (primary)));
+
+ mm_dbg ("Waiting some seconds before reopening the port...");
+ g_timeout_add_seconds (5, (GSourceFunc)after_disconnect_sleep_cb, result);
+}
+
+/*****************************************************************************/
+
+static gboolean
+cmp_properties (MMBearer *self,
+ MMCommonBearerProperties *properties)
+{
+ return (mm_common_bearer_properties_get_apn (properties) == NULL &&
+ mm_common_bearer_properties_get_ip_type (properties) == NULL &&
+ mm_common_bearer_properties_get_number (properties) == NULL &&
+ mm_common_bearer_properties_get_rm_protocol (properties) == MM_MODEM_CDMA_RM_PROTOCOL_UNKNOWN &&
+ mm_common_bearer_properties_get_allow_roaming (properties));
+}
+
+/*****************************************************************************/
+
+MMBearer *
+mm_bearer_iridium_new (MMBroadbandModemIridium *modem)
+{
+ MMBearer *bearer;
+
+ /* The Iridium bearer inherits from MMBearer (so it's not a MMBroadbandBearer)
+ * and that means that the object is not async-initable, so we just use
+ * g_object_get() here */
+ bearer = g_object_new (MM_TYPE_BEARER_IRIDIUM,
+ MM_BEARER_MODEM, modem,
+ "ip-timeout", MM_BEARER_IRIDIUM_IP_TIMEOUT_DEFAULT,
+ NULL);
+
+ /* Only export valid bearers */
+ mm_bearer_export (bearer);
+
+ return bearer;
+}
+
+static void
+mm_bearer_iridium_init (MMBearerIridium *self)
+{
+}
+
+static void
+mm_bearer_iridium_class_init (MMBearerIridiumClass *klass)
+{
+ MMBearerClass *bearer_class = MM_BEARER_CLASS (klass);
+
+ /* Virtual methods */
+ bearer_class->cmp_properties = cmp_properties;
+ bearer_class->connect = connect;
+ bearer_class->connect_finish = connect_finish;
+ bearer_class->disconnect = disconnect;
+ bearer_class->disconnect_finish = disconnect_finish;
+}
diff --git a/plugins/iridium/mm-bearer-iridium.h b/plugins/iridium/mm-bearer-iridium.h
new file mode 100644
index 00000000..ccb33072
--- /dev/null
+++ b/plugins/iridium/mm-bearer-iridium.h
@@ -0,0 +1,53 @@
+/* -*- 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:
+ *
+ * Author: Aleksander Morgado <aleksander@lanedo.com>
+ *
+ * Copyright (C) 2012 Ammonit Measurement GmbH.
+ */
+
+#ifndef MM_BEARER_IRIDIUM_H
+#define MM_BEARER_IRIDIUM_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <libmm-common.h>
+
+#include "mm-broadband-bearer.h"
+#include "mm-broadband-modem-iridium.h"
+
+#define MM_TYPE_BEARER_IRIDIUM (mm_bearer_iridium_get_type ())
+#define MM_BEARER_IRIDIUM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BEARER_IRIDIUM, MMBearerIridium))
+#define MM_BEARER_IRIDIUM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BEARER_IRIDIUM, MMBearerIridiumClass))
+#define MM_IS_BEARER_IRIDIUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BEARER_IRIDIUM))
+#define MM_IS_BEARER_IRIDIUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BEARER_IRIDIUM))
+#define MM_BEARER_IRIDIUM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BEARER_IRIDIUM, MMBearerIridiumClass))
+
+typedef struct _MMBearerIridium MMBearerIridium;
+typedef struct _MMBearerIridiumClass MMBearerIridiumClass;
+
+struct _MMBearerIridium {
+ MMBearer parent;
+};
+
+struct _MMBearerIridiumClass {
+ MMBearerClass parent;
+};
+
+GType mm_bearer_iridium_get_type (void);
+
+/* Iridium bearer creation implementation.
+ * NOTE it is *not* a broadband bearer, so not async-initable */
+MMBearer *mm_bearer_iridium_new (MMBroadbandModemIridium *modem);
+
+#endif /* MM_BEARER_IRIDIUM_H */
diff --git a/plugins/iridium/mm-broadband-modem-iridium.c b/plugins/iridium/mm-broadband-modem-iridium.c
new file mode 100644
index 00000000..bb5cdc47
--- /dev/null
+++ b/plugins/iridium/mm-broadband-modem-iridium.c
@@ -0,0 +1,486 @@
+/* -*- 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 - 2012 Ammonit Measurement GmbH
+ * 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-log.h"
+#include "mm-errors-types.h"
+#include "mm-base-modem-at.h"
+#include "mm-iface-modem.h"
+#include "mm-iface-modem-3gpp.h"
+#include "mm-iface-modem-messaging.h"
+#include "mm-broadband-modem-iridium.h"
+#include "mm-sim-iridium.h"
+#include "mm-bearer-iridium.h"
+#include "mm-modem-helpers.h"
+
+static void iface_modem_init (MMIfaceModem *iface);
+static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
+static void iface_modem_messaging_init (MMIfaceModemMessaging *iface);
+
+G_DEFINE_TYPE_EXTENDED (MMBroadbandModemIridium, mm_broadband_modem_iridium, MM_TYPE_BROADBAND_MODEM, 0,
+ G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
+ G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)
+ G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_MESSAGING, iface_modem_messaging_init));
+
+/*****************************************************************************/
+/* Initializing the modem (Modem interface) */
+
+static gboolean
+modem_init_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
+}
+
+static const MMBaseModemAtCommand modem_init_sequence[] = {
+ /* Init command */
+ { "E0 V1", 3, FALSE, NULL },
+ { "+CMEE=1", 3, FALSE, NULL },
+ { NULL }
+};
+
+static void
+init_sequence_ready (MMBroadbandModem *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *simple)
+{
+ GError *error = NULL;
+
+ mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, NULL, &error);
+ if (error)
+ g_simple_async_result_take_error (simple, error);
+ else
+ g_simple_async_result_set_op_res_gboolean (simple, TRUE);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+}
+
+static gboolean
+after_atz_sleep_cb (GSimpleAsyncResult *simple)
+{
+ MMBaseModem *self;
+
+ self = MM_BASE_MODEM (g_async_result_get_source_object (G_ASYNC_RESULT (simple)));
+ /* Now, run the remaining sequence */
+ mm_base_modem_at_sequence (self,
+ modem_init_sequence,
+ NULL, /* response_processor_context */
+ NULL, /* response_processor_context_free */
+ NULL, /* cancellable */
+ (GAsyncReadyCallback)init_sequence_ready,
+ simple);
+ g_object_unref (self);
+ return FALSE;
+}
+
+static void
+atz_ready (MMBroadbandModem *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *simple)
+{
+ GError *error = NULL;
+
+ mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
+ if (error) {
+ g_simple_async_result_take_error (simple, error);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+ return;
+ }
+
+ /* Once ATZ reply is received, we need to wait a bit before going on,
+ * otherwise, the next commands given will receive garbage as reply
+ * (500ms should be enough) */
+ g_timeout_add (500, (GSourceFunc)after_atz_sleep_cb, simple);
+}
+
+static void
+modem_init (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ modem_init);
+ /* First, send ATZ alone */
+ mm_base_modem_at_command (MM_BASE_MODEM (self),
+ "Z",
+ 3,
+ TRUE,
+ NULL, /* cancellable */
+ (GAsyncReadyCallback)atz_ready,
+ result);
+}
+
+/*****************************************************************************/
+/* Operator Code and Name loading (3GPP interface) */
+
+static gchar *
+load_operator_code_finish (MMIfaceModem3gpp *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ /* Only "90103" operator code is assumed */
+ return g_strdup ("90103");
+}
+
+static gchar *
+load_operator_name_finish (MMIfaceModem3gpp *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ /* Only "IRIDIUM" operator name is assumed */
+ return g_strdup ("IRIDIUM");
+}
+
+static void
+load_operator_name_or_code (MMIfaceModem3gpp *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ load_operator_name_or_code);
+ g_simple_async_result_set_op_res_gboolean (result, TRUE);
+ g_simple_async_result_complete_in_idle (result);
+ g_object_unref (result);
+}
+
+/*****************************************************************************/
+/* Enable unsolicited events (SMS indications) (Messaging interface) */
+
+static gboolean
+messaging_enable_unsolicited_events_finish (MMIfaceModemMessaging *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return !!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
+}
+
+static void
+messaging_enable_unsolicited_events (MMIfaceModemMessaging *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ /* AT+CNMI=<mode>,[<mt>[,<bm>[,<ds>[,<bfr>]]]]
+ * but <bm> can only be 0,
+ * and <ds> can only be either 0 or 1
+ *
+ * Note: Modem may return +CMS ERROR:322, which indicates Memory Full,
+ * not a big deal
+ */
+ mm_base_modem_at_command (MM_BASE_MODEM (self),
+ "+CNMI=2,1,0,0,1",
+ 3,
+ FALSE,
+ NULL, /* cancellable */
+ callback,
+ user_data);
+}
+
+/*****************************************************************************/
+/* Signal quality (Modem interface) */
+
+static guint
+load_signal_quality_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ gint quality = 0;
+ const gchar *result;
+
+ result = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
+ if (!result)
+ return 0;
+
+ /* Skip possible whitespaces after '+CSQF:' and before the response */
+ result = mm_strip_tag (result, "+CSQF:");
+ while (*result == ' ')
+ result++;
+
+ if (sscanf (result, "%d", &quality))
+ /* Normalize the quality. <rssi> is NOT given in dBs,
+ * given as a relative value between 0 and 5 */
+ quality = CLAMP (quality, 0, 5) * 100 / 5;
+ else
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Could not parse signal quality results");
+
+ return quality;
+}
+
+static void
+load_signal_quality (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ /* The iridium modem may have a huge delay to get signal quality if we pass
+ * AT+CSQ, so we'll default to use AT+CSQF, which is a fast version that
+ * returns right away the last signal quality value retrieved */
+ mm_base_modem_at_command (MM_BASE_MODEM (self),
+ "+CSQF",
+ 3,
+ FALSE,
+ NULL, /* cancellable */
+ callback,
+ user_data);
+}
+
+/*****************************************************************************/
+/* Flow control (Modem interface) */
+
+static gboolean
+setup_flow_control_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
+}
+
+static void
+setup_flow_control_ready (MMBroadbandModemIridium *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *operation_result)
+{
+ GError *error = NULL;
+
+ if (!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error))
+ /* Let the error be critical. We DO need RTS/CTS in order to have
+ * proper modem disabling. */
+ g_simple_async_result_take_error (operation_result, error);
+ else
+ g_simple_async_result_set_op_res_gboolean (operation_result, TRUE);
+
+ g_simple_async_result_complete (operation_result);
+ g_object_unref (operation_result);
+}
+
+static void
+setup_flow_control (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ setup_flow_control);
+
+ /* Enable RTS/CTS flow control.
+ * Other available values:
+ * AT&K0: Disable flow control
+ * AT&K3: RTS/CTS
+ * AT&K4: XOFF/XON
+ * AT&K6: Both RTS/CTS and XOFF/XON
+ */
+ mm_base_modem_at_command (MM_BASE_MODEM (self),
+ "&K3",
+ 3,
+ FALSE,
+ NULL, /* cancellable */
+ (GAsyncReadyCallback)setup_flow_control_ready,
+ result);
+}
+
+/*****************************************************************************/
+/* Create SIM (Modem inteface) */
+
+static MMSim *
+create_sim_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ return mm_sim_new_finish (res, error);
+}
+
+static void
+create_sim (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ /* New Iridium SIM */
+ mm_sim_iridium_new (MM_BASE_MODEM (self),
+ NULL, /* cancellable */
+ callback,
+ user_data);
+}
+
+/*****************************************************************************/
+/* Create Bearer (Modem interface) */
+
+static MMBearer *
+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 Iridium bearer created at DBus path '%s'", mm_bearer_get_path (bearer));
+
+ return g_object_ref (bearer);
+}
+
+static void
+create_bearer (MMIfaceModem *self,
+ MMCommonBearerProperties *properties,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ MMBearer *bearer;
+ GSimpleAsyncResult *result;
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ create_bearer);
+ /* We just create a MMBearerIridium
+ * Note that we do not need to use properties here */
+ mm_dbg ("Creating Iridium bearer...");
+ bearer = mm_bearer_iridium_new (MM_BROADBAND_MODEM_IRIDIUM (self));
+ g_simple_async_result_set_op_res_gpointer (result,
+ bearer,
+ (GDestroyNotify)g_object_unref);
+ g_simple_async_result_complete_in_idle (result);
+ g_object_unref (result);
+}
+
+/*****************************************************************************/
+
+static void
+setup_ports (MMBroadbandModem *self)
+{
+ /* Call parent's setup ports first always */
+ MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_iridium_parent_class)->setup_ports (self);
+
+ /* Set 9600 baudrate by default in the AT port */
+ mm_dbg ("Baudrate will be set to 9600 bps...");
+ g_object_set (G_OBJECT (mm_base_modem_get_port_primary (MM_BASE_MODEM (self))),
+ MM_SERIAL_PORT_BAUD, 9600,
+ NULL);
+}
+
+/*****************************************************************************/
+
+MMBroadbandModemIridium *
+mm_broadband_modem_iridium_new (const gchar *device,
+ const gchar *driver,
+ const gchar *plugin,
+ guint16 vendor_id,
+ guint16 product_id)
+{
+ return g_object_new (MM_TYPE_BROADBAND_MODEM_IRIDIUM,
+ 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,
+ /* Allow only up to 3 consecutive timeouts in the serial port */
+ MM_BASE_MODEM_MAX_TIMEOUTS, 3,
+ /* Only CS network is supported by the Iridium modem */
+ MM_IFACE_MODEM_3GPP_PS_NETWORK_SUPPORTED, FALSE,
+ MM_IFACE_MODEM_MESSAGING_SMS_MEM1_STORAGE, MM_SMS_STORAGE_SM,
+ MM_IFACE_MODEM_MESSAGING_SMS_MEM2_STORAGE, MM_SMS_STORAGE_SM,
+ MM_IFACE_MODEM_MESSAGING_SMS_MEM3_STORAGE, MM_SMS_STORAGE_SM,
+ NULL);
+}
+
+static void
+mm_broadband_modem_iridium_init (MMBroadbandModemIridium *self)
+{
+}
+
+static void
+iface_modem_init (MMIfaceModem *iface)
+{
+ /* Initialization */
+ iface->modem_init = modem_init;
+ iface->modem_init_finish = modem_init_finish;
+
+ /* Create Iridium-specific SIM and bearer*/
+ iface->create_sim = create_sim;
+ iface->create_sim_finish = create_sim_finish;
+ iface->create_bearer = create_bearer;
+ iface->create_bearer_finish = create_bearer_finish;
+
+ /* CSQF-based signal quality */
+ iface->load_signal_quality = load_signal_quality;
+ iface->load_signal_quality_finish = load_signal_quality_finish;
+
+ /* RTS/CTS flow control */
+ iface->setup_flow_control = setup_flow_control;
+ iface->setup_flow_control_finish = setup_flow_control_finish;
+
+ /* No need to power-up/power-down the modem */
+ iface->modem_power_up = NULL;
+ iface->modem_power_up_finish = NULL;
+ iface->modem_power_down = NULL;
+ iface->modem_power_down_finish = NULL;
+}
+
+static void
+iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
+{
+ /* Fixed operator code and name to be reported */
+ iface->load_operator_name = load_operator_name_or_code;
+ iface->load_operator_name_finish = load_operator_name_finish;
+ iface->load_operator_code = load_operator_name_or_code;
+ iface->load_operator_code_finish = load_operator_code_finish;
+
+ /* Don't try to scan networks with AT+COPS=?.
+ * It does work, but it will only reply about the Iridium network
+ * being found (so not very helpful, as that is the only one expected), but
+ * also, it will use a non-standard reply format. Instead of supporting that
+ * specific format used, just fully skip it.
+ * For reference, the result is:
+ * +COPS:(002),"IRIDIUM","IRIDIUM","90103",,(000-001),(000-002)
+ */
+ iface->scan_networks = NULL;
+ iface->scan_networks_finish = NULL;
+}
+
+static void
+iface_modem_messaging_init (MMIfaceModemMessaging *iface)
+{
+ iface->enable_unsolicited_events = messaging_enable_unsolicited_events;
+ iface->enable_unsolicited_events_finish = messaging_enable_unsolicited_events_finish;
+}
+
+static void
+mm_broadband_modem_iridium_class_init (MMBroadbandModemIridiumClass *klass)
+{
+ MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
+
+ broadband_modem_class->setup_ports = setup_ports;
+}
diff --git a/plugins/iridium/mm-broadband-modem-iridium.h b/plugins/iridium/mm-broadband-modem-iridium.h
new file mode 100644
index 00000000..941f82f0
--- /dev/null
+++ b/plugins/iridium/mm-broadband-modem-iridium.h
@@ -0,0 +1,49 @@
+/* -*- 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) 2008 - 2009 Novell, Inc.
+ * Copyright (C) 2009 - 2011 Red Hat, Inc.
+ * Copyright (C) 2011 Google Inc.
+ */
+
+#ifndef MM_BROADBAND_MODEM_IRIDIUM_H
+#define MM_BROADBAND_MODEM_IRIDIUM_H
+
+#include "mm-broadband-modem.h"
+
+#define MM_TYPE_BROADBAND_MODEM_IRIDIUM (mm_broadband_modem_iridium_get_type ())
+#define MM_BROADBAND_MODEM_IRIDIUM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_IRIDIUM, MMBroadbandModemIridium))
+#define MM_BROADBAND_MODEM_IRIDIUM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_IRIDIUM_AIRLINK, MMBroadbandModemIridiumClass))
+#define MM_IS_BROADBAND_MODEM_IRIDIUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_IRIDIUM_AIRLINK))
+#define MM_IS_BROADBAND_MODEM_IRIDIUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_IRIDIUM_AIRLINK))
+#define MM_BROADBAND_MODEM_IRIDIUM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_IRIDIUM_AIRLINK, MMBroadbandModemIridiumClass))
+
+typedef struct _MMBroadbandModemIridium MMBroadbandModemIridium;
+typedef struct _MMBroadbandModemIridiumClass MMBroadbandModemIridiumClass;
+
+struct _MMBroadbandModemIridium {
+ MMBroadbandModem parent;
+};
+
+struct _MMBroadbandModemIridiumClass{
+ MMBroadbandModemClass parent;
+};
+
+GType mm_broadband_modem_iridium_get_type (void);
+
+MMBroadbandModemIridium *mm_broadband_modem_iridium_new (const gchar *device,
+ const gchar *driver,
+ const gchar *plugin,
+ guint16 vendor_id,
+ guint16 product_id);
+
+#endif /* MM_BROADBAND_MODEM_IRIDIUM_H */
diff --git a/plugins/iridium/mm-plugin-iridium.c b/plugins/iridium/mm-plugin-iridium.c
new file mode 100644
index 00000000..ff522728
--- /dev/null
+++ b/plugins/iridium/mm-plugin-iridium.c
@@ -0,0 +1,127 @@
+/* -*- 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.
+ *
+<<<<<<< HEAD
+ * Copyright (C) 2011 Ammonit Measurement GmbH
+=======
+ * Copyright (C) 2011 - 2012 Ammonit Measurement GmbH
+>>>>>>> 4ce461e... iridium: start porting the Iridium plugin to the '06-api' codebase
+ * Author: Aleksander Morgado <aleksander@lanedo.com>
+ */
+
+#include <string.h>
+#include <gmodule.h>
+
+#include "mm-plugin-iridium.h"
+#include "mm-broadband-modem-iridium.h"
+#include "mm-errors-types.h"
+#include "mm-private-boxed-types.h"
+#include "mm-log.h"
+
+G_DEFINE_TYPE (MMPluginIridium, mm_plugin_iridium, 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, *driver;
+ guint16 vendor = 0, product = 0;
+
+ /* The Iridium 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);
+ driver = mm_port_probe_get_port_driver (probe);
+
+ /* 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. */
+ 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_iridium_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_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[] = { 0x1edd, 0 };
+ static const gchar *vendor_strings[] = { "iridium", NULL };
+ /* Also support motorola-branded Iridium modems */
+ static const mm_str_pair product_strings[] = {{"motorola", "satellite" },
+ { NULL, NULL }};
+
+ return MM_PLUGIN (
+ g_object_new (MM_TYPE_PLUGIN_IRIDIUM,
+ MM_PLUGIN_BASE_NAME, "Iridium",
+ MM_PLUGIN_BASE_ALLOWED_SUBSYSTEMS, subsystems,
+ MM_PLUGIN_BASE_ALLOWED_VENDOR_STRINGS, vendor_strings,
+ MM_PLUGIN_BASE_ALLOWED_PRODUCT_STRINGS, product_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_iridium_init (MMPluginIridium *self)
+{
+}
+
+static void
+mm_plugin_iridium_class_init (MMPluginIridiumClass *klass)
+{
+ MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
+
+ pb_class->grab_port = grab_port;
+}
diff --git a/plugins/iridium/mm-plugin-iridium.h b/plugins/iridium/mm-plugin-iridium.h
new file mode 100644
index 00000000..20706da7
--- /dev/null
+++ b/plugins/iridium/mm-plugin-iridium.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.
+ *
+ * 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 - 2012 Ammonit Measurement GmbH
+ * Author: Aleksander Morgado <aleksander@lanedo.com>
+ */
+
+#ifndef MM_PLUGIN_IRIDIUM_H
+#define MM_PLUGIN_IRIDIUM_H
+
+#include "mm-plugin-base.h"
+
+#define MM_TYPE_PLUGIN_IRIDIUM (mm_plugin_iridium_get_type ())
+#define MM_PLUGIN_IRIDIUM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_IRIDIUM, MMPluginIridium))
+#define MM_PLUGIN_IRIDIUM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_IRIDIUM, MMPluginIridiumClass))
+#define MM_IS_PLUGIN_IRIDIUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_IRIDIUM))
+#define MM_IS_PLUGIN_IRIDIUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_IRIDIUM))
+#define MM_PLUGIN_IRIDIUM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_IRIDIUM, MMPluginIridiumClass))
+
+typedef struct {
+ MMPluginBase parent;
+} MMPluginIridium;
+
+typedef struct {
+ MMPluginBaseClass parent;
+} MMPluginIridiumClass;
+
+GType mm_plugin_iridium_get_type (void);
+
+G_MODULE_EXPORT MMPlugin *mm_plugin_create (void);
+
+#endif /* MM_PLUGIN_IRIDIUM_H */
diff --git a/plugins/iridium/mm-sim-iridium.c b/plugins/iridium/mm-sim-iridium.c
new file mode 100644
index 00000000..519b6f90
--- /dev/null
+++ b/plugins/iridium/mm-sim-iridium.c
@@ -0,0 +1,87 @@
+/* -*- 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 - 2012 Ammonit Measurement GmbH.
+ * Author: Aleksander Morgado <aleksander@lanedo.com>
+ */
+
+#include <config.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <ModemManager.h>
+#include <libmm-common.h>
+
+#include "mm-sim-iridium.h"
+
+G_DEFINE_TYPE (MMSimIridium, mm_sim_iridium, MM_TYPE_SIM);
+
+/*****************************************************************************/
+
+MMSim *
+mm_sim_iridium_new_finish (GAsyncResult *res,
+ GError **error)
+{
+ GObject *source;
+ GObject *sim;
+
+ source = g_async_result_get_source_object (res);
+ sim = g_async_initable_new_finish (G_ASYNC_INITABLE (source), res, error);
+ g_object_unref (source);
+
+ if (!sim)
+ return NULL;
+
+ /* Only export valid SIMs */
+ mm_sim_export (MM_SIM (sim));
+
+ return MM_SIM (sim);
+}
+
+void
+mm_sim_iridium_new (MMBaseModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ g_async_initable_new_async (MM_TYPE_SIM_IRIDIUM,
+ G_PRIORITY_DEFAULT,
+ cancellable,
+ callback,
+ user_data,
+ MM_SIM_MODEM, modem,
+ NULL);
+}
+
+static void
+mm_sim_iridium_init (MMSimIridium *self)
+{
+}
+
+static void
+mm_sim_iridium_class_init (MMSimIridiumClass *klass)
+{
+ MMSimClass *sim_class = MM_SIM_CLASS (klass);
+
+ /* Skip querying the SIM card info, not supported by Iridium modems */
+ sim_class->load_sim_identifier = NULL;
+ sim_class->load_sim_identifier_finish = NULL;
+ sim_class->load_imsi = NULL;
+ sim_class->load_imsi_finish = NULL;
+ sim_class->load_operator_identifier = NULL;
+ sim_class->load_operator_identifier_finish = NULL;
+ sim_class->load_operator_name = NULL;
+ sim_class->load_operator_name_finish = NULL;
+}
diff --git a/plugins/iridium/mm-sim-iridium.h b/plugins/iridium/mm-sim-iridium.h
new file mode 100644
index 00000000..0150cb1e
--- /dev/null
+++ b/plugins/iridium/mm-sim-iridium.h
@@ -0,0 +1,52 @@
+/* -*- 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 - 2012 Ammonit Measurement GmbH.
+ * Author: Aleksander Morgado <aleksander@lanedo.com>
+ */
+
+#ifndef MM_SIM_IRIDIUM_H
+#define MM_SIM_IRIDIUM_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "mm-sim.h"
+
+#define MM_TYPE_SIM_IRIDIUM (mm_sim_iridium_get_type ())
+#define MM_SIM_IRIDIUM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SIM_IRIDIUM, MMSimIridium))
+#define MM_SIM_IRIDIUM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SIM_IRIDIUM, MMSimIridiumClass))
+#define MM_IS_SIM_IRIDIUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SIM_IRIDIUM))
+#define MM_IS_SIM_IRIDIUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SIM_IRIDIUM))
+#define MM_SIM_IRIDIUM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SIM_IRIDIUM, MMSimIridiumClass))
+
+typedef struct _MMSimIridium MMSimIridium;
+typedef struct _MMSimIridiumClass MMSimIridiumClass;
+
+struct _MMSimIridium {
+ MMSim parent;
+};
+
+struct _MMSimIridiumClass {
+ MMSimClass parent;
+};
+
+GType mm_sim_iridium_get_type (void);
+
+void mm_sim_iridium_new (MMBaseModem *modem,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+MMSim *mm_sim_iridium_new_finish (GAsyncResult *res,
+ GError **error);
+
+#endif /* MM_SIM_IRIDIUM_H */