build: move plugins directory to src/plugins
We are going to allow including the plugin sources built within the ModemManager daemon binary; moving the sources within the daemon sources directory makes it easier.
This commit is contained in:
committed by
Aleksander Morgado
parent
072d7ac906
commit
e14b904cbd
@@ -0,0 +1,109 @@
|
||||
# do not edit this file, it will be overwritten on update
|
||||
ACTION!="add|change|move|bind", GOTO="mm_fibocom_port_types_end"
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2cb7", GOTO="mm_fibocom_port_types"
|
||||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1782", GOTO="mm_fibocom_port_types"
|
||||
GOTO="mm_fibocom_port_types_end"
|
||||
|
||||
LABEL="mm_fibocom_port_types"
|
||||
|
||||
SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="?*", ENV{.MM_USBIFNUM}="$attr{bInterfaceNumber}"
|
||||
|
||||
# Fibocom L850-GL attach APN with toggle modem power
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0007", ENV{ID_MM_FIBOCOM_INITIAL_EPS_OFF_ON}="1"
|
||||
|
||||
# Fibocom L850-GL
|
||||
# ttyACM0 (if #2): AT port
|
||||
# ttyACM1 (if #4): debug port (ignore)
|
||||
# ttyACM2 (if #6): AT port
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0007", ENV{.MM_USBIFNUM}=="04", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
|
||||
# Fibocom NL668-AM
|
||||
# ttyACM0 (if #2): AT port
|
||||
# ttyACM1 (if #3): AT port
|
||||
# ttyACM2 (if #4): debug port (ignore)
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a0", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a0", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a0", ENV{.MM_USBIFNUM}=="04", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
|
||||
# Fibocom FM150
|
||||
# ttyUSB0 (if #0): QCDM port
|
||||
# ttyUSB1 (if #1): AT port
|
||||
# ttyUSB2 (if #2): AT port
|
||||
# ttyUSB2 (if #3): Ignore
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0104", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_QCDM}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0104", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0104", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0104", ENV{.MM_USBIFNUM}=="03", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
|
||||
# Fibocom FM101-GL (MBIM)
|
||||
# ttyUSB0 (if #2): AT port
|
||||
# ttyUSB1 (if #3): AT port
|
||||
# ttyUSB2 (if #4): debug port (ignore)
|
||||
# ttyUSB3 (if #5): debug port (ignore)
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a2", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a2", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a2", ENV{.MM_USBIFNUM}=="04", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a2", ENV{.MM_USBIFNUM}=="05", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
|
||||
# Fibocom FM101-GL (ADB)
|
||||
# ttyUSB0 (if #2): debug port (ignore)
|
||||
# ttyUSB1 (if #3): AT port
|
||||
# ttyUSB2 (if #4): debug port (ignore)
|
||||
# ttyUSB3 (if #5): debug port (ignore)
|
||||
# ttyUSB4 (if #6): debug port (ignore)
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a4", ENV{.MM_USBIFNUM}=="02", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a4", ENV{.MM_USBIFNUM}=="03", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a4", ENV{.MM_USBIFNUM}=="04", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a4", ENV{.MM_USBIFNUM}=="05", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="01a4", ENV{.MM_USBIFNUM}=="06", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
|
||||
|
||||
# Fibocom MA510-GL (GTUSBMODE=31)
|
||||
# ttyUSB0 (if #0): debug port (ignore)
|
||||
# ttyUSB1 (if #1): AT port
|
||||
# ttyUSB2 (if #2): AT port
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0106", ENV{.MM_USBIFNUM}=="00", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0106", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0106", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="0106", ENV{ID_MM_FIBOCOM_INITIAL_EPS_CID}="1"
|
||||
|
||||
# Fibocom MA510-GL (GTUSBMODE=32)
|
||||
# ttyUSB1 (if #0): AT port
|
||||
# ttyUSB2 (if #1): AT port
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="010a", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="010a", ENV{.MM_USBIFNUM}=="01", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
ATTRS{idVendor}=="2cb7", ATTRS{idProduct}=="010a", ENV{ID_MM_FIBOCOM_INITIAL_EPS_CID}="1"
|
||||
|
||||
# Fibocom L610 (GTUSBMODE=31)
|
||||
# ttyUSB0 (if #0): AT port
|
||||
# ttyUSB1 (if #1): NV
|
||||
# ttyUSB2 (if #2): MOS
|
||||
# ttyUSB3 (if #3): Diagnostic
|
||||
# ttyUSB4 (if #4): Logging
|
||||
# ttyUSB5 (if #5): AT port
|
||||
# ttyUSB6 (if #6): AT port
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d10", ENV{.MM_USBIFNUM}=="00", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d10", ENV{.MM_USBIFNUM}=="01", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d10", ENV{.MM_USBIFNUM}=="02", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d10", ENV{.MM_USBIFNUM}=="03", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d10", ENV{.MM_USBIFNUM}=="04", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d10", ENV{.MM_USBIFNUM}=="05", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d10", ENV{.MM_USBIFNUM}=="06", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
|
||||
# Fibocom L610 (GTUSBMODE={32,33} - ECM/RNDIS)
|
||||
# ttyUSB0 (if #2): AT port
|
||||
# ttyUSB1 (if #3): NV
|
||||
# ttyUSB2 (if #4): MOS
|
||||
# ttyUSB3 (if #5): Diagnostic
|
||||
# ttyUSB4 (if #6): Logging
|
||||
# ttyUSB5 (if #7): AT port
|
||||
# ttyUSB6 (if #8): AT port
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d11", ENV{.MM_USBIFNUM}=="02", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_PRIMARY}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d11", ENV{.MM_USBIFNUM}=="03", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d11", ENV{.MM_USBIFNUM}=="04", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d11", ENV{.MM_USBIFNUM}=="05", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d11", ENV{.MM_USBIFNUM}=="06", ENV{ID_MM_PORT_IGNORE}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d11", ENV{.MM_USBIFNUM}=="07", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
ATTRS{idVendor}=="1782", ATTRS{idProduct}=="4d11", ENV{.MM_USBIFNUM}=="08", SUBSYSTEM=="tty", ENV{ID_MM_PORT_TYPE_AT_SECONDARY}="1"
|
||||
|
||||
LABEL="mm_fibocom_port_types_end"
|
||||
@@ -0,0 +1,540 @@
|
||||
/* -*- 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) 2022 Disruptive Technologies Research AS
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "mm-broadband-bearer-fibocom-ecm.h"
|
||||
#include "mm-broadband-modem-fibocom.h"
|
||||
#include "mm-base-modem-at.h"
|
||||
#include "mm-iface-modem-3gpp.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
G_DEFINE_TYPE (MMBroadbandBearerFibocomEcm, mm_broadband_bearer_fibocom_ecm, MM_TYPE_BROADBAND_BEARER)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Common helper functions */
|
||||
|
||||
static gboolean
|
||||
parse_gtrndis_read_response (const gchar *response,
|
||||
guint *state,
|
||||
guint *cid,
|
||||
GError **error)
|
||||
{
|
||||
g_autoptr(GRegex) r = NULL;
|
||||
g_autoptr(GMatchInfo) match_info = NULL;
|
||||
|
||||
r = g_regex_new ("\\+GTRNDIS:\\s*(\\d+)(?:,(\\d+))?",
|
||||
G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW, 0, NULL);
|
||||
g_assert (r != NULL);
|
||||
|
||||
if (!g_regex_match (r, response, 0, &match_info)) {
|
||||
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Invalid +GTRNDIS response: %s", response);
|
||||
return FALSE;
|
||||
}
|
||||
if (!mm_get_uint_from_match_info (match_info, 1, state)) {
|
||||
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Failed to match state in +GTRNDIS response: %s", response);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (*state) {
|
||||
if (!mm_get_uint_from_match_info (match_info, 2, cid)) {
|
||||
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Failed to match cid in +GTRNDIS response: %s", response);
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
*cid = 0;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Connection status monitoring */
|
||||
|
||||
static MMBearerConnectionStatus
|
||||
load_connection_status_finish (MMBaseBearer *bearer,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
GError *inner_error = NULL;
|
||||
gssize value;
|
||||
|
||||
value = g_task_propagate_int (G_TASK (res), &inner_error);
|
||||
if (inner_error) {
|
||||
g_propagate_error (error, inner_error);
|
||||
return MM_BEARER_CONNECTION_STATUS_UNKNOWN;
|
||||
}
|
||||
return (MMBearerConnectionStatus) value;
|
||||
}
|
||||
|
||||
static void
|
||||
gtrndis_query_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
MMBaseBearer *bearer;
|
||||
GError *error = NULL;
|
||||
const gchar *result;
|
||||
guint state;
|
||||
guint cid;
|
||||
|
||||
bearer = g_task_get_source_object (task);
|
||||
result = mm_base_modem_at_command_finish (modem, res, &error);
|
||||
if (!result)
|
||||
g_task_return_error (task, error);
|
||||
else if (!parse_gtrndis_read_response (result, &state, &cid, &error))
|
||||
g_task_return_error (task, error);
|
||||
else if (!state || (gint) cid != mm_base_bearer_get_profile_id (bearer))
|
||||
g_task_return_int (task, MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
|
||||
else
|
||||
g_task_return_int (task, MM_BEARER_CONNECTION_STATUS_CONNECTED);
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
load_connection_status (MMBaseBearer *bearer,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
MMBaseModem *modem = NULL;
|
||||
|
||||
task = g_task_new (bearer, NULL, callback, user_data);
|
||||
|
||||
g_object_get (MM_BASE_BEARER (bearer),
|
||||
MM_BASE_BEARER_MODEM, &modem,
|
||||
NULL);
|
||||
|
||||
mm_base_modem_at_command (modem,
|
||||
"+GTRNDIS?",
|
||||
3,
|
||||
FALSE,
|
||||
(GAsyncReadyCallback) gtrndis_query_ready,
|
||||
task);
|
||||
g_object_unref (modem);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 3GPP Connect */
|
||||
|
||||
typedef struct {
|
||||
MMBroadbandModem *modem;
|
||||
MMPortSerialAt *primary;
|
||||
MMPortSerialAt *secondary;
|
||||
MMBearerIpFamily ip_family;
|
||||
} ConnectContext;
|
||||
|
||||
static void
|
||||
connect_context_free (ConnectContext *ctx)
|
||||
{
|
||||
g_clear_object (&ctx->modem);
|
||||
g_clear_object (&ctx->primary);
|
||||
g_clear_object (&ctx->secondary);
|
||||
g_slice_free (ConnectContext, ctx);
|
||||
}
|
||||
|
||||
static MMBearerConnectResult *
|
||||
connect_3gpp_finish (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_connect_3gpp_ready (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
MMBearerConnectResult *result;
|
||||
|
||||
result = MM_BROADBAND_BEARER_CLASS (mm_broadband_bearer_fibocom_ecm_parent_class)->connect_3gpp_finish (self, res, &error);
|
||||
if (result)
|
||||
g_task_return_pointer (task, result, (GDestroyNotify) mm_bearer_connect_result_unref);
|
||||
else
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_3gpp_ready (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gboolean result;
|
||||
ConnectContext *ctx;
|
||||
|
||||
result = MM_BROADBAND_BEARER_GET_CLASS (self)->disconnect_3gpp_finish (self, res, &error);
|
||||
if (!result) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = g_task_get_task_data (task);
|
||||
MM_BROADBAND_BEARER_CLASS (mm_broadband_bearer_fibocom_ecm_parent_class)->connect_3gpp (
|
||||
self,
|
||||
ctx->modem,
|
||||
ctx->primary,
|
||||
ctx->secondary,
|
||||
g_task_get_cancellable (task),
|
||||
(GAsyncReadyCallback) parent_connect_3gpp_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
static void
|
||||
gtrndis_check_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
MMBroadbandBearer *self;
|
||||
ConnectContext *ctx;
|
||||
GError *error = NULL;
|
||||
const gchar *response;
|
||||
guint state;
|
||||
guint cid;
|
||||
|
||||
self = g_task_get_source_object (task);
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
response = mm_base_modem_at_command_finish (modem, res, &error);
|
||||
if (!response) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!parse_gtrndis_read_response (response, &state, &cid, &error)) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
if (state) {
|
||||
/* RNDIS is already active, disconnect first. */
|
||||
mm_obj_dbg (self, "RNDIS active, tearing down existing connection...");
|
||||
MM_BROADBAND_BEARER_GET_CLASS (self)->disconnect_3gpp (
|
||||
MM_BROADBAND_BEARER (self),
|
||||
ctx->modem,
|
||||
ctx->primary,
|
||||
ctx->secondary,
|
||||
NULL, /* data port */
|
||||
cid,
|
||||
(GAsyncReadyCallback) disconnect_3gpp_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Execute the regular connection flow if RNDIS is inactive. */
|
||||
mm_obj_dbg (self, "RNDIS inactive");
|
||||
MM_BROADBAND_BEARER_CLASS (mm_broadband_bearer_fibocom_ecm_parent_class)->connect_3gpp (
|
||||
MM_BROADBAND_BEARER (self),
|
||||
ctx->modem,
|
||||
ctx->primary,
|
||||
ctx->secondary,
|
||||
g_task_get_cancellable (task),
|
||||
(GAsyncReadyCallback) parent_connect_3gpp_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
static void
|
||||
connect_3gpp (MMBroadbandBearer *self,
|
||||
MMBroadbandModem *modem,
|
||||
MMPortSerialAt *primary,
|
||||
MMPortSerialAt *secondary,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
ConnectContext *ctx;
|
||||
GTask *task;
|
||||
|
||||
ctx = g_slice_new0 (ConnectContext);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->secondary = secondary ? g_object_ref (secondary) : NULL;
|
||||
ctx->ip_family = mm_bearer_properties_get_ip_type (mm_base_bearer_peek_config (MM_BASE_BEARER (self)));
|
||||
mm_3gpp_normalize_ip_family (&ctx->ip_family);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, ctx, (GDestroyNotify) connect_context_free);
|
||||
|
||||
/* First, we must check whether RNDIS is already active */
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (modem),
|
||||
"+GTRNDIS?",
|
||||
3,
|
||||
FALSE, /* allow_cached */
|
||||
(GAsyncReadyCallback) gtrndis_check_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Dial context and task */
|
||||
|
||||
typedef struct {
|
||||
MMBroadbandModem *modem;
|
||||
MMPortSerialAt *primary;
|
||||
guint cid;
|
||||
MMPort *data;
|
||||
} DialContext;
|
||||
|
||||
static void
|
||||
dial_task_free (DialContext *ctx)
|
||||
{
|
||||
g_object_unref (ctx->modem);
|
||||
g_object_unref (ctx->primary);
|
||||
if (ctx->data)
|
||||
g_object_unref (ctx->data);
|
||||
g_slice_free (DialContext, ctx);
|
||||
}
|
||||
|
||||
static GTask *
|
||||
dial_task_new (MMBroadbandBearerFibocomEcm *self,
|
||||
MMBroadbandModem *modem,
|
||||
MMPortSerialAt *primary,
|
||||
guint cid,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
DialContext *ctx;
|
||||
GTask *task;
|
||||
|
||||
ctx = g_slice_new0 (DialContext);
|
||||
ctx->modem = g_object_ref (modem);
|
||||
ctx->primary = g_object_ref (primary);
|
||||
ctx->cid = cid;
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_task_data (task, ctx, (GDestroyNotify) dial_task_free);
|
||||
|
||||
ctx->data = mm_base_modem_get_best_data_port (MM_BASE_MODEM (modem), MM_PORT_TYPE_NET);
|
||||
if (!ctx->data) {
|
||||
g_task_return_new_error (task,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_NOT_FOUND,
|
||||
"No valid data port found to launch connection");
|
||||
g_object_unref (task);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 3GPP Dialing (sub-step of the 3GPP Connection sequence) */
|
||||
|
||||
static MMPort *
|
||||
dial_3gpp_finish (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
gtrndis_verify_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
DialContext *ctx;
|
||||
GError *error = NULL;
|
||||
const gchar *response;
|
||||
|
||||
ctx = g_task_get_task_data (task);
|
||||
response = mm_base_modem_at_command_finish (modem, res, &error);
|
||||
|
||||
if (!response)
|
||||
g_task_return_error (task, error);
|
||||
else {
|
||||
response = mm_strip_tag (response, "+GTRNDIS:");
|
||||
if (strtol (response, NULL, 10) != 1)
|
||||
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"Connection status verification failed");
|
||||
else
|
||||
g_task_return_pointer (task, g_object_ref (ctx->data), g_object_unref);
|
||||
}
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
gtrndis_activate_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!mm_base_modem_at_command_finish (modem, res, &error)) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_base_modem_at_command (modem,
|
||||
"+GTRNDIS?",
|
||||
6, /* timeout [s] */
|
||||
FALSE, /* allow_cached */
|
||||
(GAsyncReadyCallback) gtrndis_verify_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
static void
|
||||
dial_3gpp (MMBroadbandBearer *self,
|
||||
MMBaseModem *modem,
|
||||
MMPortSerialAt *primary,
|
||||
guint cid,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
g_autofree gchar *cmd = NULL;
|
||||
|
||||
task = dial_task_new (MM_BROADBAND_BEARER_FIBOCOM_ECM (self),
|
||||
MM_BROADBAND_MODEM (modem),
|
||||
primary,
|
||||
cid,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data);
|
||||
if (!task)
|
||||
return;
|
||||
|
||||
cmd = g_strdup_printf ("+GTRNDIS=1,%u", cid);
|
||||
mm_base_modem_at_command (modem,
|
||||
cmd,
|
||||
MM_BASE_BEARER_DEFAULT_CONNECTION_TIMEOUT,
|
||||
FALSE, /* allow_cached */
|
||||
(GAsyncReadyCallback) gtrndis_activate_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 3GPP Disconnect sequence */
|
||||
|
||||
static gboolean
|
||||
disconnect_3gpp_finish (MMBroadbandBearer *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
gtrndis_deactivate_ready (MMBaseModem *modem,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!mm_base_modem_at_command_finish (modem, res, &error))
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
disconnect_3gpp (MMBroadbandBearer *self,
|
||||
MMBroadbandModem *modem,
|
||||
MMPortSerialAt *primary,
|
||||
MMPortSerialAt *secondary,
|
||||
MMPort *data,
|
||||
guint cid,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
g_autofree gchar *cmd = NULL;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
cmd = g_strdup_printf ("+GTRNDIS=0,%u", cid);
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (modem),
|
||||
cmd,
|
||||
MM_BASE_BEARER_DEFAULT_DISCONNECTION_TIMEOUT,
|
||||
FALSE, /* allow_cached */
|
||||
(GAsyncReadyCallback) gtrndis_deactivate_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBaseBearer *
|
||||
mm_broadband_bearer_fibocom_ecm_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_base_bearer_export (MM_BASE_BEARER (bearer));
|
||||
|
||||
return MM_BASE_BEARER (bearer);
|
||||
}
|
||||
|
||||
void
|
||||
mm_broadband_bearer_fibocom_ecm_new (MMBroadbandModemFibocom *modem,
|
||||
MMBearerProperties *config,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_async_initable_new_async (
|
||||
MM_TYPE_BROADBAND_BEARER_FIBOCOM_ECM,
|
||||
G_PRIORITY_DEFAULT,
|
||||
cancellable,
|
||||
callback,
|
||||
user_data,
|
||||
MM_BASE_BEARER_MODEM, modem,
|
||||
MM_BASE_BEARER_CONFIG, config,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_bearer_fibocom_ecm_init (MMBroadbandBearerFibocomEcm *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_bearer_fibocom_ecm_class_init (MMBroadbandBearerFibocomEcmClass *klass)
|
||||
{
|
||||
MMBaseBearerClass *base_bearer_class = MM_BASE_BEARER_CLASS (klass);
|
||||
MMBroadbandBearerClass *broadband_bearer_class = MM_BROADBAND_BEARER_CLASS (klass);
|
||||
|
||||
base_bearer_class->load_connection_status = load_connection_status;
|
||||
base_bearer_class->load_connection_status_finish = load_connection_status_finish;
|
||||
|
||||
broadband_bearer_class->connect_3gpp = connect_3gpp;
|
||||
broadband_bearer_class->connect_3gpp_finish = connect_3gpp_finish;
|
||||
broadband_bearer_class->dial_3gpp = dial_3gpp;
|
||||
broadband_bearer_class->dial_3gpp_finish = dial_3gpp_finish;
|
||||
broadband_bearer_class->disconnect_3gpp = disconnect_3gpp;
|
||||
broadband_bearer_class->disconnect_3gpp_finish = disconnect_3gpp_finish;
|
||||
}
|
||||
@@ -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) 2022 Disruptive Technologies Research AS
|
||||
*/
|
||||
|
||||
#ifndef MM_BROADBAND_BEARER_FIBOCOM_ECM_H
|
||||
#define MM_BROADBAND_BEARER_FIBOCOM_ECM_H
|
||||
|
||||
#include "mm-broadband-bearer.h"
|
||||
#include "mm-broadband-modem-fibocom.h"
|
||||
|
||||
#define MM_TYPE_BROADBAND_BEARER_FIBOCOM_ECM (mm_broadband_bearer_fibocom_ecm_get_type ())
|
||||
#define MM_BROADBAND_BEARER_FIBOCOM_ECM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_BEARER_FIBOCOM_ECM, MMBroadbandBearerFibocomEcm))
|
||||
#define MM_BROADBAND_BEARER_FIBOCOM_ECM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_BEARER_FIBOCOM_ECM, MMBroadbandBearerFibocomEcmClass))
|
||||
#define MM_IS_BROADBAND_BEARER_FIBOCOM_ECM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_BEARER_FIBOCOM_ECM))
|
||||
#define MM_IS_BROADBAND_BEARER_FIBOCOM_ECM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_BEARER_FIBOCOM_ECM))
|
||||
#define MM_BROADBAND_BEARER_FIBOCOM_ECM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_BEARER_FIBOCOM_ECM, MMBroadbandBearerFibocomEcmClass))
|
||||
|
||||
typedef struct _MMBroadbandBearerFibocomEcm MMBroadbandBearerFibocomEcm;
|
||||
typedef struct _MMBroadbandBearerFibocomEcmClass MMBroadbandBearerFibocomEcmClass;
|
||||
|
||||
struct _MMBroadbandBearerFibocomEcm {
|
||||
MMBroadbandBearer parent;
|
||||
};
|
||||
|
||||
struct _MMBroadbandBearerFibocomEcmClass {
|
||||
MMBroadbandBearerClass parent;
|
||||
};
|
||||
|
||||
GType mm_broadband_bearer_fibocom_ecm_get_type (void);
|
||||
|
||||
void mm_broadband_bearer_fibocom_ecm_new (MMBroadbandModemFibocom *modem,
|
||||
MMBearerProperties *properties,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
MMBaseBearer *mm_broadband_bearer_fibocom_ecm_new_finish (GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
#endif /* MM_BROADBAND_BEARER_FIBOCOM_ECM_H */
|
||||
@@ -0,0 +1,763 @@
|
||||
/* -*- 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) 2022 Disruptive Technologies Research AS
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "mm-broadband-modem-fibocom.h"
|
||||
#include "mm-broadband-bearer-fibocom-ecm.h"
|
||||
#include "mm-broadband-modem.h"
|
||||
#include "mm-base-modem-at.h"
|
||||
#include "mm-iface-modem.h"
|
||||
#include "mm-iface-modem-3gpp.h"
|
||||
#include "mm-iface-modem-3gpp-profile-manager.h"
|
||||
#include "mm-log.h"
|
||||
|
||||
static void iface_modem_init (MMIfaceModem *iface);
|
||||
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
|
||||
static void iface_modem_3gpp_profile_manager_init (MMIfaceModem3gppProfileManager *iface);
|
||||
|
||||
static MMIfaceModem3gppProfileManager *iface_modem_3gpp_profile_manager_parent;
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemFibocom, mm_broadband_modem_fibocom, 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_3GPP_PROFILE_MANAGER, iface_modem_3gpp_profile_manager_init))
|
||||
|
||||
typedef enum {
|
||||
FEATURE_SUPPORT_UNKNOWN,
|
||||
FEATURE_NOT_SUPPORTED,
|
||||
FEATURE_SUPPORTED,
|
||||
} FeatureSupport;
|
||||
|
||||
struct _MMBroadbandModemFibocomPrivate {
|
||||
FeatureSupport gtrndis_support;
|
||||
GRegex *sim_ready_regex;
|
||||
FeatureSupport initial_eps_bearer_support;
|
||||
gint initial_eps_bearer_cid;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Create Bearer (Modem interface) */
|
||||
|
||||
static MMBaseBearer *
|
||||
modem_create_bearer_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_pointer (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
broadband_bearer_fibocom_ecm_new_ready (GObject *source,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
MMBaseBearer *bearer = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
bearer = mm_broadband_bearer_fibocom_ecm_new_finish (res, &error);
|
||||
if (!bearer)
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_pointer (task, bearer, g_object_unref);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
broadband_bearer_new_ready (GObject *source,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
MMBaseBearer *bearer = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
bearer = mm_broadband_bearer_new_finish (res, &error);
|
||||
if (!bearer)
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_pointer (task, bearer, g_object_unref);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
common_create_bearer (GTask *task)
|
||||
{
|
||||
MMBroadbandModemFibocom *self;
|
||||
|
||||
self = g_task_get_source_object (task);
|
||||
|
||||
switch (self->priv->gtrndis_support) {
|
||||
case FEATURE_SUPPORTED:
|
||||
mm_obj_dbg (self, "+GTRNDIS supported, creating Fibocom ECM bearer");
|
||||
mm_broadband_bearer_fibocom_ecm_new (self,
|
||||
g_task_get_task_data (task),
|
||||
NULL, /* cancellable */
|
||||
(GAsyncReadyCallback) broadband_bearer_fibocom_ecm_new_ready,
|
||||
task);
|
||||
return;
|
||||
case FEATURE_NOT_SUPPORTED:
|
||||
mm_obj_dbg (self, "+GTRNDIS not supported, creating generic PPP bearer");
|
||||
mm_broadband_bearer_new (MM_BROADBAND_MODEM (self),
|
||||
g_task_get_task_data (task),
|
||||
NULL, /* cancellable */
|
||||
(GAsyncReadyCallback) broadband_bearer_new_ready,
|
||||
task);
|
||||
return;
|
||||
case FEATURE_SUPPORT_UNKNOWN:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gtrndis_test_ready (MMBaseModem *_self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
MMBroadbandModemFibocom *self = MM_BROADBAND_MODEM_FIBOCOM (_self);
|
||||
|
||||
if (!mm_base_modem_at_command_finish (_self, res, NULL)) {
|
||||
mm_obj_dbg (self, "+GTRNDIS unsupported");
|
||||
self->priv->gtrndis_support = FEATURE_NOT_SUPPORTED;
|
||||
} else {
|
||||
mm_obj_dbg (self, "+GTRNDIS supported");
|
||||
self->priv->gtrndis_support = FEATURE_SUPPORTED;
|
||||
}
|
||||
|
||||
/* Go on and create the bearer */
|
||||
common_create_bearer (task);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_create_bearer (MMIfaceModem *_self,
|
||||
MMBearerProperties *properties,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMBroadbandModemFibocom *self = MM_BROADBAND_MODEM_FIBOCOM (_self);
|
||||
GTask *task;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
g_task_set_task_data (task, g_object_ref (properties), g_object_unref);
|
||||
|
||||
if (self->priv->gtrndis_support != FEATURE_SUPPORT_UNKNOWN) {
|
||||
common_create_bearer (task);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mm_base_modem_peek_best_data_port (MM_BASE_MODEM (self), MM_PORT_TYPE_NET)) {
|
||||
mm_obj_dbg (self, "skipping +GTRNDIS check as no data port is available");
|
||||
self->priv->gtrndis_support = FEATURE_NOT_SUPPORTED;
|
||||
common_create_bearer (task);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_obj_dbg (self, "checking +GTRNDIS support...");
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
"+GTRNDIS=?",
|
||||
6, /* timeout [s] */
|
||||
TRUE, /* allow_cached */
|
||||
(GAsyncReadyCallback) gtrndis_test_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Reset / Power (Modem interface) */
|
||||
|
||||
static gboolean
|
||||
modem_common_power_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return !!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_reset (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
"+CFUN=15",
|
||||
15,
|
||||
FALSE,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_power_down (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
"+CFUN=4",
|
||||
15,
|
||||
FALSE,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_power_off (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
"+CPWROFF",
|
||||
3,
|
||||
FALSE,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Load initial EPS bearer properties (as agreed with network) */
|
||||
|
||||
static MMBearerProperties *
|
||||
modem_3gpp_load_initial_eps_bearer_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return MM_BEARER_PROPERTIES (g_task_propagate_pointer (G_TASK (res), error));
|
||||
}
|
||||
|
||||
static void
|
||||
load_initial_eps_cgcontrdp_ready (MMBaseModem *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
const gchar *response;
|
||||
g_autofree gchar *apn = NULL;
|
||||
MMBearerProperties *properties;
|
||||
|
||||
response = mm_base_modem_at_command_finish (self, res, &error);
|
||||
if (!response || !mm_3gpp_parse_cgcontrdp_response (response, NULL, NULL, &apn, NULL, NULL, NULL, NULL, NULL, &error))
|
||||
g_task_return_error (task, error);
|
||||
else {
|
||||
properties = mm_bearer_properties_new ();
|
||||
mm_bearer_properties_set_apn (properties, apn);
|
||||
g_task_return_pointer (task, properties, g_object_unref);
|
||||
}
|
||||
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_3gpp_load_initial_eps_bearer (MMIfaceModem3gpp *_self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMBroadbandModemFibocom *self = MM_BROADBAND_MODEM_FIBOCOM (_self);
|
||||
GTask *task;
|
||||
g_autofree gchar *cmd = NULL;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
if (self->priv->initial_eps_bearer_support != FEATURE_SUPPORTED) {
|
||||
g_task_return_new_error (task,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_UNSUPPORTED,
|
||||
"Initial EPS bearer context ID unknown");
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
g_assert (self->priv->initial_eps_bearer_cid >= 0);
|
||||
cmd = g_strdup_printf ("+CGCONTRDP=%d", self->priv->initial_eps_bearer_cid);
|
||||
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
cmd,
|
||||
3,
|
||||
FALSE,
|
||||
(GAsyncReadyCallback) load_initial_eps_cgcontrdp_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Load initial EPS bearer settings (currently configured in modem) */
|
||||
|
||||
static MMBearerProperties *
|
||||
modem_3gpp_load_initial_eps_bearer_settings_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return MM_BEARER_PROPERTIES (g_task_propagate_pointer (G_TASK (res), error));
|
||||
}
|
||||
|
||||
static void
|
||||
load_initial_eps_bearer_get_profile_ready (MMIfaceModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(MM3gppProfile) profile = NULL;
|
||||
MMBearerProperties *properties;
|
||||
|
||||
profile = mm_iface_modem_3gpp_profile_manager_get_profile_finish (self, res, &error);
|
||||
if (!profile) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
properties = mm_bearer_properties_new_from_profile (profile, &error);
|
||||
if (!properties)
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_pointer (task, properties, g_object_unref);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_3gpp_load_initial_eps_bearer_settings (MMIfaceModem3gpp *_self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMBroadbandModemFibocom *self = MM_BROADBAND_MODEM_FIBOCOM (_self);
|
||||
MMPortSerialAt *port;
|
||||
MMKernelDevice *device;
|
||||
GTask *task;
|
||||
|
||||
/* Initial EPS bearer CID initialization run once only */
|
||||
if (G_UNLIKELY (self->priv->initial_eps_bearer_support == FEATURE_SUPPORT_UNKNOWN)) {
|
||||
/* There doesn't seem to be a programmatic way to find the initial EPS
|
||||
* bearer's CID, so we'll use a udev variable. */
|
||||
port = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
device = mm_port_peek_kernel_device (MM_PORT (port));
|
||||
if (mm_kernel_device_has_global_property (device, "ID_MM_FIBOCOM_INITIAL_EPS_CID")) {
|
||||
self->priv->initial_eps_bearer_support = FEATURE_SUPPORTED;
|
||||
self->priv->initial_eps_bearer_cid = mm_kernel_device_get_global_property_as_int (
|
||||
device, "ID_MM_FIBOCOM_INITIAL_EPS_CID");
|
||||
}
|
||||
else
|
||||
self->priv->initial_eps_bearer_support = FEATURE_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
if (self->priv->initial_eps_bearer_support != FEATURE_SUPPORTED) {
|
||||
g_task_return_new_error (task,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_UNSUPPORTED,
|
||||
"Initial EPS bearer context ID unknown");
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
g_assert (self->priv->initial_eps_bearer_cid >= 0);
|
||||
mm_iface_modem_3gpp_profile_manager_get_profile (
|
||||
MM_IFACE_MODEM_3GPP_PROFILE_MANAGER (self),
|
||||
self->priv->initial_eps_bearer_cid,
|
||||
(GAsyncReadyCallback) load_initial_eps_bearer_get_profile_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Set initial EPS bearer settings */
|
||||
|
||||
typedef enum {
|
||||
SET_INITIAL_EPS_BEARER_SETTINGS_STEP_LOAD_POWER_STATE = 0,
|
||||
SET_INITIAL_EPS_BEARER_SETTINGS_STEP_POWER_DOWN,
|
||||
SET_INITIAL_EPS_BEARER_SETTINGS_STEP_MODIFY_PROFILE,
|
||||
SET_INITIAL_EPS_BEARER_SETTINGS_STEP_POWER_UP,
|
||||
SET_INITIAL_EPS_BEARER_SETTINGS_STEP_FINISH,
|
||||
} SetInitialEpsStep;
|
||||
|
||||
typedef struct {
|
||||
MM3gppProfile *profile;
|
||||
SetInitialEpsStep step;
|
||||
MMModemPowerState power_state;
|
||||
} SetInitialEpsContext;
|
||||
|
||||
static void
|
||||
set_initial_eps_context_free (SetInitialEpsContext *ctx)
|
||||
{
|
||||
g_object_unref (ctx->profile);
|
||||
g_slice_free (SetInitialEpsContext, ctx);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
modem_3gpp_set_initial_eps_bearer_settings_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void set_initial_eps_step (GTask *task);
|
||||
|
||||
static void
|
||||
set_initial_eps_bearer_power_up_ready (MMBaseModem *_self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
MMBroadbandModemFibocom *self = MM_BROADBAND_MODEM_FIBOCOM (_self);
|
||||
SetInitialEpsContext *ctx;
|
||||
GError *error = NULL;
|
||||
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->modem_power_up_finish (MM_IFACE_MODEM (self), res, &error)) {
|
||||
g_prefix_error (&error, "Couldn't power up modem: ");
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->step++;
|
||||
set_initial_eps_step (task);
|
||||
}
|
||||
|
||||
static void
|
||||
set_initial_eps_bearer_modify_profile_ready (MMIfaceModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
SetInitialEpsContext *ctx;
|
||||
g_autoptr(MM3gppProfile) stored = NULL;
|
||||
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
stored = mm_iface_modem_3gpp_profile_manager_set_profile_finish (self, res, &error);
|
||||
if (!stored) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->step++;
|
||||
set_initial_eps_step (task);
|
||||
}
|
||||
|
||||
static void
|
||||
set_initial_eps_bearer_power_down_ready (MMBaseModem *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
SetInitialEpsContext *ctx;
|
||||
GError *error = NULL;
|
||||
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->modem_power_down_finish (MM_IFACE_MODEM (self), res, &error)) {
|
||||
g_prefix_error (&error, "Couldn't power down modem: ");
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->step++;
|
||||
set_initial_eps_step (task);
|
||||
}
|
||||
|
||||
static void
|
||||
set_initial_eps_bearer_load_power_state_ready (MMBaseModem *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
SetInitialEpsContext *ctx;
|
||||
GError *error = NULL;
|
||||
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
ctx->power_state = MM_IFACE_MODEM_GET_INTERFACE (self)->load_power_state_finish (MM_IFACE_MODEM (self), res, &error);
|
||||
if (error) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->step++;
|
||||
set_initial_eps_step (task);
|
||||
}
|
||||
|
||||
static void
|
||||
set_initial_eps_step (GTask *task)
|
||||
{
|
||||
MMBroadbandModemFibocom *self;
|
||||
SetInitialEpsContext *ctx;
|
||||
|
||||
self = g_task_get_source_object (task);
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
switch (ctx->step) {
|
||||
case SET_INITIAL_EPS_BEARER_SETTINGS_STEP_LOAD_POWER_STATE:
|
||||
mm_obj_dbg (self, "querying current power state...");
|
||||
g_assert (MM_IFACE_MODEM_GET_INTERFACE (self)->load_power_state);
|
||||
g_assert (MM_IFACE_MODEM_GET_INTERFACE (self)->load_power_state_finish);
|
||||
MM_IFACE_MODEM_GET_INTERFACE (self)->load_power_state (
|
||||
MM_IFACE_MODEM (self),
|
||||
(GAsyncReadyCallback) set_initial_eps_bearer_load_power_state_ready,
|
||||
task);
|
||||
return;
|
||||
|
||||
case SET_INITIAL_EPS_BEARER_SETTINGS_STEP_POWER_DOWN:
|
||||
if (ctx->power_state == MM_MODEM_POWER_STATE_ON) {
|
||||
mm_obj_dbg (self, "powering down before changing initial EPS bearer settings...");
|
||||
g_assert (MM_IFACE_MODEM_GET_INTERFACE (self)->modem_power_down);
|
||||
g_assert (MM_IFACE_MODEM_GET_INTERFACE (self)->modem_power_down_finish);
|
||||
MM_IFACE_MODEM_GET_INTERFACE (self)->modem_power_down (
|
||||
MM_IFACE_MODEM (self),
|
||||
(GAsyncReadyCallback) set_initial_eps_bearer_power_down_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* fall through */
|
||||
|
||||
case SET_INITIAL_EPS_BEARER_SETTINGS_STEP_MODIFY_PROFILE:
|
||||
mm_obj_dbg (self, "modifying initial EPS bearer settings profile...");
|
||||
mm_iface_modem_3gpp_profile_manager_set_profile (MM_IFACE_MODEM_3GPP_PROFILE_MANAGER (self),
|
||||
ctx->profile,
|
||||
"profile-id",
|
||||
TRUE,
|
||||
(GAsyncReadyCallback) set_initial_eps_bearer_modify_profile_ready,
|
||||
task);
|
||||
return;
|
||||
|
||||
case SET_INITIAL_EPS_BEARER_SETTINGS_STEP_POWER_UP:
|
||||
if (ctx->power_state == MM_MODEM_POWER_STATE_ON) {
|
||||
mm_obj_dbg (self, "powering up after changing initial EPS bearer settings...");
|
||||
g_assert (MM_IFACE_MODEM_GET_INTERFACE (self)->modem_power_up);
|
||||
g_assert (MM_IFACE_MODEM_GET_INTERFACE (self)->modem_power_up_finish);
|
||||
MM_IFACE_MODEM_GET_INTERFACE (self)->modem_power_up (
|
||||
MM_IFACE_MODEM (self),
|
||||
(GAsyncReadyCallback) set_initial_eps_bearer_power_up_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
ctx->step++;
|
||||
/* fall through */
|
||||
|
||||
case SET_INITIAL_EPS_BEARER_SETTINGS_STEP_FINISH:
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
modem_3gpp_set_initial_eps_bearer_settings (MMIfaceModem3gpp *_self,
|
||||
MMBearerProperties *properties,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMBroadbandModemFibocom *self = MM_BROADBAND_MODEM_FIBOCOM (_self);
|
||||
GTask *task;
|
||||
MM3gppProfile *profile;
|
||||
MMBearerIpFamily ip_family;
|
||||
SetInitialEpsContext *ctx;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
if (self->priv->initial_eps_bearer_support != FEATURE_SUPPORTED) {
|
||||
g_task_return_new_error (task,
|
||||
MM_CORE_ERROR,
|
||||
MM_CORE_ERROR_UNSUPPORTED,
|
||||
"Initial EPS bearer context ID unknown");
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
profile = mm_bearer_properties_peek_3gpp_profile (properties);
|
||||
g_assert (self->priv->initial_eps_bearer_cid >= 0);
|
||||
mm_3gpp_profile_set_profile_id (profile, self->priv->initial_eps_bearer_cid);
|
||||
ip_family = mm_3gpp_profile_get_ip_type (profile);
|
||||
if (ip_family == MM_BEARER_IP_FAMILY_NONE || ip_family == MM_BEARER_IP_FAMILY_ANY)
|
||||
mm_3gpp_profile_set_ip_type (profile, MM_BEARER_IP_FAMILY_IPV4);
|
||||
|
||||
/* Setup context */
|
||||
ctx = g_slice_new0 (SetInitialEpsContext);
|
||||
ctx->profile = g_object_ref (profile);
|
||||
ctx->step = SET_INITIAL_EPS_BEARER_SETTINGS_STEP_LOAD_POWER_STATE;
|
||||
g_task_set_task_data (task, ctx, (GDestroyNotify) set_initial_eps_context_free);
|
||||
|
||||
set_initial_eps_step (task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Deactivate profile (3GPP profile management interface) */
|
||||
|
||||
static gboolean
|
||||
modem_3gpp_profile_manager_deactivate_profile_finish (MMIfaceModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
profile_manager_parent_deactivate_profile_ready (MMIfaceModem3gppProfileManager *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
if (iface_modem_3gpp_profile_manager_parent->deactivate_profile_finish(self, res, &error))
|
||||
g_task_return_boolean (task, TRUE);
|
||||
else
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_3gpp_profile_manager_deactivate_profile (MMIfaceModem3gppProfileManager *_self,
|
||||
MM3gppProfile *profile,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMBroadbandModemFibocom *self = MM_BROADBAND_MODEM_FIBOCOM (_self);
|
||||
GTask *task;
|
||||
gint profile_id;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
profile_id = mm_3gpp_profile_get_profile_id (profile);
|
||||
|
||||
if (self->priv->initial_eps_bearer_support == FEATURE_SUPPORTED) {
|
||||
g_assert (self->priv->initial_eps_bearer_cid >= 0);
|
||||
if (self->priv->initial_eps_bearer_cid == profile_id) {
|
||||
mm_obj_dbg (self, "skipping profile deactivation (initial EPS bearer)");
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
iface_modem_3gpp_profile_manager_parent->deactivate_profile (
|
||||
_self,
|
||||
profile,
|
||||
(GAsyncReadyCallback) profile_manager_parent_deactivate_profile_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
setup_ports (MMBroadbandModem *_self)
|
||||
{
|
||||
MMBroadbandModemFibocom *self = (MM_BROADBAND_MODEM_FIBOCOM (_self));
|
||||
MMPortSerialAt *ports[2];
|
||||
guint i;
|
||||
|
||||
/* Call parent's setup ports first always */
|
||||
MM_BROADBAND_MODEM_CLASS (mm_broadband_modem_fibocom_parent_class)->setup_ports (_self);
|
||||
|
||||
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (ports); i++) {
|
||||
if (!ports[i])
|
||||
continue;
|
||||
mm_port_serial_at_add_unsolicited_msg_handler (
|
||||
ports[i],
|
||||
self->priv->sim_ready_regex,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
MMBroadbandModemFibocom *
|
||||
mm_broadband_modem_fibocom_new (const gchar *device,
|
||||
const gchar **drivers,
|
||||
const gchar *plugin,
|
||||
guint16 vendor_id,
|
||||
guint16 product_id)
|
||||
{
|
||||
return g_object_new (MM_TYPE_BROADBAND_MODEM_FIBOCOM,
|
||||
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,
|
||||
MM_BASE_MODEM_DATA_NET_SUPPORTED, TRUE,
|
||||
MM_BASE_MODEM_DATA_TTY_SUPPORTED, TRUE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_modem_fibocom_init (MMBroadbandModemFibocom *self)
|
||||
{
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
|
||||
MM_TYPE_BROADBAND_MODEM_FIBOCOM,
|
||||
MMBroadbandModemFibocomPrivate);
|
||||
|
||||
self->priv->gtrndis_support = FEATURE_SUPPORT_UNKNOWN;
|
||||
self->priv->sim_ready_regex = g_regex_new ("\\r\\n\\+SIM READY\\r\\n",
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
self->priv->initial_eps_bearer_support = FEATURE_SUPPORT_UNKNOWN;
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
MMBroadbandModemFibocom *self = MM_BROADBAND_MODEM_FIBOCOM (object);
|
||||
|
||||
g_regex_unref (self->priv->sim_ready_regex);
|
||||
|
||||
G_OBJECT_CLASS (mm_broadband_modem_fibocom_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_init (MMIfaceModem *iface)
|
||||
{
|
||||
iface->create_bearer = modem_create_bearer;
|
||||
iface->create_bearer_finish = modem_create_bearer_finish;
|
||||
iface->reset = modem_reset;
|
||||
iface->reset_finish = modem_common_power_finish;
|
||||
iface->modem_power_down = modem_power_down;
|
||||
iface->modem_power_down_finish = modem_common_power_finish;
|
||||
iface->modem_power_off = modem_power_off;
|
||||
iface->modem_power_off_finish = modem_common_power_finish;
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
|
||||
{
|
||||
iface->load_initial_eps_bearer = modem_3gpp_load_initial_eps_bearer;
|
||||
iface->load_initial_eps_bearer_finish = modem_3gpp_load_initial_eps_bearer_finish;
|
||||
iface->load_initial_eps_bearer_settings = modem_3gpp_load_initial_eps_bearer_settings;
|
||||
iface->load_initial_eps_bearer_settings_finish = modem_3gpp_load_initial_eps_bearer_settings_finish;
|
||||
iface->set_initial_eps_bearer_settings = modem_3gpp_set_initial_eps_bearer_settings;
|
||||
iface->set_initial_eps_bearer_settings_finish = modem_3gpp_set_initial_eps_bearer_settings_finish;
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_3gpp_profile_manager_init (MMIfaceModem3gppProfileManager *iface)
|
||||
{
|
||||
iface_modem_3gpp_profile_manager_parent = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->deactivate_profile = modem_3gpp_profile_manager_deactivate_profile;
|
||||
iface->deactivate_profile_finish = modem_3gpp_profile_manager_deactivate_profile_finish;
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_modem_fibocom_class_init (MMBroadbandModemFibocomClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
MMBroadbandModemClass *broadband_modem_class = MM_BROADBAND_MODEM_CLASS (klass);
|
||||
|
||||
g_type_class_add_private (G_OBJECT_CLASS (klass),
|
||||
sizeof (MMBroadbandModemFibocomPrivate));
|
||||
|
||||
/* Virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
broadband_modem_class->setup_ports = setup_ports;
|
||||
}
|
||||
@@ -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) 2022 Disruptive Technologies Research AS
|
||||
*/
|
||||
|
||||
#ifndef MM_BROADBAND_MODEM_FIBOCOM_H
|
||||
#define MM_BROADBAND_MODEM_FIBOCOM_H
|
||||
|
||||
#include "mm-broadband-modem.h"
|
||||
|
||||
#define MM_TYPE_BROADBAND_MODEM_FIBOCOM (mm_broadband_modem_fibocom_get_type ())
|
||||
#define MM_BROADBAND_MODEM_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_FIBOCOM, MMBroadbandModemFibocom))
|
||||
#define MM_BROADBAND_MODEM_FIBOCOM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_FIBOCOM, MMBroadbandModemFibocomClass))
|
||||
#define MM_IS_BROADBAND_MODEM_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_FIBOCOM))
|
||||
#define MM_IS_BROADBAND_MODEM_FIBOCOM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_FIBOCOM))
|
||||
#define MM_BROADBAND_MODEM_FIBOCOM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_FIBOCOM, MMBroadbandModemFibocomClass))
|
||||
|
||||
typedef struct _MMBroadbandModemFibocom MMBroadbandModemFibocom;
|
||||
typedef struct _MMBroadbandModemFibocomClass MMBroadbandModemFibocomClass;
|
||||
typedef struct _MMBroadbandModemFibocomPrivate MMBroadbandModemFibocomPrivate;
|
||||
|
||||
struct _MMBroadbandModemFibocom {
|
||||
MMBroadbandModem parent;
|
||||
MMBroadbandModemFibocomPrivate *priv;
|
||||
};
|
||||
|
||||
struct _MMBroadbandModemFibocomClass{
|
||||
MMBroadbandModemClass parent;
|
||||
};
|
||||
|
||||
GType mm_broadband_modem_fibocom_get_type (void);
|
||||
|
||||
MMBroadbandModemFibocom *mm_broadband_modem_fibocom_new (const gchar *device,
|
||||
const gchar **drivers,
|
||||
const gchar *plugin,
|
||||
guint16 vendor_id,
|
||||
guint16 product_id);
|
||||
|
||||
#endif /* MM_BROADBAND_MODEM_FIBOCOM_H */
|
||||
@@ -0,0 +1,95 @@
|
||||
/* -*- 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) 2022 Fibocom Wireless Inc.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ModemManager.h"
|
||||
#include "mm-log-object.h"
|
||||
#include "mm-iface-modem.h"
|
||||
#include "mm-iface-modem-3gpp.h"
|
||||
#include "mm-broadband-modem-mbim-fibocom.h"
|
||||
#include "mm-shared-fibocom.h"
|
||||
|
||||
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
|
||||
static void shared_fibocom_init (MMSharedFibocom *iface);
|
||||
|
||||
static MMIfaceModem3gpp *iface_modem_3gpp_parent;
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimFibocom, mm_broadband_modem_mbim_fibocom, MM_TYPE_BROADBAND_MODEM_MBIM, 0,
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_FIBOCOM, shared_fibocom_init))
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
MMBroadbandModemMbimFibocom *
|
||||
mm_broadband_modem_mbim_fibocom_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_FIBOCOM,
|
||||
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,
|
||||
/* MBIM bearer supports NET only */
|
||||
MM_BASE_MODEM_DATA_NET_SUPPORTED, TRUE,
|
||||
MM_BASE_MODEM_DATA_TTY_SUPPORTED, FALSE,
|
||||
MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, TRUE,
|
||||
MM_IFACE_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED, TRUE,
|
||||
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||
MM_BROADBAND_MODEM_MBIM_QMI_UNSUPPORTED, TRUE,
|
||||
#endif
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_modem_mbim_fibocom_init (MMBroadbandModemMbimFibocom *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
|
||||
{
|
||||
iface_modem_3gpp_parent = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->set_initial_eps_bearer_settings = mm_shared_fibocom_set_initial_eps_bearer_settings;
|
||||
iface->set_initial_eps_bearer_settings_finish = mm_shared_fibocom_set_initial_eps_bearer_settings_finish;
|
||||
}
|
||||
|
||||
static MMIfaceModem3gpp *
|
||||
peek_parent_3gpp_interface (MMSharedFibocom *self)
|
||||
{
|
||||
return iface_modem_3gpp_parent;
|
||||
}
|
||||
|
||||
static void
|
||||
shared_fibocom_init (MMSharedFibocom *iface)
|
||||
{
|
||||
iface->peek_parent_3gpp_interface = peek_parent_3gpp_interface;
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_modem_mbim_fibocom_class_init (MMBroadbandModemMbimFibocomClass *klass)
|
||||
{
|
||||
}
|
||||
@@ -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) 2022 Fibocom Wireless Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_BROADBAND_MODEM_MBIM_FIBOCOM_H
|
||||
#define MM_BROADBAND_MODEM_MBIM_FIBOCOM_H
|
||||
|
||||
#include "mm-broadband-modem-mbim.h"
|
||||
|
||||
#define MM_TYPE_BROADBAND_MODEM_MBIM_FIBOCOM (mm_broadband_modem_mbim_fibocom_get_type ())
|
||||
#define MM_BROADBAND_MODEM_MBIM_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_MBIM_FIBOCOM, MMBroadbandModemMbimFibocom))
|
||||
#define MM_BROADBAND_MODEM_MBIM_FIBOCOM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_MBIM_FIBOCOM, MMBroadbandModemMbimFibocomClass))
|
||||
#define MM_IS_BROADBAND_MODEM_MBIM_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_MBIM_FIBOCOM))
|
||||
#define MM_IS_BROADBAND_MODEM_MBIM_FIBOCOM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_MBIM_FIBOCOM))
|
||||
#define MM_BROADBAND_MODEM_MBIM_FIBOCOM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_MBIM_FIBOCOM, MMBroadbandModemMbimFibocomClass))
|
||||
|
||||
typedef struct _MMBroadbandModemMbimFibocom MMBroadbandModemMbimFibocom;
|
||||
typedef struct _MMBroadbandModemMbimFibocomClass MMBroadbandModemMbimFibocomClass;
|
||||
|
||||
struct _MMBroadbandModemMbimFibocom {
|
||||
MMBroadbandModemMbim parent;
|
||||
};
|
||||
|
||||
struct _MMBroadbandModemMbimFibocomClass{
|
||||
MMBroadbandModemMbimClass parent;
|
||||
};
|
||||
|
||||
GType mm_broadband_modem_mbim_fibocom_get_type (void);
|
||||
|
||||
MMBroadbandModemMbimFibocom *mm_broadband_modem_mbim_fibocom_new (const gchar *device,
|
||||
const gchar **drivers,
|
||||
const gchar *plugin,
|
||||
guint16 vendor_id,
|
||||
guint16 product_id);
|
||||
|
||||
#endif /* MM_BROADBAND_MODEM_MBIM_FIBOCOM_H */
|
||||
@@ -0,0 +1,95 @@
|
||||
/* -*- 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) 2022 Fibocom Wireless Inc.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "ModemManager.h"
|
||||
#include "mm-log-object.h"
|
||||
#include "mm-iface-modem.h"
|
||||
#include "mm-iface-modem-3gpp.h"
|
||||
#include "mm-broadband-modem-mbim-xmm-fibocom.h"
|
||||
#include "mm-shared-fibocom.h"
|
||||
|
||||
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
|
||||
static void shared_fibocom_init (MMSharedFibocom *iface);
|
||||
|
||||
static MMIfaceModem3gpp *iface_modem_3gpp_parent;
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimXmmFibocom, mm_broadband_modem_mbim_xmm_fibocom, MM_TYPE_BROADBAND_MODEM_MBIM_XMM, 0,
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_FIBOCOM, shared_fibocom_init))
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
MMBroadbandModemMbimXmmFibocom *
|
||||
mm_broadband_modem_mbim_xmm_fibocom_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_XMM_FIBOCOM,
|
||||
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,
|
||||
/* MBIM bearer supports NET only */
|
||||
MM_BASE_MODEM_DATA_NET_SUPPORTED, TRUE,
|
||||
MM_BASE_MODEM_DATA_TTY_SUPPORTED, FALSE,
|
||||
MM_IFACE_MODEM_SIM_HOT_SWAP_SUPPORTED, TRUE,
|
||||
MM_IFACE_MODEM_PERIODIC_SIGNAL_CHECK_DISABLED, TRUE,
|
||||
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
|
||||
MM_BROADBAND_MODEM_MBIM_QMI_UNSUPPORTED, TRUE,
|
||||
#endif
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_modem_mbim_xmm_fibocom_init (MMBroadbandModemMbimXmmFibocom *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
|
||||
{
|
||||
iface_modem_3gpp_parent = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->set_initial_eps_bearer_settings = mm_shared_fibocom_set_initial_eps_bearer_settings;
|
||||
iface->set_initial_eps_bearer_settings_finish = mm_shared_fibocom_set_initial_eps_bearer_settings_finish;
|
||||
}
|
||||
|
||||
static MMIfaceModem3gpp *
|
||||
peek_parent_3gpp_interface (MMSharedFibocom *self)
|
||||
{
|
||||
return iface_modem_3gpp_parent;
|
||||
}
|
||||
|
||||
static void
|
||||
shared_fibocom_init (MMSharedFibocom *iface)
|
||||
{
|
||||
iface->peek_parent_3gpp_interface = peek_parent_3gpp_interface;
|
||||
}
|
||||
|
||||
static void
|
||||
mm_broadband_modem_mbim_xmm_fibocom_class_init (MMBroadbandModemMbimXmmFibocomClass *klass)
|
||||
{
|
||||
}
|
||||
@@ -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) 2022 Fibocom Wireless Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_BROADBAND_MODEM_MBIM_XMM_FIBOCOM_H
|
||||
#define MM_BROADBAND_MODEM_MBIM_XMM_FIBOCOM_H
|
||||
|
||||
#include "mm-broadband-modem-mbim-xmm.h"
|
||||
|
||||
#define MM_TYPE_BROADBAND_MODEM_MBIM_XMM_FIBOCOM (mm_broadband_modem_mbim_xmm_fibocom_get_type ())
|
||||
#define MM_BROADBAND_MODEM_MBIM_XMM_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_BROADBAND_MODEM_MBIM_XMM_FIBOCOM, MMBroadbandModemMbimXmmFibocom))
|
||||
#define MM_BROADBAND_MODEM_MBIM_XMM_FIBOCOM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_BROADBAND_MODEM_MBIM_XMM_FIBOCOM, MMBroadbandModemMbimXmmFibocomClass))
|
||||
#define MM_IS_BROADBAND_MODEM_MBIM_XMM_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_BROADBAND_MODEM_MBIM_XMM_FIBOCOM))
|
||||
#define MM_IS_BROADBAND_MODEM_MBIM_XMM_FIBOCOM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_BROADBAND_MODEM_MBIM_XMM_FIBOCOM))
|
||||
#define MM_BROADBAND_MODEM_MBIM_XMM_FIBOCOM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_BROADBAND_MODEM_MBIM_XMM_FIBOCOM, MMBroadbandModemMbimXmmFibocomClass))
|
||||
|
||||
typedef struct _MMBroadbandModemMbimXmmFibocom MMBroadbandModemMbimXmmFibocom;
|
||||
typedef struct _MMBroadbandModemMbimXmmFibocomClass MMBroadbandModemMbimXmmFibocomClass;
|
||||
|
||||
struct _MMBroadbandModemMbimXmmFibocom {
|
||||
MMBroadbandModemMbimXmm parent;
|
||||
};
|
||||
|
||||
struct _MMBroadbandModemMbimXmmFibocomClass{
|
||||
MMBroadbandModemMbimXmmClass parent;
|
||||
};
|
||||
|
||||
GType mm_broadband_modem_mbim_xmm_fibocom_get_type (void);
|
||||
|
||||
MMBroadbandModemMbimXmmFibocom *mm_broadband_modem_mbim_xmm_fibocom_new (const gchar *device,
|
||||
const gchar **drivers,
|
||||
const gchar *plugin,
|
||||
guint16 vendor_id,
|
||||
guint16 product_id);
|
||||
|
||||
#endif /* MM_BROADBAND_MODEM_MBIM_XMM_FIBOCOM_H */
|
||||
@@ -0,0 +1,136 @@
|
||||
/* -*- 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) 2018-2020 Aleksander Morgado <aleksander@aleksander.es>
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <gmodule.h>
|
||||
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include "mm-log-object.h"
|
||||
#include "mm-plugin-fibocom.h"
|
||||
#include "mm-broadband-modem.h"
|
||||
#include "mm-broadband-modem-xmm.h"
|
||||
#include "mm-broadband-modem-fibocom.h"
|
||||
|
||||
#if defined WITH_MBIM
|
||||
#include "mm-broadband-modem-mbim.h"
|
||||
#include "mm-broadband-modem-mbim-fibocom.h"
|
||||
#include "mm-broadband-modem-mbim-xmm.h"
|
||||
#include "mm-broadband-modem-mbim-xmm-fibocom.h"
|
||||
#endif
|
||||
|
||||
#if defined WITH_QMI
|
||||
#include "mm-broadband-modem-qmi.h"
|
||||
#endif
|
||||
|
||||
G_DEFINE_TYPE (MMPluginFibocom, mm_plugin_fibocom, MM_TYPE_PLUGIN)
|
||||
|
||||
MM_PLUGIN_DEFINE_MAJOR_VERSION
|
||||
MM_PLUGIN_DEFINE_MINOR_VERSION
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static MMBaseModem *
|
||||
create_modem (MMPlugin *self,
|
||||
const gchar *uid,
|
||||
const gchar **drivers,
|
||||
guint16 vendor,
|
||||
guint16 product,
|
||||
guint16 subsystem_vendor,
|
||||
GList *probes,
|
||||
GError **error)
|
||||
{
|
||||
#if defined WITH_MBIM
|
||||
if (mm_port_probe_list_has_mbim_port (probes)) {
|
||||
if (mm_port_probe_list_is_xmm (probes)) {
|
||||
mm_obj_dbg (self, "MBIM-powered XMM-based Fibocom modem found...");
|
||||
return MM_BASE_MODEM (mm_broadband_modem_mbim_xmm_fibocom_new (uid,
|
||||
drivers,
|
||||
mm_plugin_get_name (self),
|
||||
vendor,
|
||||
product));
|
||||
}
|
||||
mm_obj_dbg (self, "MBIM-powered Fibocom modem found...");
|
||||
return MM_BASE_MODEM (mm_broadband_modem_mbim_fibocom_new (uid,
|
||||
drivers,
|
||||
mm_plugin_get_name (self),
|
||||
vendor,
|
||||
product));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined WITH_QMI
|
||||
if (mm_port_probe_list_has_qmi_port (probes)) {
|
||||
mm_obj_dbg (self, "QMI-powered Fibocom modem found...");
|
||||
return MM_BASE_MODEM (mm_broadband_modem_qmi_new (uid,
|
||||
drivers,
|
||||
mm_plugin_get_name (self),
|
||||
vendor,
|
||||
product));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mm_port_probe_list_is_xmm (probes)) {
|
||||
mm_obj_dbg (self, "XMM-based Fibocom modem found...");
|
||||
return MM_BASE_MODEM (mm_broadband_modem_xmm_new (uid,
|
||||
drivers,
|
||||
mm_plugin_get_name (self),
|
||||
vendor,
|
||||
product));
|
||||
}
|
||||
|
||||
mm_obj_dbg (self, "Fibocom modem found...");
|
||||
return MM_BASE_MODEM (mm_broadband_modem_fibocom_new (uid,
|
||||
drivers,
|
||||
mm_plugin_get_name (self),
|
||||
vendor,
|
||||
product));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
G_MODULE_EXPORT MMPlugin *
|
||||
mm_plugin_create (void)
|
||||
{
|
||||
static const gchar *subsystems[] = { "tty", "net", "usbmisc", NULL };
|
||||
static const guint16 vendor_ids[] = { 0x2cb7, 0x1782, 0 };
|
||||
static const gchar *drivers[] = { "cdc_mbim", "qmi_wwan", "cdc_ether", "option", NULL };
|
||||
|
||||
return MM_PLUGIN (
|
||||
g_object_new (MM_TYPE_PLUGIN_FIBOCOM,
|
||||
MM_PLUGIN_NAME, MM_MODULE_NAME,
|
||||
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
|
||||
MM_PLUGIN_ALLOWED_VENDOR_IDS, vendor_ids,
|
||||
MM_PLUGIN_ALLOWED_DRIVERS, drivers,
|
||||
MM_PLUGIN_ALLOWED_AT, TRUE,
|
||||
MM_PLUGIN_ALLOWED_MBIM, TRUE,
|
||||
MM_PLUGIN_ALLOWED_QMI, TRUE,
|
||||
MM_PLUGIN_XMM_PROBE, TRUE,
|
||||
NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
mm_plugin_fibocom_init (MMPluginFibocom *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
mm_plugin_fibocom_class_init (MMPluginFibocomClass *klass)
|
||||
{
|
||||
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
|
||||
|
||||
plugin_class->create_modem = create_modem;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/* -*- 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) 2018 Aleksander Morgado <aleksander@aleksander.es>
|
||||
*/
|
||||
|
||||
#ifndef MM_PLUGIN_FIBOCOM_H
|
||||
#define MM_PLUGIN_FIBOCOM_H
|
||||
|
||||
#include "mm-plugin.h"
|
||||
|
||||
#define MM_TYPE_PLUGIN_FIBOCOM (mm_plugin_fibocom_get_type ())
|
||||
#define MM_PLUGIN_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_FIBOCOM, MMPluginFibocom))
|
||||
#define MM_PLUGIN_FIBOCOM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_FIBOCOM, MMPluginFibocomClass))
|
||||
#define MM_IS_PLUGIN_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_FIBOCOM))
|
||||
#define MM_IS_PLUGIN_FIBOCOM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_FIBOCOM))
|
||||
#define MM_PLUGIN_FIBOCOM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_FIBOCOM, MMPluginFibocomClass))
|
||||
|
||||
typedef struct {
|
||||
MMPlugin parent;
|
||||
} MMPluginFibocom;
|
||||
|
||||
typedef struct {
|
||||
MMPluginClass parent;
|
||||
} MMPluginFibocomClass;
|
||||
|
||||
GType mm_plugin_fibocom_get_type (void);
|
||||
|
||||
G_MODULE_EXPORT MMPlugin *mm_plugin_create (void);
|
||||
|
||||
#endif /* MM_PLUGIN_FIBOCOM_H */
|
||||
@@ -0,0 +1,246 @@
|
||||
/* -*- 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) 2022 Fibocom Wireless Inc.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include "mm-log-object.h"
|
||||
#include "mm-broadband-modem.h"
|
||||
#include "mm-broadband-modem-mbim.h"
|
||||
#include "mm-iface-modem.h"
|
||||
#include "mm-iface-modem-3gpp.h"
|
||||
#include "mm-shared-fibocom.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Private data context */
|
||||
|
||||
#define PRIVATE_TAG "shared-intel-private-tag"
|
||||
static GQuark private_quark;
|
||||
|
||||
typedef struct {
|
||||
/* 3GPP interface support */
|
||||
MMIfaceModem3gpp *iface_modem_3gpp_parent;
|
||||
} Private;
|
||||
|
||||
static void
|
||||
private_free (Private *priv)
|
||||
{
|
||||
g_slice_free (Private, priv);
|
||||
}
|
||||
|
||||
static Private *
|
||||
get_private (MMSharedFibocom *self)
|
||||
{
|
||||
Private *priv;
|
||||
|
||||
if (G_UNLIKELY (!private_quark))
|
||||
private_quark = g_quark_from_static_string (PRIVATE_TAG);
|
||||
|
||||
priv = g_object_get_qdata (G_OBJECT (self), private_quark);
|
||||
if (!priv) {
|
||||
priv = g_slice_new0 (Private);
|
||||
|
||||
/* Setup parent class' MMIfaceModem3gpp */
|
||||
g_assert (MM_SHARED_FIBOCOM_GET_INTERFACE (self)->peek_parent_3gpp_interface);
|
||||
priv->iface_modem_3gpp_parent = MM_SHARED_FIBOCOM_GET_INTERFACE (self)->peek_parent_3gpp_interface (self);
|
||||
|
||||
g_object_set_qdata_full (G_OBJECT (self), private_quark, priv, (GDestroyNotify)private_free);
|
||||
}
|
||||
|
||||
return priv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
MMBearerProperties *config;
|
||||
gboolean initial_eps_off_on;
|
||||
} SetInitialEpsBearerSettingsContext;
|
||||
|
||||
static void
|
||||
set_initial_eps_bearer_settings_context_free (SetInitialEpsBearerSettingsContext *ctx)
|
||||
{
|
||||
g_clear_object (&ctx->config);
|
||||
g_slice_free (SetInitialEpsBearerSettingsContext, ctx);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_shared_fibocom_set_initial_eps_bearer_settings_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
after_attach_apn_modem_power_up_ready (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!mm_iface_modem_set_power_state_finish (self, res, &error)) {
|
||||
mm_obj_warn (self, "failed to power up modem after attach APN settings update: %s", error->message);
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_obj_dbg (self, "success toggling modem power up after attach APN");
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_set_initial_eps_bearer_settings_ready (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
SetInitialEpsBearerSettingsContext *ctx;
|
||||
Private *priv;
|
||||
GError *error = NULL;
|
||||
|
||||
ctx = g_task_get_task_data (task);
|
||||
priv = get_private (MM_SHARED_FIBOCOM (self));
|
||||
|
||||
if (!priv->iface_modem_3gpp_parent->set_initial_eps_bearer_settings_finish (self, res, &error)) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx->initial_eps_off_on) {
|
||||
mm_obj_dbg (self, "toggle modem power up after attach APN");
|
||||
mm_iface_modem_set_power_state (MM_IFACE_MODEM (self),
|
||||
MM_MODEM_POWER_STATE_ON,
|
||||
(GAsyncReadyCallback) after_attach_apn_modem_power_up_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_set_initial_eps_bearer_settings (GTask *task)
|
||||
{
|
||||
MMSharedFibocom *self;
|
||||
SetInitialEpsBearerSettingsContext *ctx;
|
||||
Private *priv;
|
||||
|
||||
self = g_task_get_source_object (task);
|
||||
ctx = g_task_get_task_data (task);
|
||||
priv = get_private (self);
|
||||
|
||||
g_assert (priv->iface_modem_3gpp_parent);
|
||||
g_assert (priv->iface_modem_3gpp_parent->set_initial_eps_bearer_settings);
|
||||
g_assert (priv->iface_modem_3gpp_parent->set_initial_eps_bearer_settings_finish);
|
||||
|
||||
priv->iface_modem_3gpp_parent->set_initial_eps_bearer_settings (MM_IFACE_MODEM_3GPP (self),
|
||||
ctx->config,
|
||||
(GAsyncReadyCallback)parent_set_initial_eps_bearer_settings_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
static void
|
||||
before_attach_apn_modem_power_down_ready (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!mm_iface_modem_set_power_state_finish (self, res, &error)) {
|
||||
mm_obj_warn (self, "failed to power down modem before attach APN settings update: %s", error->message);
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
mm_obj_dbg (self, "success toggling modem power down before attach APN");
|
||||
|
||||
parent_set_initial_eps_bearer_settings (task);
|
||||
}
|
||||
|
||||
void
|
||||
mm_shared_fibocom_set_initial_eps_bearer_settings (MMIfaceModem3gpp *self,
|
||||
MMBearerProperties *config,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
SetInitialEpsBearerSettingsContext *ctx;
|
||||
GTask *task;
|
||||
MMPortMbim *port;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
/* This shared logic is only expected in MBIM capable devices */
|
||||
g_assert (MM_IS_BROADBAND_MODEM_MBIM (self));
|
||||
port = mm_broadband_modem_mbim_peek_port_mbim (MM_BROADBAND_MODEM_MBIM (self));
|
||||
if (!port) {
|
||||
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
|
||||
"No valid MBIM port found");
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
ctx = g_slice_new0 (SetInitialEpsBearerSettingsContext);
|
||||
ctx->config = g_object_ref (config);
|
||||
ctx->initial_eps_off_on = mm_kernel_device_get_property_as_boolean (mm_port_peek_kernel_device (MM_PORT (port)), "ID_MM_FIBOCOM_INITIAL_EPS_OFF_ON");
|
||||
g_task_set_task_data (task, ctx, (GDestroyNotify)set_initial_eps_bearer_settings_context_free);
|
||||
|
||||
if (ctx->initial_eps_off_on) {
|
||||
mm_obj_dbg (self, "toggle modem power down before attach APN");
|
||||
mm_iface_modem_set_power_state (MM_IFACE_MODEM (self),
|
||||
MM_MODEM_POWER_STATE_LOW,
|
||||
(GAsyncReadyCallback) before_attach_apn_modem_power_down_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
|
||||
parent_set_initial_eps_bearer_settings (task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
shared_fibocom_init (gpointer g_iface)
|
||||
{
|
||||
}
|
||||
|
||||
GType
|
||||
mm_shared_fibocom_get_type (void)
|
||||
{
|
||||
static GType shared_fibocom_type = 0;
|
||||
|
||||
if (!G_UNLIKELY (shared_fibocom_type)) {
|
||||
static const GTypeInfo info = {
|
||||
sizeof (MMSharedFibocom), /* class_size */
|
||||
shared_fibocom_init, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
};
|
||||
|
||||
shared_fibocom_type = g_type_register_static (G_TYPE_INTERFACE, "MMSharedFibocom", &info, 0);
|
||||
g_type_interface_add_prerequisite (shared_fibocom_type, MM_TYPE_IFACE_MODEM);
|
||||
g_type_interface_add_prerequisite (shared_fibocom_type, MM_TYPE_IFACE_MODEM_3GPP);
|
||||
}
|
||||
|
||||
return shared_fibocom_type;
|
||||
}
|
||||
@@ -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:
|
||||
*
|
||||
* Copyright (C) 2022 Fibocom Wireless Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_SHARED_FIBOCOM_H
|
||||
#define MM_SHARED_FIBOCOM_H
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
#define _LIBMM_INSIDE_MM
|
||||
#include <libmm-glib.h>
|
||||
|
||||
#include "mm-broadband-modem.h"
|
||||
#include "mm-iface-modem-3gpp.h"
|
||||
#include "mm-iface-modem.h"
|
||||
|
||||
#define MM_TYPE_SHARED_FIBOCOM (mm_shared_fibocom_get_type ())
|
||||
#define MM_SHARED_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_SHARED_FIBOCOM, MMSharedFibocom))
|
||||
#define MM_IS_SHARED_FIBOCOM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_SHARED_FIBOCOM))
|
||||
#define MM_SHARED_FIBOCOM_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_SHARED_FIBOCOM, MMSharedFibocom))
|
||||
|
||||
typedef struct _MMSharedFibocom MMSharedFibocom;
|
||||
|
||||
struct _MMSharedFibocom {
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Peek 3GPP interface of the parent class of the object */
|
||||
MMIfaceModem3gpp * (* peek_parent_3gpp_interface) (MMSharedFibocom *self);
|
||||
};
|
||||
|
||||
GType mm_shared_fibocom_get_type (void);
|
||||
|
||||
void mm_shared_fibocom_set_initial_eps_bearer_settings (MMIfaceModem3gpp *self,
|
||||
MMBearerProperties *config,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_fibocom_set_initial_eps_bearer_settings_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
#endif /* MM_SHARED_FIBOCOM_H */
|
||||
@@ -0,0 +1,20 @@
|
||||
/* -*- 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) 2022 Aleksander Morgado <aleksander@aleksander.es>
|
||||
*/
|
||||
|
||||
#include "mm-shared.h"
|
||||
|
||||
MM_SHARED_DEFINE_MAJOR_VERSION
|
||||
MM_SHARED_DEFINE_MINOR_VERSION
|
||||
MM_SHARED_DEFINE_NAME(Intel)
|
||||
Reference in New Issue
Block a user