gobi: access technology loading implementation

This commit is contained in:
Aleksander Morgado
2012-02-19 10:50:11 +01:00
parent 1359c0a928
commit d09dfbb7d1

View File

@@ -12,7 +12,7 @@
* *
* Copyright (C) 2008 - 2009 Novell, Inc. * Copyright (C) 2008 - 2009 Novell, Inc.
* Copyright (C) 2009 - 2011 Red Hat, Inc. * Copyright (C) 2009 - 2011 Red Hat, Inc.
* Copyright (C) 2011 Google Inc. * Copyright (C) 2011 - 2012 Google Inc.
*/ */
#include <config.h> #include <config.h>
@@ -24,10 +24,12 @@
#include <ctype.h> #include <ctype.h>
#include "ModemManager.h" #include "ModemManager.h"
#include "mm-modem-helpers.h"
#include "mm-serial-parsers.h" #include "mm-serial-parsers.h"
#include "mm-log.h" #include "mm-log.h"
#include "mm-errors-types.h" #include "mm-errors-types.h"
#include "mm-iface-modem.h" #include "mm-iface-modem.h"
#include "mm-iface-modem-3gpp.h"
#include "mm-base-modem-at.h" #include "mm-base-modem-at.h"
#include "mm-broadband-modem-gobi.h" #include "mm-broadband-modem-gobi.h"
@@ -36,6 +38,54 @@ static void iface_modem_init (MMIfaceModem *iface);
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemGobi, mm_broadband_modem_gobi, MM_TYPE_BROADBAND_MODEM, 0, G_DEFINE_TYPE_EXTENDED (MMBroadbandModemGobi, mm_broadband_modem_gobi, MM_TYPE_BROADBAND_MODEM, 0,
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)); G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init));
/*****************************************************************************/
/* Load access technologies (Modem interface) */
static gboolean
load_access_technologies_finish (MMIfaceModem *self,
GAsyncResult *res,
MMModemAccessTechnology *access_technologies,
guint *mask,
GError **error)
{
const gchar *p;
const gchar *response;
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
if (!response)
return FALSE;
p = mm_strip_tag (response, "*CNTI:");
p = strchr (p, ',');
if (p) {
/* We are reporting ALL 3GPP access technologies here */
*access_technologies = mm_3gpp_string_to_access_tech (p + 1);
*mask = MM_IFACE_MODEM_3GPP_ALL_ACCESS_TECHNOLOGIES_MASK;
return TRUE;
}
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Couldn't parse access technologies result: '%s'",
response);
return FALSE;
}
static void
load_access_technologies (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
mm_base_modem_at_command (MM_BASE_MODEM (self),
"*CNTI=0",
3,
FALSE,
NULL, /* cancellable */
callback,
user_data);
}
/*****************************************************************************/ /*****************************************************************************/
MMBroadbandModemGobi * MMBroadbandModemGobi *
@@ -62,6 +112,9 @@ mm_broadband_modem_gobi_init (MMBroadbandModemGobi *self)
static void static void
iface_modem_init (MMIfaceModem *iface) iface_modem_init (MMIfaceModem *iface)
{ {
iface->load_access_technologies = load_access_technologies;
iface->load_access_technologies_finish = load_access_technologies_finish;
iface->modem_power_down = NULL; iface->modem_power_down = NULL;
iface->modem_power_down_finish = NULL; iface->modem_power_down_finish = NULL;
} }