mbim: add initial MBIM support skeleton
This commit is contained in:
@@ -249,6 +249,13 @@ endif
|
|||||||
|
|
||||||
# Additional MBIM support in ModemManager
|
# Additional MBIM support in ModemManager
|
||||||
if WITH_MBIM
|
if WITH_MBIM
|
||||||
|
ModemManager_SOURCES += \
|
||||||
|
mm-sim-mbim.h \
|
||||||
|
mm-sim-mbim.c \
|
||||||
|
mm-bearer-mbim.h \
|
||||||
|
mm-bearer-mbim.c \
|
||||||
|
mm-broadband-modem-mbim.h \
|
||||||
|
mm-broadband-modem-mbim.c
|
||||||
ModemManager_CPPFLAGS += $(MBIM_CFLAGS)
|
ModemManager_CPPFLAGS += $(MBIM_CFLAGS)
|
||||||
ModemManager_LDADD += $(MBIM_LIBS)
|
ModemManager_LDADD += $(MBIM_LIBS)
|
||||||
endif
|
endif
|
||||||
|
84
src/mm-bearer-mbim.c
Normal file
84
src/mm-bearer-mbim.c
Normal file
@@ -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 <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include <ModemManager.h>
|
||||||
|
#define _LIBMM_INSIDE_MM
|
||||||
|
#include <libmm-glib.h>
|
||||||
|
|
||||||
|
#include "mm-bearer-mbim.h"
|
||||||
|
#include "mm-log.h"
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (MMBearerMbim, mm_bearer_mbim, MM_TYPE_BEARER);
|
||||||
|
|
||||||
|
struct _MMBearerMbimPrivate {
|
||||||
|
gpointer dummy;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
MMBearer *
|
||||||
|
mm_bearer_mbim_new (MMBroadbandModemMbim *modem,
|
||||||
|
MMBearerProperties *config)
|
||||||
|
{
|
||||||
|
MMBearer *bearer;
|
||||||
|
|
||||||
|
/* The Mbim 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_new() here */
|
||||||
|
bearer = g_object_new (MM_TYPE_BEARER_MBIM,
|
||||||
|
MM_BEARER_MODEM, modem,
|
||||||
|
MM_BEARER_CONFIG, config,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
/* Only export valid bearers */
|
||||||
|
mm_bearer_export (bearer);
|
||||||
|
|
||||||
|
return bearer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_bearer_mbim_init (MMBearerMbim *self)
|
||||||
|
{
|
||||||
|
/* Initialize private data */
|
||||||
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
|
||||||
|
MM_TYPE_BEARER_MBIM,
|
||||||
|
MMBearerMbimPrivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dispose (GObject *object)
|
||||||
|
{
|
||||||
|
G_OBJECT_CLASS (mm_bearer_mbim_parent_class)->dispose (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_bearer_mbim_class_init (MMBearerMbimClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
g_type_class_add_private (object_class, sizeof (MMBearerMbimPrivate));
|
||||||
|
|
||||||
|
/* Virtual methods */
|
||||||
|
object_class->dispose = dispose;
|
||||||
|
}
|
55
src/mm-bearer-mbim.h
Normal file
55
src/mm-bearer-mbim.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/* -*- 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_BEARER_MBIM_H
|
||||||
|
#define MM_BEARER_MBIM_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#define _LIBMM_INSIDE_MM
|
||||||
|
#include <libmm-glib.h>
|
||||||
|
|
||||||
|
#include "mm-bearer.h"
|
||||||
|
#include "mm-broadband-modem-mbim.h"
|
||||||
|
|
||||||
|
#define MM_TYPE_BEARER_MBIM (mm_bearer_mbim_get_type ())
|
||||||
|
#define MM_BEARER_MBIM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BEARER_MBIM, MMBearerMbim))
|
||||||
|
#define MM_BEARER_MBIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BEARER_MBIM, MMBearerMbimClass))
|
||||||
|
#define MM_IS_BEARER_MBIM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BEARER_MBIM))
|
||||||
|
#define MM_IS_BEARER_MBIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BEARER_MBIM))
|
||||||
|
#define MM_BEARER_MBIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BEARER_MBIM, MMBearerMbimClass))
|
||||||
|
|
||||||
|
typedef struct _MMBearerMbim MMBearerMbim;
|
||||||
|
typedef struct _MMBearerMbimClass MMBearerMbimClass;
|
||||||
|
typedef struct _MMBearerMbimPrivate MMBearerMbimPrivate;
|
||||||
|
|
||||||
|
struct _MMBearerMbim {
|
||||||
|
MMBearer parent;
|
||||||
|
MMBearerMbimPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MMBearerMbimClass {
|
||||||
|
MMBearerClass parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType mm_bearer_mbim_get_type (void);
|
||||||
|
|
||||||
|
/* MBIM bearer creation implementation.
|
||||||
|
* NOTE it is *not* a broadband bearer, so not async-initable */
|
||||||
|
MMBearer *mm_bearer_mbim_new (MMBroadbandModemMbim *modem,
|
||||||
|
MMBearerProperties *config);
|
||||||
|
|
||||||
|
#endif /* MM_BEARER_MBIM_H */
|
348
src/mm-broadband-modem-mbim.c
Normal file
348
src/mm-broadband-modem-mbim.c
Normal file
@@ -0,0 +1,348 @@
|
|||||||
|
/* -*- 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 "mm-broadband-modem-mbim.h"
|
||||||
|
#include "mm-bearer-mbim.h"
|
||||||
|
#include "mm-sim-mbim.h"
|
||||||
|
|
||||||
|
#include "ModemManager.h"
|
||||||
|
#include "mm-log.h"
|
||||||
|
#include "mm-errors-types.h"
|
||||||
|
#include "mm-modem-helpers.h"
|
||||||
|
#include "mm-iface-modem.h"
|
||||||
|
|
||||||
|
static void iface_modem_init (MMIfaceModem *iface);
|
||||||
|
|
||||||
|
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbim, mm_broadband_modem_mbim, MM_TYPE_BROADBAND_MODEM, 0,
|
||||||
|
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init))
|
||||||
|
|
||||||
|
struct _MMBroadbandModemMbimPrivate {
|
||||||
|
gpointer dummy;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* 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 bearer created at DBus path '%s'", mm_bearer_get_path (bearer));
|
||||||
|
|
||||||
|
return g_object_ref (bearer);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
modem_create_bearer (MMIfaceModem *self,
|
||||||
|
MMBearerProperties *properties,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
MMBearer *bearer;
|
||||||
|
GSimpleAsyncResult *result;
|
||||||
|
|
||||||
|
/* Set a new ref to the bearer object as result */
|
||||||
|
result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
modem_create_bearer);
|
||||||
|
|
||||||
|
/* We just create a MMBearerMbim */
|
||||||
|
mm_dbg ("Creating MBIM bearer in MBIM modem");
|
||||||
|
bearer = mm_bearer_mbim_new (MM_BROADBAND_MODEM_MBIM (self),
|
||||||
|
properties);
|
||||||
|
|
||||||
|
g_simple_async_result_set_op_res_gpointer (result, bearer, g_object_unref);
|
||||||
|
g_simple_async_result_complete_in_idle (result);
|
||||||
|
g_object_unref (result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Create SIM (Modem interface) */
|
||||||
|
|
||||||
|
static MMSim *
|
||||||
|
create_sim_finish (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return mm_sim_mbim_new_finish (res, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
create_sim (MMIfaceModem *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
/* New MBIM SIM */
|
||||||
|
mm_sim_mbim_new (MM_BASE_MODEM (self),
|
||||||
|
NULL, /* cancellable */
|
||||||
|
callback,
|
||||||
|
user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* First enabling step */
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
enabling_started_finish (MMBroadbandModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parent_enabling_started_ready (MMBroadbandModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GSimpleAsyncResult *simple)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_mbim_parent_class)->enabling_started_finish (
|
||||||
|
self,
|
||||||
|
res,
|
||||||
|
&error)) {
|
||||||
|
/* Don't treat this as fatal. Parent enabling may fail if it cannot grab a primary
|
||||||
|
* AT port, which isn't really an issue in MBIM-based modems */
|
||||||
|
mm_dbg ("Couldn't start parent enabling: %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_simple_async_result_set_op_res_gboolean (simple, TRUE);
|
||||||
|
g_simple_async_result_complete (simple);
|
||||||
|
g_object_unref (simple);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
enabling_started (MMBroadbandModem *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GSimpleAsyncResult *result;
|
||||||
|
|
||||||
|
result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
enabling_started);
|
||||||
|
MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_mbim_parent_class)->enabling_started (
|
||||||
|
self,
|
||||||
|
(GAsyncReadyCallback)parent_enabling_started_ready,
|
||||||
|
result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* First initialization step */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MMBroadbandModem *self;
|
||||||
|
GSimpleAsyncResult *result;
|
||||||
|
MMMbimPort *mbim;
|
||||||
|
} InitializationStartedContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
initialization_started_context_complete_and_free (InitializationStartedContext *ctx)
|
||||||
|
{
|
||||||
|
g_simple_async_result_complete_in_idle (ctx->result);
|
||||||
|
if (ctx->mbim)
|
||||||
|
g_object_unref (ctx->mbim);
|
||||||
|
g_object_unref (ctx->result);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_slice_free (InitializationStartedContext, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
initialization_started_finish (MMBroadbandModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* Just parent's pointer passed here */
|
||||||
|
return g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parent_initialization_started_ready (MMBroadbandModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
InitializationStartedContext *ctx)
|
||||||
|
{
|
||||||
|
gpointer parent_ctx;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
parent_ctx = MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_mbim_parent_class)->initialization_started_finish (
|
||||||
|
self,
|
||||||
|
res,
|
||||||
|
&error);
|
||||||
|
if (error) {
|
||||||
|
/* Don't treat this as fatal. Parent initialization may fail if it cannot grab a primary
|
||||||
|
* AT port, which isn't really an issue in MBIM-based modems */
|
||||||
|
mm_dbg ("Couldn't start parent initialization: %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_simple_async_result_set_op_res_gpointer (ctx->result, parent_ctx, NULL);
|
||||||
|
initialization_started_context_complete_and_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parent_initialization_started (InitializationStartedContext *ctx)
|
||||||
|
{
|
||||||
|
MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_mbim_parent_class)->initialization_started (
|
||||||
|
ctx->self,
|
||||||
|
(GAsyncReadyCallback)parent_initialization_started_ready,
|
||||||
|
ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mbim_port_open_ready (MMMbimPort *mbim,
|
||||||
|
GAsyncResult *res,
|
||||||
|
InitializationStartedContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!mm_mbim_port_open_finish (mbim, res, &error)) {
|
||||||
|
g_simple_async_result_take_error (ctx->result, error);
|
||||||
|
initialization_started_context_complete_and_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Done we are, launch parent's callback */
|
||||||
|
parent_initialization_started (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
initialization_started (MMBroadbandModem *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
InitializationStartedContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_slice_new0 (InitializationStartedContext);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
initialization_started);
|
||||||
|
ctx->mbim = mm_base_modem_get_port_mbim (MM_BASE_MODEM (self));
|
||||||
|
|
||||||
|
/* This may happen if we unplug the modem unexpectedly */
|
||||||
|
if (!ctx->mbim) {
|
||||||
|
g_simple_async_result_set_error (ctx->result,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_FAILED,
|
||||||
|
"Cannot initialize: MBIM port went missing");
|
||||||
|
initialization_started_context_complete_and_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mm_mbim_port_is_open (ctx->mbim)) {
|
||||||
|
/* Nothing to be done, just launch parent's callback */
|
||||||
|
parent_initialization_started (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now open our MBIM port */
|
||||||
|
mm_mbim_port_open (ctx->mbim,
|
||||||
|
NULL,
|
||||||
|
(GAsyncReadyCallback)mbim_port_open_ready,
|
||||||
|
ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
MMBroadbandModemMbim *
|
||||||
|
mm_broadband_modem_mbim_new (const gchar *device,
|
||||||
|
const gchar **drivers,
|
||||||
|
const gchar *plugin,
|
||||||
|
guint16 vendor_id,
|
||||||
|
guint16 product_id)
|
||||||
|
{
|
||||||
|
return g_object_new (MM_TYPE_BROADBAND_MODEM_MBIM,
|
||||||
|
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_mbim_init (MMBroadbandModemMbim *self)
|
||||||
|
{
|
||||||
|
/* Initialize private data */
|
||||||
|
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
|
||||||
|
MM_TYPE_BROADBAND_MODEM_MBIM,
|
||||||
|
MMBroadbandModemMbimPrivate);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
finalize (GObject *object)
|
||||||
|
{
|
||||||
|
MMMbimPort *mbim;
|
||||||
|
MMBroadbandModemMbim *self = MM_BROADBAND_MODEM_MBIM (object);
|
||||||
|
|
||||||
|
mbim = mm_base_modem_peek_port_mbim (MM_BASE_MODEM (self));
|
||||||
|
/* If we did open the MBIM port during initialization, close it now */
|
||||||
|
if (mbim &&
|
||||||
|
mm_mbim_port_is_open (mbim)) {
|
||||||
|
mm_mbim_port_close (mbim);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (mm_broadband_modem_mbim_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
iface_modem_init (MMIfaceModem *iface)
|
||||||
|
{
|
||||||
|
/* Create MBIM-specific SIM */
|
||||||
|
iface->create_sim = create_sim;
|
||||||
|
iface->create_sim_finish = create_sim_finish;
|
||||||
|
|
||||||
|
/* Create MBIM-specific bearer */
|
||||||
|
iface->create_bearer = modem_create_bearer;
|
||||||
|
iface->create_bearer_finish = modem_create_bearer_finish;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_broadband_modem_mbim_class_init (MMBroadbandModemMbimClass *klass)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
|
||||||
|
|
||||||
|
g_type_class_add_private (object_class, sizeof (MMBroadbandModemMbimPrivate));
|
||||||
|
|
||||||
|
object_class->finalize = finalize;
|
||||||
|
|
||||||
|
broadband_modem_class->initialization_started = initialization_started;
|
||||||
|
broadband_modem_class->initialization_started_finish = initialization_started_finish;
|
||||||
|
broadband_modem_class->enabling_started = enabling_started;
|
||||||
|
broadband_modem_class->enabling_started_finish = enabling_started_finish;
|
||||||
|
/* Do not initialize the MBIM modem through AT commands */
|
||||||
|
broadband_modem_class->enabling_modem_init = NULL;
|
||||||
|
broadband_modem_class->enabling_modem_init_finish = NULL;
|
||||||
|
}
|
49
src/mm-broadband-modem-mbim.h
Normal file
49
src/mm-broadband-modem-mbim.h
Normal file
@@ -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) 2013 Aleksander Morgado <aleksander@gnu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MM_BROADBAND_MODEM_MBIM_H
|
||||||
|
#define MM_BROADBAND_MODEM_MBIM_H
|
||||||
|
|
||||||
|
#include "mm-broadband-modem.h"
|
||||||
|
|
||||||
|
#define MM_TYPE_BROADBAND_MODEM_MBIM (mm_broadband_modem_mbim_get_type ())
|
||||||
|
#define MM_BROADBAND_MODEM_MBIM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_MBIM, MMBroadbandModemMbim))
|
||||||
|
#define MM_BROADBAND_MODEM_MBIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_MBIM, MMBroadbandModemMbimClass))
|
||||||
|
#define MM_IS_BROADBAND_MODEM_MBIM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_MBIM))
|
||||||
|
#define MM_IS_BROADBAND_MODEM_MBIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_MBIM))
|
||||||
|
#define MM_BROADBAND_MODEM_MBIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_MBIM, MMBroadbandModemMbimClass))
|
||||||
|
|
||||||
|
typedef struct _MMBroadbandModemMbim MMBroadbandModemMbim;
|
||||||
|
typedef struct _MMBroadbandModemMbimClass MMBroadbandModemMbimClass;
|
||||||
|
typedef struct _MMBroadbandModemMbimPrivate MMBroadbandModemMbimPrivate;
|
||||||
|
|
||||||
|
struct _MMBroadbandModemMbim {
|
||||||
|
MMBroadbandModem parent;
|
||||||
|
MMBroadbandModemMbimPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MMBroadbandModemMbimClass{
|
||||||
|
MMBroadbandModemClass parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType mm_broadband_modem_mbim_get_type (void);
|
||||||
|
|
||||||
|
MMBroadbandModemMbim *mm_broadband_modem_mbim_new (const gchar *device,
|
||||||
|
const gchar **drivers,
|
||||||
|
const gchar *plugin,
|
||||||
|
guint16 vendor_id,
|
||||||
|
guint16 product_id);
|
||||||
|
|
||||||
|
#endif /* MM_BROADBAND_MODEM_MBIM_H */
|
77
src/mm-sim-mbim.c
Normal file
77
src/mm-sim-mbim.c
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
/* -*- 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 <ModemManager.h>
|
||||||
|
#define _LIBMM_INSIDE_MM
|
||||||
|
#include <libmm-glib.h>
|
||||||
|
|
||||||
|
#include "mm-log.h"
|
||||||
|
#include "mm-sim-mbim.h"
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (MMSimMbim, mm_sim_mbim, MM_TYPE_SIM)
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
MMSim *
|
||||||
|
mm_sim_mbim_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_mbim_new (MMBaseModem *modem,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_async_initable_new_async (MM_TYPE_SIM_MBIM,
|
||||||
|
G_PRIORITY_DEFAULT,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
MM_SIM_MODEM, modem,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_sim_mbim_init (MMSimMbim *self)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
mm_sim_mbim_class_init (MMSimMbimClass *klass)
|
||||||
|
{
|
||||||
|
}
|
51
src/mm-sim-mbim.h
Normal file
51
src/mm-sim-mbim.h
Normal file
@@ -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) 2013 Aleksander Morgado <aleksander@gnu.org>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MM_SIM_MBIM_H
|
||||||
|
#define MM_SIM_MBIM_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
#include "mm-sim.h"
|
||||||
|
|
||||||
|
#define MM_TYPE_SIM_MBIM (mm_sim_mbim_get_type ())
|
||||||
|
#define MM_SIM_MBIM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SIM_MBIM, MMSimMbim))
|
||||||
|
#define MM_SIM_MBIM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_SIM_MBIM, MMSimMbimClass))
|
||||||
|
#define MM_IS_SIM_MBIM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SIM_MBIM))
|
||||||
|
#define MM_IS_SIM_MBIM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_SIM_MBIM))
|
||||||
|
#define MM_SIM_MBIM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_SIM_MBIM, MMSimMbimClass))
|
||||||
|
|
||||||
|
typedef struct _MMSimMbim MMSimMbim;
|
||||||
|
typedef struct _MMSimMbimClass MMSimMbimClass;
|
||||||
|
|
||||||
|
struct _MMSimMbim {
|
||||||
|
MMSim parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MMSimMbimClass {
|
||||||
|
MMSimClass parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType mm_sim_mbim_get_type (void);
|
||||||
|
|
||||||
|
void mm_sim_mbim_new (MMBaseModem *modem,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
MMSim *mm_sim_mbim_new_finish (GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
#endif /* MM_SIM_MBIM_H */
|
Reference in New Issue
Block a user