sierra: plugin fully ported
This commit is contained in:
@@ -1,415 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define G_UDEV_API_IS_SUBJECT_TO_CHANGE
|
||||
#include <gudev/gudev.h>
|
||||
|
||||
#include "mm-modem-sierra-cdma.h"
|
||||
#include "mm-errors.h"
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-serial-port.h"
|
||||
#include "mm-serial-parsers.h"
|
||||
#include "mm-modem-helpers.h"
|
||||
|
||||
G_DEFINE_TYPE (MMModemSierraCdma, mm_modem_sierra_cdma, MM_TYPE_GENERIC_CDMA)
|
||||
|
||||
#define MM_MODEM_SIERRA_CDMA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_MODEM_SIERRA_CDMA, MMModemSierraCdmaPrivate))
|
||||
|
||||
typedef enum {
|
||||
SYS_MODE_UNKNOWN,
|
||||
SYS_MODE_NO_SERVICE,
|
||||
SYS_MODE_CDMA_1X,
|
||||
SYS_MODE_EVDO_REV0,
|
||||
SYS_MODE_EVDO_REVA
|
||||
} SysMode;
|
||||
|
||||
typedef struct {
|
||||
SysMode sys_mode;
|
||||
} MMModemSierraCdmaPrivate;
|
||||
|
||||
MMModem *
|
||||
mm_modem_sierra_cdma_new (const char *device,
|
||||
const char *driver,
|
||||
const char *plugin,
|
||||
gboolean evdo_rev0,
|
||||
gboolean evdo_revA,
|
||||
guint32 vendor,
|
||||
guint32 product)
|
||||
{
|
||||
g_return_val_if_fail (device != NULL, NULL);
|
||||
g_return_val_if_fail (driver != NULL, NULL);
|
||||
g_return_val_if_fail (plugin != NULL, NULL);
|
||||
|
||||
return MM_MODEM (g_object_new (MM_TYPE_MODEM_SIERRA_CDMA,
|
||||
MM_MODEM_MASTER_DEVICE, device,
|
||||
MM_MODEM_DRIVER, driver,
|
||||
MM_MODEM_PLUGIN, plugin,
|
||||
MM_GENERIC_CDMA_EVDO_REV0, evdo_rev0,
|
||||
MM_GENERIC_CDMA_EVDO_REVA, evdo_revA,
|
||||
MM_MODEM_HW_VID, vendor,
|
||||
MM_MODEM_HW_PID, product,
|
||||
NULL));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define MODEM_REG_TAG "Modem has registered"
|
||||
#define GENERIC_ROAM_TAG "Roaming:"
|
||||
#define ROAM_1X_TAG "1xRoam:"
|
||||
#define ROAM_EVDO_TAG "HDRRoam:"
|
||||
#define SYS_MODE_TAG "Sys Mode:"
|
||||
#define SYS_MODE_NO_SERVICE_TAG "NO SRV"
|
||||
#define SYS_MODE_EVDO_TAG "HDR"
|
||||
#define SYS_MODE_1X_TAG "1x"
|
||||
#define SYS_MODE_CDMA_TAG "CDMA"
|
||||
#define EVDO_REV_TAG "HDR Revision:"
|
||||
#define SID_TAG "SID:"
|
||||
|
||||
static gboolean
|
||||
get_roam_value (const char *reply,
|
||||
const char *tag,
|
||||
gboolean is_eri,
|
||||
gboolean *out_roaming)
|
||||
{
|
||||
char *p;
|
||||
gboolean success;
|
||||
guint32 ind = 0;
|
||||
|
||||
p = strstr (reply, tag);
|
||||
if (!p)
|
||||
return FALSE;
|
||||
|
||||
p += strlen (tag);
|
||||
while (*p && isspace (*p))
|
||||
p++;
|
||||
|
||||
/* Use generic ERI parsing if it's an ERI */
|
||||
if (is_eri) {
|
||||
success = mm_cdma_parse_eri (p, out_roaming, &ind, NULL);
|
||||
if (success) {
|
||||
/* Sierra redefines ERI 0, 1, and 2 */
|
||||
if (ind == 0)
|
||||
*out_roaming = FALSE; /* home */
|
||||
else if (ind == 1 || ind == 2)
|
||||
*out_roaming = TRUE; /* roaming */
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
/* If it's not an ERI, roaming is just true/false */
|
||||
if (*p == '1') {
|
||||
*out_roaming = TRUE;
|
||||
return TRUE;
|
||||
} else if (*p == '0') {
|
||||
*out_roaming = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sys_mode_has_service (SysMode mode)
|
||||
{
|
||||
return ( mode == SYS_MODE_CDMA_1X
|
||||
|| mode == SYS_MODE_EVDO_REV0
|
||||
|| mode == SYS_MODE_EVDO_REVA);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sys_mode_is_evdo (SysMode mode)
|
||||
{
|
||||
return (mode == SYS_MODE_EVDO_REV0 || mode == SYS_MODE_EVDO_REVA);
|
||||
}
|
||||
|
||||
static void
|
||||
status_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
MMModemSierraCdmaPrivate *priv;
|
||||
char **lines, **iter;
|
||||
gboolean registered = FALSE;
|
||||
gboolean have_sid = FALSE;
|
||||
SysMode evdo_mode = SYS_MODE_UNKNOWN;
|
||||
SysMode sys_mode = SYS_MODE_UNKNOWN;
|
||||
gboolean evdo_roam = FALSE, cdma1x_roam = FALSE;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
priv = MM_MODEM_SIERRA_CDMA_GET_PRIVATE (info->modem);
|
||||
|
||||
if (error) {
|
||||
/* Leave superclass' reg state alone if AT!STATUS isn't supported */
|
||||
goto done;
|
||||
}
|
||||
|
||||
lines = g_strsplit_set (response->str, "\n\r", 0);
|
||||
if (!lines) {
|
||||
/* Whatever, just use superclass' registration state */
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Sierra CDMA parts have two general formats depending on whether they
|
||||
* support EVDO or not. EVDO parts report both 1x and EVDO roaming status
|
||||
* while of course 1x parts only report 1x status. Some modems also do not
|
||||
* report the Roaming information (MP 555 GPS).
|
||||
*
|
||||
* AT!STATUS responses:
|
||||
*
|
||||
* Unregistered MC5725:
|
||||
* -----------------------
|
||||
* Current band: PCS CDMA
|
||||
* Current channel: 350
|
||||
* SID: 0 NID: 0 1xRoam: 0 HDRRoam: 0
|
||||
* Temp: 33 State: 100 Sys Mode: NO SRV
|
||||
* Pilot NOT acquired
|
||||
* Modem has NOT registered
|
||||
*
|
||||
* Registered MC5725:
|
||||
* -----------------------
|
||||
* Current band: Cellular Sleep
|
||||
* Current channel: 775
|
||||
* SID: 30 NID: 2 1xRoam: 0 HDRRoam: 0
|
||||
* Temp: 29 State: 200 Sys Mode: HDR
|
||||
* Pilot acquired
|
||||
* Modem has registered
|
||||
* HDR Revision: A
|
||||
*
|
||||
* Unregistered AC580:
|
||||
* -----------------------
|
||||
* Current band: PCS CDMA
|
||||
* Current channel: 350
|
||||
* SID: 0 NID: 0 Roaming: 0
|
||||
* Temp: 39 State: 100 Scan Mode: 0
|
||||
* Pilot NOT acquired
|
||||
* Modem has NOT registered
|
||||
*
|
||||
* Registered AC580:
|
||||
* -----------------------
|
||||
* Current band: Cellular Sleep
|
||||
* Current channel: 548
|
||||
* SID: 26 NID: 1 Roaming: 1
|
||||
* Temp: 39 State: 200 Scan Mode: 0
|
||||
* Pilot Acquired
|
||||
* Modem has registered
|
||||
*/
|
||||
|
||||
/* We have to handle the two formats slightly differently; for newer formats
|
||||
* with "Sys Mode", we consider the modem registered if the Sys Mode is not
|
||||
* "NO SRV". The explicit registration status is just icing on the cake.
|
||||
* For older formats (no "Sys Mode") we treat the modem as registered if
|
||||
* the SID is non-zero.
|
||||
*/
|
||||
|
||||
for (iter = lines; iter && *iter; iter++) {
|
||||
gboolean bool_val = FALSE;
|
||||
char *p;
|
||||
|
||||
if (!strncmp (*iter, MODEM_REG_TAG, strlen (MODEM_REG_TAG))) {
|
||||
registered = TRUE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Roaming */
|
||||
get_roam_value (*iter, ROAM_1X_TAG, TRUE, &cdma1x_roam);
|
||||
get_roam_value (*iter, ROAM_EVDO_TAG, TRUE, &evdo_roam);
|
||||
if (get_roam_value (*iter, GENERIC_ROAM_TAG, FALSE, &bool_val))
|
||||
cdma1x_roam = evdo_roam = bool_val;
|
||||
|
||||
/* Current system mode */
|
||||
p = strstr (*iter, SYS_MODE_TAG);
|
||||
if (p) {
|
||||
p += strlen (SYS_MODE_TAG);
|
||||
while (*p && isspace (*p))
|
||||
p++;
|
||||
if (!strncmp (p, SYS_MODE_NO_SERVICE_TAG, strlen (SYS_MODE_NO_SERVICE_TAG)))
|
||||
sys_mode = SYS_MODE_NO_SERVICE;
|
||||
else if (!strncmp (p, SYS_MODE_EVDO_TAG, strlen (SYS_MODE_EVDO_TAG)))
|
||||
sys_mode = SYS_MODE_EVDO_REV0;
|
||||
else if ( !strncmp (p, SYS_MODE_1X_TAG, strlen (SYS_MODE_1X_TAG))
|
||||
|| !strncmp (p, SYS_MODE_CDMA_TAG, strlen (SYS_MODE_CDMA_TAG)))
|
||||
sys_mode = SYS_MODE_CDMA_1X;
|
||||
}
|
||||
|
||||
/* Current EVDO revision if system mode is EVDO */
|
||||
p = strstr (*iter, EVDO_REV_TAG);
|
||||
if (p) {
|
||||
p += strlen (EVDO_REV_TAG);
|
||||
while (*p && isspace (*p))
|
||||
p++;
|
||||
if (*p == 'A')
|
||||
evdo_mode = SYS_MODE_EVDO_REVA;
|
||||
else if (*p == '0')
|
||||
evdo_mode = SYS_MODE_EVDO_REV0;
|
||||
}
|
||||
|
||||
/* SID */
|
||||
p = strstr (*iter, SID_TAG);
|
||||
if (p) {
|
||||
p += strlen (SID_TAG);
|
||||
while (*p && isspace (*p))
|
||||
p++;
|
||||
if (isdigit (*p) && (*p != '0'))
|
||||
have_sid = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update current system mode */
|
||||
if (sys_mode_is_evdo (sys_mode)) {
|
||||
/* Prefer the explicit EVDO mode from EVDO_REV_TAG */
|
||||
if (evdo_mode != SYS_MODE_UNKNOWN)
|
||||
sys_mode = evdo_mode;
|
||||
}
|
||||
priv->sys_mode = sys_mode;
|
||||
|
||||
/* If the modem didn't report explicit registration with "Modem has
|
||||
* registered" then get registration status by looking at either system
|
||||
* mode or (for older devices that don't report that) just the SID.
|
||||
*/
|
||||
if (!registered) {
|
||||
if (sys_mode != SYS_MODE_UNKNOWN)
|
||||
registered = sys_mode_has_service (sys_mode);
|
||||
else
|
||||
registered = have_sid;
|
||||
}
|
||||
|
||||
if (registered) {
|
||||
mm_generic_cdma_query_reg_state_set_callback_1x_state (info,
|
||||
cdma1x_roam ? MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING :
|
||||
MM_MODEM_CDMA_REGISTRATION_STATE_HOME);
|
||||
|
||||
if (sys_mode_is_evdo (sys_mode)) {
|
||||
mm_generic_cdma_query_reg_state_set_callback_evdo_state (info,
|
||||
evdo_roam ? MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING :
|
||||
MM_MODEM_CDMA_REGISTRATION_STATE_HOME);
|
||||
} else {
|
||||
mm_generic_cdma_query_reg_state_set_callback_evdo_state (info, MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN);
|
||||
}
|
||||
} else {
|
||||
/* Not registered */
|
||||
mm_generic_cdma_query_reg_state_set_callback_1x_state (info, MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN);
|
||||
mm_generic_cdma_query_reg_state_set_callback_evdo_state (info, MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN);
|
||||
}
|
||||
|
||||
done:
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
query_registration_state (MMGenericCdma *cdma,
|
||||
MMModemCdmaRegistrationState cur_cdma_state,
|
||||
MMModemCdmaRegistrationState cur_evdo_state,
|
||||
MMModemCdmaRegistrationStateFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMAtSerialPort *port;
|
||||
|
||||
info = mm_generic_cdma_query_reg_state_callback_info_new (cdma, cur_cdma_state, cur_evdo_state, callback, user_data);
|
||||
|
||||
port = mm_generic_cdma_get_best_at_port (cdma, &info->error);
|
||||
if (!port) {
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_at_serial_port_queue_command (port, "!STATUS", 3, status_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
pcstate_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
/* Ignore errors for now; we're not sure if all Sierra CDMA devices support
|
||||
* at!pcstate.
|
||||
*/
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
post_enable (MMGenericCdma *cdma,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (cdma), callback, user_data);
|
||||
|
||||
primary = mm_generic_cdma_get_at_port (cdma, MM_AT_PORT_FLAG_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
mm_at_serial_port_queue_command (primary, "!pcstate=1", 5, pcstate_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
post_disable (MMGenericCdma *cdma,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (cdma), callback, user_data);
|
||||
|
||||
primary = mm_generic_cdma_get_at_port (cdma, MM_AT_PORT_FLAG_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
mm_at_serial_port_queue_command (primary, "!pcstate=0", 5, pcstate_done, info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mm_modem_sierra_cdma_init (MMModemSierraCdma *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
mm_modem_sierra_cdma_class_init (MMModemSierraCdmaClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
MMGenericCdmaClass *cdma_class = MM_GENERIC_CDMA_CLASS (klass);
|
||||
|
||||
mm_modem_sierra_cdma_parent_class = g_type_class_peek_parent (klass);
|
||||
g_type_class_add_private (object_class, sizeof (MMModemSierraCdmaPrivate));
|
||||
|
||||
cdma_class->query_registration_state = query_registration_state;
|
||||
cdma_class->post_enable = post_enable;
|
||||
cdma_class->post_disable = post_disable;
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_MODEM_SIERRA_CDMA_H
|
||||
#define MM_MODEM_SIERRA_CDMA_H
|
||||
|
||||
#include "mm-generic-cdma.h"
|
||||
|
||||
#define MM_TYPE_MODEM_SIERRA_CDMA (mm_modem_sierra_cdma_get_type ())
|
||||
#define MM_MODEM_SIERRA_CDMA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_SIERRA_CDMA, MMModemSierraCdma))
|
||||
#define MM_MODEM_SIERRA_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_SIERRA_CDMA, MMModemSierraCdmaClass))
|
||||
#define MM_IS_MODEM_SIERRA_CDMA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_SIERRA_CDMA))
|
||||
#define MM_IS_MODEM_SIERRA_CDMA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_MODEM_SIERRA_CDMA))
|
||||
#define MM_MODEM_SIERRA_CDMA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_SIERRA_CDMA, MMModemSierraCdmaClass))
|
||||
|
||||
typedef struct {
|
||||
MMGenericCdma parent;
|
||||
} MMModemSierraCdma;
|
||||
|
||||
typedef struct {
|
||||
MMGenericCdmaClass parent;
|
||||
} MMModemSierraCdmaClass;
|
||||
|
||||
GType mm_modem_sierra_cdma_get_type (void);
|
||||
|
||||
MMModem *mm_modem_sierra_cdma_new (const char *device,
|
||||
const char *driver,
|
||||
const char *plugin,
|
||||
gboolean evdo_rev0,
|
||||
gboolean evdo_revA,
|
||||
guint32 vendor,
|
||||
guint32 product);
|
||||
|
||||
#endif /* MM_MODEM_SIERRA_CDMA_H */
|
||||
@@ -1,917 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 - 2010 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "mm-modem-sierra-gsm.h"
|
||||
#include "mm-errors.h"
|
||||
#include "mm-modem-simple.h"
|
||||
#include "mm-callback-info.h"
|
||||
#include "mm-modem-helpers.h"
|
||||
#include "mm-log.h"
|
||||
#include "mm-modem-icera.h"
|
||||
|
||||
static void modem_init (MMModem *modem_class);
|
||||
static void modem_icera_init (MMModemIcera *icera_class);
|
||||
static void modem_simple_init (MMModemSimple *class);
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (MMModemSierraGsm, mm_modem_sierra_gsm, MM_TYPE_GENERIC_GSM, 0,
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_MODEM, modem_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_MODEM_ICERA, modem_icera_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_MODEM_SIMPLE, modem_simple_init))
|
||||
|
||||
#define MM_MODEM_SIERRA_GSM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_MODEM_SIERRA_GSM, MMModemSierraGsmPrivate))
|
||||
|
||||
typedef struct {
|
||||
guint enable_wait_id;
|
||||
gboolean has_net;
|
||||
char *username;
|
||||
char *password;
|
||||
gboolean is_icera;
|
||||
MMModemIceraPrivate *icera;
|
||||
} MMModemSierraGsmPrivate;
|
||||
|
||||
MMModem *
|
||||
mm_modem_sierra_gsm_new (const char *device,
|
||||
const char *driver,
|
||||
const char *plugin,
|
||||
guint32 vendor,
|
||||
guint32 product)
|
||||
{
|
||||
MMModem *modem;
|
||||
|
||||
g_return_val_if_fail (device != NULL, NULL);
|
||||
g_return_val_if_fail (driver != NULL, NULL);
|
||||
g_return_val_if_fail (plugin != NULL, NULL);
|
||||
|
||||
modem = (MMModem *) g_object_new (MM_TYPE_MODEM_SIERRA_GSM,
|
||||
MM_MODEM_MASTER_DEVICE, device,
|
||||
MM_MODEM_DRIVER, driver,
|
||||
MM_MODEM_PLUGIN, plugin,
|
||||
MM_MODEM_HW_VID, vendor,
|
||||
MM_MODEM_HW_PID, product,
|
||||
NULL);
|
||||
if (modem)
|
||||
MM_MODEM_SIERRA_GSM_GET_PRIVATE (modem)->icera = mm_modem_icera_init_private ();
|
||||
|
||||
return modem;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_allowed_mode_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
GRegex *r = NULL;
|
||||
GMatchInfo *match_info = NULL;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
if (error) {
|
||||
info->error = g_error_copy (error);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Example response: !SELRAT: 03, UMTS 3G Preferred */
|
||||
r = g_regex_new ("!SELRAT:\\s*(\\d+).*$", 0, 0, NULL);
|
||||
if (!r) {
|
||||
info->error = g_error_new_literal (MM_MODEM_ERROR,
|
||||
MM_MODEM_ERROR_GENERAL,
|
||||
"Failed to parse the allowed mode response");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (g_regex_match_full (r, response->str, response->len, 0, 0, &match_info, &info->error)) {
|
||||
MMModemGsmAllowedMode mode = MM_MODEM_GSM_ALLOWED_MODE_ANY;
|
||||
char *str;
|
||||
|
||||
str = g_match_info_fetch (match_info, 1);
|
||||
switch (atoi (str)) {
|
||||
case 0:
|
||||
mode = MM_MODEM_GSM_ALLOWED_MODE_ANY;
|
||||
break;
|
||||
case 1:
|
||||
mode = MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY;
|
||||
break;
|
||||
case 2:
|
||||
mode = MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY;
|
||||
break;
|
||||
case 3:
|
||||
mode = MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED;
|
||||
break;
|
||||
case 4:
|
||||
mode = MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED;
|
||||
break;
|
||||
default:
|
||||
info->error = g_error_new (MM_MODEM_ERROR,
|
||||
MM_MODEM_ERROR_GENERAL,
|
||||
"Failed to parse the allowed mode response: '%s'",
|
||||
response->str);
|
||||
break;
|
||||
}
|
||||
g_free (str);
|
||||
|
||||
mm_callback_info_set_result (info, GUINT_TO_POINTER (mode), NULL);
|
||||
}
|
||||
|
||||
done:
|
||||
if (match_info)
|
||||
g_match_info_free (match_info);
|
||||
if (r)
|
||||
g_regex_unref (r);
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
get_allowed_mode (MMGenericGsm *gsm,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMModemSierraGsm *self = MM_MODEM_SIERRA_GSM (gsm);
|
||||
MMCallbackInfo *info;
|
||||
MMAtSerialPort *primary;
|
||||
|
||||
if (MM_MODEM_SIERRA_GSM_GET_PRIVATE (self)->is_icera) {
|
||||
mm_modem_icera_get_allowed_mode (MM_MODEM_ICERA (self), callback, user_data);
|
||||
return;
|
||||
}
|
||||
|
||||
info = mm_callback_info_uint_new (MM_MODEM (gsm), callback, user_data);
|
||||
|
||||
/* Sierra secondary ports don't have full AT command interpreters */
|
||||
primary = mm_generic_gsm_get_at_port (gsm, MM_AT_PORT_FLAG_PRIMARY);
|
||||
if (!primary || mm_port_get_connected (MM_PORT (primary))) {
|
||||
g_set_error_literal (&info->error, MM_MODEM_ERROR, MM_MODEM_ERROR_CONNECTED,
|
||||
"Cannot perform this operation while connected");
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_at_serial_port_queue_command (primary, "!SELRAT?", 3, get_allowed_mode_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
set_allowed_mode_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
if (error)
|
||||
info->error = g_error_copy (error);
|
||||
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
set_allowed_mode (MMGenericGsm *gsm,
|
||||
MMModemGsmAllowedMode mode,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMModemSierraGsm *self = MM_MODEM_SIERRA_GSM (gsm);
|
||||
MMCallbackInfo *info;
|
||||
MMAtSerialPort *primary;
|
||||
char *command;
|
||||
int idx = 0;
|
||||
|
||||
if (MM_MODEM_SIERRA_GSM_GET_PRIVATE (self)->is_icera) {
|
||||
mm_modem_icera_set_allowed_mode (MM_MODEM_ICERA (self), mode, callback, user_data);
|
||||
return;
|
||||
}
|
||||
|
||||
info = mm_callback_info_new (MM_MODEM (gsm), callback, user_data);
|
||||
|
||||
/* Sierra secondary ports don't have full AT command interpreters */
|
||||
primary = mm_generic_gsm_get_at_port (gsm, MM_AT_PORT_FLAG_PRIMARY);
|
||||
if (!primary || mm_port_get_connected (MM_PORT (primary))) {
|
||||
g_set_error_literal (&info->error, MM_MODEM_ERROR, MM_MODEM_ERROR_CONNECTED,
|
||||
"Cannot perform this operation while connected");
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY:
|
||||
idx = 2;
|
||||
break;
|
||||
case MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY:
|
||||
idx = 1;
|
||||
break;
|
||||
case MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED:
|
||||
idx = 4;
|
||||
break;
|
||||
case MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED:
|
||||
idx = 3;
|
||||
break;
|
||||
case MM_MODEM_GSM_ALLOWED_MODE_ANY:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
command = g_strdup_printf ("!SELRAT=%d", idx);
|
||||
mm_at_serial_port_queue_command (primary, command, 3, set_allowed_mode_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
static void
|
||||
get_act_request_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = user_data;
|
||||
MMModemGsmAccessTech act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
|
||||
const char *p;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
if (error)
|
||||
info->error = g_error_copy (error);
|
||||
else {
|
||||
p = mm_strip_tag (response->str, "*CNTI:");
|
||||
p = strchr (p, ',');
|
||||
if (p)
|
||||
act = mm_gsm_string_to_access_tech (p + 1);
|
||||
}
|
||||
|
||||
mm_callback_info_set_result (info, GUINT_TO_POINTER (act), NULL);
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
get_access_technology (MMGenericGsm *modem,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMModemSierraGsm *self = MM_MODEM_SIERRA_GSM (modem);
|
||||
MMAtSerialPort *port;
|
||||
MMCallbackInfo *info;
|
||||
|
||||
if (MM_MODEM_SIERRA_GSM_GET_PRIVATE (self)->is_icera) {
|
||||
mm_modem_icera_get_access_technology (MM_MODEM_ICERA (self), callback, user_data);
|
||||
return;
|
||||
}
|
||||
|
||||
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
|
||||
|
||||
port = mm_generic_gsm_get_best_at_port (modem, &info->error);
|
||||
if (!port) {
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_at_serial_port_queue_command (port, "*CNTI=0", 3, get_act_request_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
get_sim_iccid_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = user_data;
|
||||
const char *p;
|
||||
char buf[21];
|
||||
int i;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
if (error) {
|
||||
info->error = g_error_copy (error);
|
||||
goto done;
|
||||
}
|
||||
|
||||
p = mm_strip_tag (response->str, "!ICCID:");
|
||||
if (!p) {
|
||||
info->error = g_error_new_literal (MM_MODEM_ERROR,
|
||||
MM_MODEM_ERROR_GENERAL,
|
||||
"Failed to parse !ICCID response");
|
||||
goto done;
|
||||
}
|
||||
|
||||
memset (buf, 0, sizeof (buf));
|
||||
for (i = 0; i < 20; i++) {
|
||||
if (!isdigit (p[i]) && (p[i] != 'F') && (p[i] == 'f')) {
|
||||
info->error = g_error_new (MM_MODEM_ERROR,
|
||||
MM_MODEM_ERROR_GENERAL,
|
||||
"CRSM ICCID response contained invalid character '%c'",
|
||||
p[i]);
|
||||
goto done;
|
||||
}
|
||||
if (p[i] == 'F' || p[i] == 'f') {
|
||||
buf[i] = 0;
|
||||
break;
|
||||
}
|
||||
buf[i] = p[i];
|
||||
}
|
||||
|
||||
if (i == 19 || i == 20)
|
||||
mm_callback_info_set_result (info, g_strdup (buf), g_free);
|
||||
else {
|
||||
info->error = g_error_new (MM_MODEM_ERROR,
|
||||
MM_MODEM_ERROR_GENERAL,
|
||||
"Invalid +CRSM ICCID response size (was %d, expected 19 or 20)",
|
||||
i);
|
||||
}
|
||||
|
||||
done:
|
||||
mm_serial_port_close (MM_SERIAL_PORT (port));
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
get_sim_iccid (MMGenericGsm *modem,
|
||||
MMModemStringFn callback,
|
||||
gpointer callback_data)
|
||||
{
|
||||
MMAtSerialPort *port;
|
||||
MMCallbackInfo *info;
|
||||
GError *error = NULL;
|
||||
|
||||
port = mm_generic_gsm_get_best_at_port (modem, &error);
|
||||
if (!port)
|
||||
goto error;
|
||||
|
||||
if (!mm_serial_port_open (MM_SERIAL_PORT (port), &error))
|
||||
goto error;
|
||||
|
||||
info = mm_callback_info_string_new (MM_MODEM (modem), callback, callback_data);
|
||||
mm_at_serial_port_queue_command (port, "!ICCID?", 3, get_sim_iccid_done, info);
|
||||
return;
|
||||
|
||||
error:
|
||||
callback (MM_MODEM (modem), NULL, error, callback_data);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Modem class override functions */
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
icera_check_cb (MMModem *modem,
|
||||
guint32 result,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (!error) {
|
||||
MMModemSierraGsm *self = MM_MODEM_SIERRA_GSM (user_data);
|
||||
MMModemSierraGsmPrivate *priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (self);
|
||||
|
||||
if (result) {
|
||||
priv->is_icera = TRUE;
|
||||
g_object_set (G_OBJECT (modem),
|
||||
MM_MODEM_IP_METHOD, MM_MODEM_IP_METHOD_STATIC,
|
||||
NULL);
|
||||
|
||||
/* Turn on unsolicited network state messages */
|
||||
mm_modem_icera_change_unsolicited_messages (MM_MODEM_ICERA (modem), TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
sierra_enabled (gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = user_data;
|
||||
MMGenericGsm *modem;
|
||||
MMModemSierraGsmPrivate *priv;
|
||||
|
||||
/* Make sure we don't use an invalid modem that may have been removed */
|
||||
if (info->modem) {
|
||||
modem = MM_GENERIC_GSM (info->modem);
|
||||
priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (modem);
|
||||
priv->enable_wait_id = 0;
|
||||
mm_modem_icera_is_icera (MM_MODEM_ICERA (modem), icera_check_cb, MM_MODEM_SIERRA_GSM (modem));
|
||||
|
||||
MM_GENERIC_GSM_CLASS (mm_modem_sierra_gsm_parent_class)->do_enable_power_up_done (modem, NULL, NULL, info);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
real_do_enable_power_up_done (MMGenericGsm *gsm,
|
||||
GString *response,
|
||||
GError *error,
|
||||
MMCallbackInfo *info)
|
||||
{
|
||||
MMModemSierraGsmPrivate *priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (gsm);
|
||||
char *driver = NULL;
|
||||
|
||||
if (error) {
|
||||
/* Chain up to parent */
|
||||
MM_GENERIC_GSM_CLASS (mm_modem_sierra_gsm_parent_class)->do_enable_power_up_done (gsm, NULL, error, info);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Old Sierra devices (like the PCMCIA-based 860) return OK on +CFUN=1 right
|
||||
* away but need some time to finish initialization. Anything driven by
|
||||
* 'sierra' is new enough to need no delay.
|
||||
*/
|
||||
g_object_get (G_OBJECT (gsm), MM_MODEM_DRIVER, &driver, NULL);
|
||||
if (g_strcmp0 (driver, "sierra") == 0)
|
||||
sierra_enabled (info);
|
||||
else {
|
||||
g_warn_if_fail (priv->enable_wait_id == 0);
|
||||
priv->enable_wait_id = g_timeout_add_seconds (10, sierra_enabled, info);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_current_functionality_status_cb (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = user_data;
|
||||
guint needed = FALSE;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
/* On error, just assume we don't need the power-up command */
|
||||
if (!error) {
|
||||
const gchar *p;
|
||||
|
||||
p = mm_strip_tag (response->str, "+CFUN:");
|
||||
if (p && *p == '1') {
|
||||
/* If reported functionality status is '1', then we do not need to
|
||||
* issue the power-up command. Otherwise, do it. */
|
||||
mm_dbg ("Already in full functionality status, skipping power-up command");
|
||||
} else {
|
||||
needed = TRUE;
|
||||
mm_warn ("Not in full functionality status, power-up command is needed.");
|
||||
}
|
||||
} else
|
||||
mm_warn ("Failed checking if power-up command is needed: '%s'. "
|
||||
"Will assume it isn't.",
|
||||
error->message);
|
||||
|
||||
/* Set result and schedule */
|
||||
mm_callback_info_set_result (info,
|
||||
GUINT_TO_POINTER (needed),
|
||||
NULL);
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
do_enable_power_up_check_needed (MMGenericGsm *self,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMAtSerialPort *primary;
|
||||
MMCallbackInfo *info;
|
||||
|
||||
info = mm_callback_info_uint_new (MM_MODEM (self), callback, user_data);
|
||||
|
||||
/* Get port */
|
||||
primary = mm_generic_gsm_get_at_port (self, MM_AT_PORT_FLAG_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
/* Get current functionality status */
|
||||
mm_dbg ("Getting current functionality status...");
|
||||
mm_at_serial_port_queue_command (primary, "+CFUN?", 3, get_current_functionality_status_cb, info);
|
||||
}
|
||||
|
||||
static void
|
||||
port_grabbed (MMGenericGsm *gsm,
|
||||
MMPort *port,
|
||||
MMAtPortFlags pflags,
|
||||
gpointer user_data)
|
||||
{
|
||||
GRegex *regex;
|
||||
|
||||
if (MM_IS_AT_SERIAL_PORT (port)) {
|
||||
g_object_set (G_OBJECT (port), MM_PORT_CARRIER_DETECT, FALSE, NULL);
|
||||
|
||||
regex = g_regex_new ("\\r\\n\\+PACSP0\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, NULL, NULL);
|
||||
g_regex_unref (regex);
|
||||
|
||||
/* Add Icera-specific handlers */
|
||||
mm_modem_icera_register_unsolicted_handlers (MM_MODEM_ICERA (gsm), MM_AT_SERIAL_PORT (port));
|
||||
} else if (mm_port_get_subsys (port) == MM_PORT_SUBSYS_NET) {
|
||||
MM_MODEM_SIERRA_GSM_GET_PRIVATE (gsm)->has_net = TRUE;
|
||||
g_object_set (G_OBJECT (gsm), MM_MODEM_IP_METHOD, MM_MODEM_IP_METHOD_DHCP, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
ppp_connect_done (MMModem *modem, GError *error, gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = user_data;
|
||||
|
||||
/* Do nothing if modem removed */
|
||||
if (!modem || mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
if (error)
|
||||
info->error = g_error_copy (error);
|
||||
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
net_activate_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
mm_generic_gsm_connect_complete (MM_GENERIC_GSM (info->modem), error, info);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
auth_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
gint cid;
|
||||
char *command;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
if (error) {
|
||||
info->error = g_error_copy (error);
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
cid = mm_generic_gsm_get_cid (MM_GENERIC_GSM (info->modem));
|
||||
g_warn_if_fail (cid >= 0);
|
||||
|
||||
/* Activate data on the net port */
|
||||
command = g_strdup_printf ("!SCACT=1,%d", cid);
|
||||
mm_at_serial_port_queue_command (port, command, 3, net_activate_done, info);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
static void
|
||||
ps_attach_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = user_data;
|
||||
MMModemSierraGsmPrivate *priv;
|
||||
MMModem *parent_modem_iface;
|
||||
const char *number;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
if (error) {
|
||||
info->error = g_error_copy (error);
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (info->modem);
|
||||
if (priv->has_net) {
|
||||
gint cid;
|
||||
char *command;
|
||||
|
||||
/* If we have a net interface, we don't do PPP */
|
||||
|
||||
cid = mm_generic_gsm_get_cid (MM_GENERIC_GSM (info->modem));
|
||||
g_warn_if_fail (cid >= 0);
|
||||
|
||||
if (!priv->username || !priv->password)
|
||||
command = g_strdup_printf ("$QCPDPP=%d,0", cid);
|
||||
else {
|
||||
command = g_strdup_printf ("$QCPDPP=%d,1,\"%s\",\"%s\"",
|
||||
cid,
|
||||
priv->password ? priv->password : "",
|
||||
priv->username ? priv->username : "");
|
||||
|
||||
}
|
||||
|
||||
mm_at_serial_port_queue_command (port, command, 3, auth_done, info);
|
||||
g_free (command);
|
||||
} else {
|
||||
/* We've got a PS attach, chain up to parent for the connect */
|
||||
number = mm_callback_info_get_data (info, "number");
|
||||
parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (info->modem));
|
||||
parent_modem_iface->connect (info->modem, number, ppp_connect_done, info);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_connect (MMModem *modem,
|
||||
const char *number,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info;
|
||||
MMAtSerialPort *port;
|
||||
|
||||
if (MM_MODEM_SIERRA_GSM_GET_PRIVATE (modem)->is_icera) {
|
||||
mm_modem_icera_do_connect (MM_MODEM_ICERA (modem), number, callback, user_data);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_modem_set_state (modem, MM_MODEM_STATE_CONNECTING, MM_MODEM_STATE_REASON_NONE);
|
||||
|
||||
info = mm_callback_info_new (modem, callback, user_data);
|
||||
mm_callback_info_set_data (info, "number", g_strdup (number), g_free);
|
||||
|
||||
port = mm_generic_gsm_get_best_at_port (MM_GENERIC_GSM (modem), &info->error);
|
||||
if (!port) {
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Try to initiate a PS attach. Some Sierra modems can get into a
|
||||
* state where if there is no PS attach when dialing, the next time
|
||||
* the modem tries to connect it won't ever register with the network.
|
||||
*/
|
||||
mm_at_serial_port_queue_command (port, "+CGATT=1", 10, ps_attach_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
get_ip4_config (MMModem *modem,
|
||||
MMModemIp4Fn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMModem *parent_iface;
|
||||
|
||||
if (MM_MODEM_SIERRA_GSM_GET_PRIVATE (modem)->is_icera) {
|
||||
mm_modem_icera_get_ip4_config (MM_MODEM_ICERA (modem), callback, user_data);
|
||||
} else {
|
||||
parent_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (modem));
|
||||
parent_iface->get_ip4_config (modem, callback, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clear_user_pass (MMModemSierraGsm *self)
|
||||
{
|
||||
MMModemSierraGsmPrivate *priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (self);
|
||||
|
||||
g_free (priv->username);
|
||||
priv->username = NULL;
|
||||
g_free (priv->password);
|
||||
priv->password = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
do_disconnect (MMGenericGsm *gsm,
|
||||
gint cid,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMModemSierraGsm *self = MM_MODEM_SIERRA_GSM (gsm);
|
||||
MMModemSierraGsmPrivate *priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (self);
|
||||
|
||||
if (priv->is_icera) {
|
||||
mm_modem_icera_do_disconnect (gsm, cid, callback, user_data);
|
||||
return;
|
||||
}
|
||||
|
||||
clear_user_pass (self);
|
||||
|
||||
if (priv->has_net) {
|
||||
MMAtSerialPort *primary;
|
||||
char *command;
|
||||
|
||||
primary = mm_generic_gsm_get_at_port (gsm, MM_AT_PORT_FLAG_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
/* If we have a net interface, deactivate it */
|
||||
command = g_strdup_printf ("!SCACT=0,%d", cid);
|
||||
mm_at_serial_port_queue_command (primary, command, 3, NULL, NULL);
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
MM_GENERIC_GSM_CLASS (mm_modem_sierra_gsm_parent_class)->do_disconnect (gsm, cid, callback, user_data);
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
disable_unsolicited_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
|
||||
/* If the modem has already been removed, return without
|
||||
* scheduling callback */
|
||||
if (mm_callback_info_check_modem_removed (info))
|
||||
return;
|
||||
|
||||
/* Ignore all errors */
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
static void
|
||||
invoke_call_parent_disable_fn (MMCallbackInfo *info)
|
||||
{
|
||||
/* Note: we won't call the parent disable if info->modem is no longer
|
||||
* valid. The invoke is called always once the info gets scheduled, which
|
||||
* may happen during removed modem detection. */
|
||||
if (info->modem) {
|
||||
MMModem *parent_modem_iface;
|
||||
|
||||
parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (info->modem));
|
||||
parent_modem_iface->disable (info->modem, (MMModemFn)info->callback, info->user_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
do_disable (MMModem *modem,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMModemSierraGsmPrivate *priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (modem);
|
||||
MMAtSerialPort *primary;
|
||||
MMCallbackInfo *info;
|
||||
|
||||
info = mm_callback_info_new_full (modem,
|
||||
invoke_call_parent_disable_fn,
|
||||
(GCallback)callback,
|
||||
user_data);
|
||||
|
||||
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_AT_PORT_FLAG_PRIMARY);
|
||||
g_assert (primary);
|
||||
|
||||
/* Turn off unsolicited responses */
|
||||
if (priv->is_icera) {
|
||||
mm_modem_icera_cleanup (MM_MODEM_ICERA (modem));
|
||||
mm_modem_icera_change_unsolicited_messages (MM_MODEM_ICERA (modem), FALSE);
|
||||
}
|
||||
|
||||
/* Random command to ensure unsolicited message disable completes */
|
||||
mm_at_serial_port_queue_command (primary, "E0", 5, disable_unsolicited_done, info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Simple Modem class override functions */
|
||||
/*****************************************************************************/
|
||||
|
||||
static char *
|
||||
simple_dup_string_property (GHashTable *properties, const char *name, GError **error)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = (GValue *) g_hash_table_lookup (properties, name);
|
||||
if (!value)
|
||||
return NULL;
|
||||
|
||||
if (G_VALUE_HOLDS_STRING (value))
|
||||
return g_value_dup_string (value);
|
||||
|
||||
g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
|
||||
"Invalid property type for '%s': %s (string expected)",
|
||||
name, G_VALUE_TYPE_NAME (value));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
simple_connect (MMModemSimple *simple,
|
||||
GHashTable *properties,
|
||||
MMModemFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMModemSierraGsmPrivate *priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (simple);
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
MMModemSimple *parent_iface;
|
||||
|
||||
if (priv->is_icera) {
|
||||
mm_modem_icera_simple_connect (MM_MODEM_ICERA (simple), properties);
|
||||
} else {
|
||||
clear_user_pass (MM_MODEM_SIERRA_GSM (simple));
|
||||
priv->username = simple_dup_string_property (properties, "username", &info->error);
|
||||
priv->password = simple_dup_string_property (properties, "password", &info->error);
|
||||
}
|
||||
|
||||
parent_iface = g_type_interface_peek_parent (MM_MODEM_SIMPLE_GET_INTERFACE (simple));
|
||||
parent_iface->connect (MM_MODEM_SIMPLE (simple), properties, callback, info);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static MMModemIceraPrivate *
|
||||
get_icera_private (MMModemIcera *icera)
|
||||
{
|
||||
return MM_MODEM_SIERRA_GSM_GET_PRIVATE (icera)->icera;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
modem_init (MMModem *modem_class)
|
||||
{
|
||||
modem_class->connect = do_connect;
|
||||
modem_class->disable = do_disable;
|
||||
modem_class->get_ip4_config = get_ip4_config;
|
||||
}
|
||||
|
||||
static void
|
||||
modem_icera_init (MMModemIcera *icera)
|
||||
{
|
||||
icera->get_private = get_icera_private;
|
||||
}
|
||||
|
||||
static void
|
||||
modem_simple_init (MMModemSimple *class)
|
||||
{
|
||||
class->connect = simple_connect;
|
||||
}
|
||||
|
||||
static void
|
||||
mm_modem_sierra_gsm_init (MMModemSierraGsm *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
MMModemSierraGsm *self = MM_MODEM_SIERRA_GSM (object);
|
||||
MMModemSierraGsmPrivate *priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (self);
|
||||
|
||||
if (priv->enable_wait_id)
|
||||
g_source_remove (priv->enable_wait_id);
|
||||
|
||||
mm_modem_icera_dispose_private (MM_MODEM_ICERA (self));
|
||||
|
||||
clear_user_pass (self);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_modem_sierra_gsm_class_init (MMModemSierraGsmClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
MMGenericGsmClass *gsm_class = MM_GENERIC_GSM_CLASS (klass);
|
||||
|
||||
mm_modem_sierra_gsm_parent_class = g_type_class_peek_parent (klass);
|
||||
g_type_class_add_private (object_class, sizeof (MMModemSierraGsmPrivate));
|
||||
|
||||
object_class->dispose = dispose;
|
||||
gsm_class->port_grabbed = port_grabbed;
|
||||
gsm_class->do_enable_power_up_check_needed = do_enable_power_up_check_needed;
|
||||
gsm_class->do_enable_power_up_done = real_do_enable_power_up_done;
|
||||
gsm_class->set_allowed_mode = set_allowed_mode;
|
||||
gsm_class->get_allowed_mode = get_allowed_mode;
|
||||
gsm_class->get_access_technology = get_access_technology;
|
||||
gsm_class->get_sim_iccid = get_sim_iccid;
|
||||
gsm_class->do_disconnect = do_disconnect;
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_MODEM_SIERRA_GSM_H
|
||||
#define MM_MODEM_SIERRA_GSM_H
|
||||
|
||||
#include "mm-generic-gsm.h"
|
||||
|
||||
#define MM_TYPE_MODEM_SIERRA_GSM (mm_modem_sierra_gsm_get_type ())
|
||||
#define MM_MODEM_SIERRA_GSM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_SIERRA_GSM, MMModemSierraGsm))
|
||||
#define MM_MODEM_SIERRA_GSM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_MODEM_SIERRA_GSM, MMModemSierraGsmClass))
|
||||
#define MM_IS_MODEM_SIERRA_GSM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_SIERRA_GSM))
|
||||
#define MM_IS_MODEM_SIERRA_GSM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_MODEM_SIERRA_GSM))
|
||||
#define MM_MODEM_SIERRA_GSM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_MODEM_SIERRA_GSM, MMModemSierraGsmClass))
|
||||
|
||||
typedef struct {
|
||||
MMGenericGsm parent;
|
||||
} MMModemSierraGsm;
|
||||
|
||||
typedef struct {
|
||||
MMGenericGsmClass parent;
|
||||
} MMModemSierraGsmClass;
|
||||
|
||||
GType mm_modem_sierra_gsm_get_type (void);
|
||||
|
||||
MMModem *mm_modem_sierra_gsm_new (const char *device,
|
||||
const char *driver,
|
||||
const char *plugin_name,
|
||||
guint32 vendor,
|
||||
guint32 product);
|
||||
|
||||
#endif /* MM_MODEM_SIERRA_GSM_H */
|
||||
@@ -1,244 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <gmodule.h>
|
||||
#include "mm-plugin-sierra.h"
|
||||
#include "mm-modem-sierra-gsm.h"
|
||||
#include "mm-modem-sierra-cdma.h"
|
||||
|
||||
G_DEFINE_TYPE (MMPluginSierra, mm_plugin_sierra, MM_TYPE_PLUGIN_BASE)
|
||||
|
||||
int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
|
||||
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
|
||||
|
||||
G_MODULE_EXPORT MMPlugin *
|
||||
mm_plugin_create (void)
|
||||
{
|
||||
return MM_PLUGIN (g_object_new (MM_TYPE_PLUGIN_SIERRA,
|
||||
MM_PLUGIN_BASE_NAME, "Sierra",
|
||||
NULL));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define TAG_SIERRA_APP1_PORT "sierra-app1-port"
|
||||
#define TAG_SIERRA_APP_PPP_OK "sierra-app-ppp-ok"
|
||||
|
||||
#define CAP_CDMA (MM_PLUGIN_BASE_PORT_CAP_IS707_A | \
|
||||
MM_PLUGIN_BASE_PORT_CAP_IS707_P | \
|
||||
MM_PLUGIN_BASE_PORT_CAP_IS856 | \
|
||||
MM_PLUGIN_BASE_PORT_CAP_IS856_A)
|
||||
|
||||
static guint32
|
||||
get_level_for_capabilities (guint32 capabilities)
|
||||
{
|
||||
if (capabilities & MM_PLUGIN_BASE_PORT_CAP_GSM)
|
||||
return 10;
|
||||
if (capabilities & CAP_CDMA)
|
||||
return 10;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_probe_response (MMPluginBase *self,
|
||||
MMPluginBaseSupportsTask *task,
|
||||
const char *cmd,
|
||||
const char *response,
|
||||
const GError *error)
|
||||
{
|
||||
if (error || !response || strcmp (cmd, "I")) {
|
||||
MM_PLUGIN_BASE_CLASS (mm_plugin_sierra_parent_class)->handle_probe_response (self, task, cmd, response, error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr (response, "APP1")) {
|
||||
g_object_set_data (G_OBJECT (task), TAG_SIERRA_APP1_PORT, GUINT_TO_POINTER (TRUE));
|
||||
|
||||
/* 885 can handle PPP on the APP ports, leaving the primary port open
|
||||
* for command and status while connected. Older modems (ie 8775) say
|
||||
* they can but fail during PPP.
|
||||
*/
|
||||
if (strstr (response, "C885"))
|
||||
g_object_set_data (G_OBJECT (task), TAG_SIERRA_APP_PPP_OK, GUINT_TO_POINTER (TRUE));
|
||||
|
||||
mm_plugin_base_supports_task_complete (task, 10);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Not an app port, let the superclass handle the response */
|
||||
MM_PLUGIN_BASE_CLASS (mm_plugin_sierra_parent_class)->handle_probe_response (self, task, cmd, response, error);
|
||||
}
|
||||
|
||||
static void
|
||||
probe_result (MMPluginBase *base,
|
||||
MMPluginBaseSupportsTask *task,
|
||||
guint32 capabilities,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (capabilities));
|
||||
}
|
||||
|
||||
static MMPluginSupportsResult
|
||||
supports_port (MMPluginBase *base,
|
||||
MMModem *existing,
|
||||
MMPluginBaseSupportsTask *task)
|
||||
{
|
||||
GUdevDevice *port;
|
||||
const char *driver, *subsys;
|
||||
|
||||
/* Can't do anything with non-serial ports */
|
||||
port = mm_plugin_base_supports_task_get_port (task);
|
||||
if (!port)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
driver = mm_plugin_base_supports_task_get_driver (task);
|
||||
if (!driver || (strcmp (driver, "sierra") && strcmp (driver, "sierra_net")))
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
|
||||
subsys = g_udev_device_get_subsystem (port);
|
||||
g_assert (subsys);
|
||||
if (!strcmp (subsys, "net")) {
|
||||
/* Can't grab the net port until we know whether this is a CDMA or GSM device */
|
||||
if (!existing)
|
||||
return MM_PLUGIN_SUPPORTS_PORT_DEFER;
|
||||
|
||||
mm_plugin_base_supports_task_complete (task, 10);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
}
|
||||
|
||||
/* Check if a previous probing was already launched in this port */
|
||||
if (mm_plugin_base_supports_task_propagate_cached (task)) {
|
||||
guint32 level;
|
||||
|
||||
/* A previous probing was already done, use its results */
|
||||
level = get_level_for_capabilities (mm_plugin_base_supports_task_get_probed_capabilities (task));
|
||||
if (level) {
|
||||
mm_plugin_base_supports_task_complete (task, level);
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
}
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/* Otherwise kick off a probe */
|
||||
if (mm_plugin_base_probe_port (base, task, 100000, NULL))
|
||||
return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
|
||||
|
||||
return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
|
||||
}
|
||||
|
||||
static MMModem *
|
||||
grab_port (MMPluginBase *base,
|
||||
MMModem *existing,
|
||||
MMPluginBaseSupportsTask *task,
|
||||
GError **error)
|
||||
{
|
||||
GUdevDevice *port = NULL;
|
||||
MMModem *modem = NULL;
|
||||
const char *name, *subsys, *sysfs_path;
|
||||
guint32 caps;
|
||||
MMPortType ptype;
|
||||
guint16 vendor = 0, product = 0;
|
||||
MMAtPortFlags pflags = MM_AT_PORT_FLAG_NONE;
|
||||
|
||||
port = mm_plugin_base_supports_task_get_port (task);
|
||||
g_assert (port);
|
||||
|
||||
subsys = g_udev_device_get_subsystem (port);
|
||||
name = g_udev_device_get_name (port);
|
||||
|
||||
caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
|
||||
ptype = mm_plugin_base_probed_capabilities_to_port_type (caps);
|
||||
|
||||
/* Is it a GSM secondary port? */
|
||||
if (g_object_get_data (G_OBJECT (task), TAG_SIERRA_APP1_PORT)) {
|
||||
if (g_object_get_data (G_OBJECT (task), TAG_SIERRA_APP_PPP_OK))
|
||||
pflags = MM_AT_PORT_FLAG_PPP;
|
||||
else
|
||||
pflags = MM_AT_PORT_FLAG_SECONDARY;
|
||||
|
||||
/* Secondary ports may not be tagged as AT since they only speak a
|
||||
* limited command set. But we know they're AT if they are tagged
|
||||
* as secondary ports.
|
||||
*/
|
||||
ptype = MM_PORT_TYPE_AT;
|
||||
} else if (ptype == MM_PORT_TYPE_AT)
|
||||
pflags = MM_AT_PORT_FLAG_PRIMARY;
|
||||
|
||||
if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) {
|
||||
g_set_error (error, 0, 0, "Could not get modem product ID.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sysfs_path = mm_plugin_base_supports_task_get_physdev_path (task);
|
||||
if (!existing) {
|
||||
if ((caps & MM_PLUGIN_BASE_PORT_CAP_GSM) || (ptype != MM_PORT_TYPE_UNKNOWN)) {
|
||||
modem = mm_modem_sierra_gsm_new (sysfs_path,
|
||||
mm_plugin_base_supports_task_get_driver (task),
|
||||
mm_plugin_get_name (MM_PLUGIN (base)),
|
||||
vendor,
|
||||
product);
|
||||
} else if (caps & CAP_CDMA) {
|
||||
modem = mm_modem_sierra_cdma_new (sysfs_path,
|
||||
mm_plugin_base_supports_task_get_driver (task),
|
||||
mm_plugin_get_name (MM_PLUGIN (base)),
|
||||
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856),
|
||||
!!(caps & MM_PLUGIN_BASE_PORT_CAP_IS856_A),
|
||||
vendor,
|
||||
product);
|
||||
}
|
||||
|
||||
if (modem) {
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, pflags, NULL, error)) {
|
||||
g_object_unref (modem);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
} else if ( get_level_for_capabilities (caps)
|
||||
|| (ptype != MM_PORT_TYPE_UNKNOWN)
|
||||
|| (strcmp (subsys, "net") == 0)) {
|
||||
|
||||
/* FIXME: we don't yet know how to activate IP on CDMA devices using
|
||||
* pseudo-ethernet ports.
|
||||
*/
|
||||
if (strcmp (subsys, "net") == 0 && MM_IS_MODEM_SIERRA_CDMA (modem))
|
||||
return modem;
|
||||
|
||||
modem = existing;
|
||||
if (!mm_modem_grab_port (modem, subsys, name, ptype, pflags, NULL, error))
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return modem;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
mm_plugin_sierra_init (MMPluginSierra *self)
|
||||
{
|
||||
g_signal_connect (self, "probe-result", G_CALLBACK (probe_result), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_plugin_sierra_class_init (MMPluginSierraClass *klass)
|
||||
{
|
||||
MMPluginBaseClass *pb_class = MM_PLUGIN_BASE_CLASS (klass);
|
||||
|
||||
pb_class->supports_port = supports_port;
|
||||
pb_class->grab_port = grab_port;
|
||||
pb_class->handle_probe_response = handle_probe_response;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2008 - 2009 Novell, Inc.
|
||||
* Copyright (C) 2009 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_PLUGIN_SIERRA_H
|
||||
#define MM_PLUGIN_SIERRA_H
|
||||
|
||||
#include "mm-plugin-base.h"
|
||||
#include "mm-generic-gsm.h"
|
||||
|
||||
#define MM_TYPE_PLUGIN_SIERRA (mm_plugin_sierra_get_type ())
|
||||
#define MM_PLUGIN_SIERRA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_SIERRA, MMPluginSierra))
|
||||
#define MM_PLUGIN_SIERRA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MM_TYPE_PLUGIN_SIERRA, MMPluginSierraClass))
|
||||
#define MM_IS_PLUGIN_SIERRA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_PLUGIN_SIERRA))
|
||||
#define MM_IS_PLUGIN_SIERRA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MM_TYPE_PLUGIN_SIERRA))
|
||||
#define MM_PLUGIN_SIERRA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MM_TYPE_PLUGIN_SIERRA, MMPluginSierraClass))
|
||||
|
||||
typedef struct {
|
||||
MMPluginBase parent;
|
||||
} MMPluginSierra;
|
||||
|
||||
typedef struct {
|
||||
MMPluginBaseClass parent;
|
||||
} MMPluginSierraClass;
|
||||
|
||||
GType mm_plugin_sierra_get_type (void);
|
||||
|
||||
G_MODULE_EXPORT MMPlugin *mm_plugin_create (void);
|
||||
|
||||
#endif /* MM_PLUGIN_SIERRA_H */
|
||||
Reference in New Issue
Block a user