Merge remote branch 'origin/master' into qcdm

This commit is contained in:
Dan Williams
2010-03-08 20:01:22 -08:00
27 changed files with 2056 additions and 757 deletions

View File

@@ -13,4 +13,5 @@ EXTRA_DIST = \
mm-modem-gsm-network.xml \ mm-modem-gsm-network.xml \
mm-modem-gsm-sms.xml \ mm-modem-gsm-sms.xml \
mm-modem-simple.xml \ mm-modem-simple.xml \
mm-serial-error.xml mm-serial-error.xml \
mm-modem-location.xml

View File

@@ -25,6 +25,7 @@
<xi:include href="mm-manager.xml"/> <xi:include href="mm-manager.xml"/>
<xi:include href="mm-modem.xml"/> <xi:include href="mm-modem.xml"/>
<xi:include href="mm-modem-simple.xml"/> <xi:include href="mm-modem-simple.xml"/>
<xi:include href="mm-modem-location.xml"/>
<xi:include href="mm-modem-cdma.xml"/> <xi:include href="mm-modem-cdma.xml"/>
<xi:include href="mm-modem-gsm.xml"/> <xi:include href="mm-modem-gsm.xml"/>
<xi:include href="mm-modem-gsm-card.xml"/> <xi:include href="mm-modem-gsm-card.xml"/>

View File

@@ -96,11 +96,17 @@
</method> </method>
<property name="SupportedBands" type="u" access="read" tp:type="MM_MODEM_GSM_BAND"> <property name="SupportedBands" type="u" access="read" tp:type="MM_MODEM_GSM_BAND">
<tp:docstring>Bands supported by the card. (Note for plugin writers: returned value must not contain ANY)</tp:docstring> <tp:docstring>
Bands supported by the card. (Note for plugin writers:
returned value must not contain ANY)
</tp:docstring>
</property> </property>
<property name="SupportedModes" type="u" access="read" tp:type="MM_MODEM_GSM_MODE"> <property name="SupportedModes" type="u" access="read" tp:type="MM_MODEM_GSM_MODE">
<tp:docstring>Network selection modes supported by the card. (Note for plugin writers: returned value must not contain ANY)</tp:docstring> <tp:docstring>
Network selection modes supported by the card. (Note for plugin writers:
returned value must not contain ANY)
</tp:docstring>
</property> </property>
</interface> </interface>

View File

@@ -82,11 +82,12 @@
<method name="SetNetworkMode"> <method name="SetNetworkMode">
<tp:docstring> <tp:docstring>
Set the desired mode the device may use when connecting to a mobile network. Set the desired mode the device may use when connecting to a mobile
network (DEPRECATED; see SetAllowedMode instead).
</tp:docstring> </tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_gsm_modem_set_network_mode"/> <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_gsm_modem_set_network_mode"/>
<arg name="mode" type="u" direction="in" tp:type="MM_MODEM_GSM_MODE"> <arg name="mode" type="u" direction="in" tp:type="MM_MODEM_GSM_NETWORK_DEPRECATED_MODE">
<tp:docstring> <tp:docstring>
The desired network mode. Only one mode may be specified, and may not be UNKNOWN. The desired network mode. Only one mode may be specified, and may not be UNKNOWN.
</tp:docstring> </tp:docstring>
@@ -95,11 +96,14 @@
<method name="GetNetworkMode"> <method name="GetNetworkMode">
<tp:docstring> <tp:docstring>
Returns the current network mode of the device. (Note for plugin writers: returned value *may* be ANY) Returns the current network mode of the device (DEPRECATED; does not
allow returning both the saved mode preference *and* the current access
technology of the device at the same time. See the AllowedMode
property instead).
</tp:docstring> </tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/> <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_gsm_modem_get_network_mode"/> <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_gsm_modem_get_network_mode"/>
<arg name="mode" type="u" direction="out" tp:type="MM_MODEM_GSM_MODE"> <arg name="mode" type="u" direction="out" tp:type="MM_MODEM_GSM_NETWORK_DEPRECATED_MODE">
<tp:docstring> <tp:docstring>
Returns the general network mode (ex. 2G/3G preference) of the device. Returns the general network mode (ex. 2G/3G preference) of the device.
</tp:docstring> </tp:docstring>
@@ -122,6 +126,37 @@
</arg> </arg>
</method> </method>
<method name="SetAllowedMode">
<tp:docstring>
Set the access technologies a device is allowed to use when connecting
to a mobile network.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_gsm_modem_set_allowed_mode"/>
<arg name="mode" type="u" direction="in" tp:type="MM_MODEM_GSM_ALLOWED_MODE">
<tp:docstring>
The allowed mode. The device may not support all modes; see
the org.freedesktop.ModemManager.Gsm.Card.SupportedModes property for
allowed modes for each device. All devices support the "ANY" flag.
</tp:docstring>
</arg>
</method>
<property name="AllowedMode" type="u" access="read" tp:type="MM_MODEM_GSM_ALLOWED_MODE">
<tp:docstring>
The allowed access technologies (eg 2G/3G preference) the device is allowed
to use when connecting to a mobile network.
</tp:docstring>
</property>
<property name="AccessTechnology" type="u" access="read" tp:type="MM_MODEM_GSM_ACCESS_TECH">
<tp:docstring>
The current network access technology used by the device to communicate
with the base station. (Note to plugin writers: if the device's access
technology cannot be determined, use UNKNOWN)
</tp:docstring>
</property>
<signal name="SignalQuality"> <signal name="SignalQuality">
<tp:docstring> <tp:docstring>
The signal quality changed. The signal quality changed.
@@ -156,12 +191,11 @@
<signal name="NetworkMode"> <signal name="NetworkMode">
<tp:docstring> <tp:docstring>
The network mode changed. The network mode preference changed. (DEPRECATED; see documentation
for GetNetworkMode/SetNetworkMode)
</tp:docstring> </tp:docstring>
<arg name="mode" type="u" tp:type="MM_MODEM_GSM_MODE"> <arg name="mode" type="u" tp:type="MM_MODEM_GSM_NETWORK_DEPRECATED_MODE">
<tp:docstring> <tp:docstring>The new network mode.</tp:docstring>
The new network mode.
</tp:docstring>
</arg> </arg>
</signal> </signal>
@@ -198,5 +232,45 @@
</tp:enumvalue> </tp:enumvalue>
</tp:enum> </tp:enum>
<tp:enum name="MM_MODEM_GSM_NETWORK_DEPRECATED_MODE" type="u">
<tp:docstring>
DEPRECATED; should not be used in new applications. Use
AccessTechnology, AllowedMode, and SetAllowedMode() instead.
</tp:docstring>
<tp:enumvalue suffix="ANY" value="0">
<tp:docstring>Any network mode can be used</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="GPRS" value="1">
<tp:docstring>GPRS</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="EDGE" value="2">
<tp:docstring>EDGE</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="UMTS" value="3">
<tp:docstring>UMTS (3G)</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="HSDPA" value="4">
<tp:docstring>HSDPA</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="2G_PREFERRED" value="5">
<tp:docstring>Prefer 2G (GPRS or EDGE)</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="3G_PREFERRED" value="6">
<tp:docstring>Prefer 3G (UMTS/HSDPA/HSUPA/HSPA)</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="2G_ONLY" value="7">
<tp:docstring>Use only 2G (GPRS or EDGE)</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="3G_ONLY" value="8">
<tp:docstring>Use only 3G (UMTS/HSDPA/HSUPA/HSPA)</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="HSUPA" value="9">
<tp:docstring>HSUPA</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="HSPA" value="10">
<tp:docstring>HSPA (HSDPA + HSUPA)</tp:docstring>
</tp:enumvalue>
</tp:enum>
</interface> </interface>
</node> </node>

View File

@@ -3,6 +3,11 @@
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"> <node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.ModemManager.Modem.Gsm"> <interface name="org.freedesktop.ModemManager.Modem.Gsm">
<tp:flags name="MM_MODEM_GSM_MODE" value-prefix="MM_MODEM_GSM_MODE" type="u"> <tp:flags name="MM_MODEM_GSM_MODE" value-prefix="MM_MODEM_GSM_MODE" type="u">
<tp:docstring>
A bitfield describing the specifc access modes and technologies
supported by a device and the access technology in-use when connected to
a mobile network.
</tp:docstring>
<tp:flag suffix="UNKNOWN" value="0x0"> <tp:flag suffix="UNKNOWN" value="0x0">
<tp:docstring>Unknown or invalid mode.</tp:docstring> <tp:docstring>Unknown or invalid mode.</tp:docstring>
</tp:flag> </tp:flag>
@@ -19,28 +24,39 @@
<tp:docstring>UMTS (3G)</tp:docstring> <tp:docstring>UMTS (3G)</tp:docstring>
</tp:flag> </tp:flag>
<tp:flag suffix="HSDPA" value="0x10"> <tp:flag suffix="HSDPA" value="0x10">
<tp:docstring>HSDPA</tp:docstring> <tp:docstring>HSDPA (3G)</tp:docstring>
</tp:flag> </tp:flag>
<tp:flag suffix="2G_PREFERRED" value="0x20"> <tp:flag suffix="2G_PREFERRED" value="0x20">
<tp:docstring>Prefer 2G (GPRS or EDGE)</tp:docstring> <tp:docstring>Prefer 2G (GPRS or EDGE)</tp:docstring>
</tp:flag> </tp:flag>
<tp:flag suffix="3G_PREFERRED" value="0x40"> <tp:flag suffix="3G_PREFERRED" value="0x40">
<tp:docstring>Prefer 3G (UMTS or HSDPA)</tp:docstring> <tp:docstring>Prefer 3G (UMTS/HSDPA/HSUPA/HSPA)</tp:docstring>
</tp:flag> </tp:flag>
<tp:flag suffix="2G_ONLY" value="0x80"> <tp:flag suffix="2G_ONLY" value="0x80">
<tp:docstring>Use only 2G (GPRS or EDGE)</tp:docstring> <tp:docstring>Use only 2G (GPRS or EDGE)</tp:docstring>
</tp:flag> </tp:flag>
<tp:flag suffix="3G_ONLY" value="0x100"> <tp:flag suffix="3G_ONLY" value="0x100">
<tp:docstring>Use only 3G (UMTS or HSDPA)</tp:docstring> <tp:docstring>Use only 3G (UMTS/HSDPA/HSUPA/HSPA)</tp:docstring>
</tp:flag> </tp:flag>
<tp:flag suffix="HSUPA" value="0x200"> <tp:flag suffix="HSUPA" value="0x200">
<tp:docstring>HSUPA</tp:docstring> <tp:docstring>HSUPA (3G)</tp:docstring>
</tp:flag>
<tp:flag suffix="HSPA" value="0x400">
<tp:docstring>HSPA (3G)</tp:docstring>
</tp:flag>
<tp:flag suffix="GSM" value="0x800">
<tp:docstring>GSM</tp:docstring>
</tp:flag>
<tp:flag suffix="GSM_COMPACT" value="0x1000">
<tp:docstring>GSM Compact</tp:docstring>
</tp:flag> </tp:flag>
</tp:flags> </tp:flags>
<tp:flags name="MM_MODEM_GSM_BAND" value-prefix="MM_MODEM_GSM_BAND" type="u"> <tp:flags name="MM_MODEM_GSM_BAND" value-prefix="MM_MODEM_GSM_BAND" type="u">
<tp:docstring> <tp:docstring>
GSM network and device bands. A bitfield describing the specific radio bands supported by the device
and the radio bands the device is allowed to use when connecting to a
mobile network.
</tp:docstring> </tp:docstring>
<tp:flag suffix="UNKNOWN" value="0x0"> <tp:flag suffix="UNKNOWN" value="0x0">
<tp:docstring>Unknown or invalid band</tp:docstring> <tp:docstring>Unknown or invalid band</tp:docstring>
@@ -82,5 +98,64 @@
<tp:docstring>WCDMA 3GPP UMTS 1700 MHz (Class IX)</tp:docstring> <tp:docstring>WCDMA 3GPP UMTS 1700 MHz (Class IX)</tp:docstring>
</tp:flag> </tp:flag>
</tp:flags> </tp:flags>
<tp:enum name="MM_MODEM_GSM_ALLOWED_MODE" type="u">
<tp:docstring>
Describes the device's current access mode preference; ie the specific
technology preferences the device is allowed to use when connecting to
a mobile network.
</tp:docstring>
<tp:enumvalue suffix="ANY" value="0">
<tp:docstring>Any mode can be used</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="2G_PREFERRED" value="1">
<tp:docstring>Prefer 2G (GPRS or EDGE)</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="3G_PREFERRED" value="2">
<tp:docstring>Prefer 3G (UMTS or HSxPA)</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="2G_ONLY" value="3">
<tp:docstring>Use only 2G (GPRS or EDGE)</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="3G_ONLY" value="4">
<tp:docstring>Use only 3G (UMTS or HSxPA)</tp:docstring>
</tp:enumvalue>
</tp:enum>
<tp:enum name="MM_MODEM_GSM_ACCESS_TECH" type="u">
<tp:docstring>
Describes various access technologies that a device uses when connected
to a mobile network.
</tp:docstring>
<tp:enumvalue suffix="UNKNOWN" value="0">
<tp:docstring>The access technology used is unknown</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="GSM" value="1">
<tp:docstring>GSM</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="GSM_COMPACT" value="2">
<tp:docstring>Compact GSM</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="GPRS" value="3">
<tp:docstring>GPRS</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="EDGE" value="4">
<tp:docstring>EDGE (ETSI 27.007: "GSM w/EGPRS")</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="UMTS" value="5">
<tp:docstring>UMTS (ETSI 27.007: "UTRAN")</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="HSDPA" value="6">
<tp:docstring>HSDPA (ETSI 27.007: "UTRAN w/HSDPA")</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="HSUPA" value="7">
<tp:docstring>HSUPA (ETSI 27.007: "UTRAN w/HSUPA")</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="HSPA" value="8">
<tp:docstring>HSPA (ETSI 27.007: "UTRAN w/HSDPA and HSUPA")</tp:docstring>
</tp:enumvalue>
</tp:enum>
</interface> </interface>
</node> </node>

View File

@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8" ?>
<node name="/" xmlns:tp="http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0">
<interface name="org.freedesktop.ModemManager.Modem.Location">
<tp:docstring>
This interface allows devices to provide location information to client
applications. Not all devices can provide this information, or even if
they do, they may not be able to provide it while a data session is
active.
</tp:docstring>
<property name="Capabilities" type="u" access="read" tp:type="MM_MODEM_LOCATION_CAPABILITIES">
<tp:docstring>
Location capabilities of the device.
</tp:docstring>
</property>
<property name="Enabled" type="b" access="read">
<tp:docstring>
TRUE if location information gathering is enabled for this device, FALSE
if it is disabled. When disabled, the device will not provide location
information.
</tp:docstring>
</property>
<method name="Enable">
<tp:docstring>
Enable or disable location information gathering. This method may
require the client to authenticate itself.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_modem_location_enable"/>
<arg name="enable" type="b" direction="in">
<tp:docstring>
TRUE to enable location information gathering, FALSE to disable.
</tp:docstring>
</arg>
<arg name="signal_location" type="b" direction="in">
<tp:docstring>
When enabling location information gathering, this argument controls
whether the device emits signals with new location information or not.
When signals are emitted, any client application (including malicious
ones!) can listen for location updates unless D-Bus permissions
restrict these signals from certain users. If further security is
desired, this argument can be set to FALSE to disable location
updates via D-Bus signals and require applications to call
authenticated APIs (like GetLocation) to get location information.
This argument is ignored when disabling location information
gathering.
</tp:docstring>
</arg>
</method>
<method name="GetLocation">
<tp:docstring>
Return current location information, if any. This method may require
the client to authenticate itself.
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_modem_location_get_location"/>
<arg name="Location" type="a{uv}" access="read" direction="out" tp:type="Location_Information_Map">
<tp:docstring>
Dict of available location information when location information
gathering is enabled. If the modem supports multiple location types
it may return more than one here.
</tp:docstring>
</arg>
</method>
<property name="SignalsLocation" type="b" access="read">
<tp:docstring>
TRUE if location updates will be emitted via D-Bus signals, FALSE
if location updates will not be emitted. See the Enable method for
more information.
</tp:docstring>
</property>
<property name="Location" type="a{uv}" access="read" tp:type="Location_Information_Map">
<tp:docstring>
Dict of available location information when location information
gathering is enabled. If the modem supports multiple location types
it may return more than one here. Note that if the device was told
not to emit updated location information when location information
gathering was initially enabled, this property may not return
any location information for security reasons.
</tp:docstring>
</property>
<tp:mapping name="Location_Information_Map">
<tp:docstring>
A mapping from location type to type-specific location information.
</tp:docstring>
<tp:member type="u" name="Type" tp:type="MM_MODEM_LOCATION_CAPABILITIES">
<tp:docstring>
Identifies the type and format of the associated location information. Contrary to the value description, this is not a bitfield but uses the same values as the MM_MODEM_LOCATION_CAPABILITIES bitfield.
</tp:docstring>
</tp:member>
<tp:member type="v" name="Data">
<tp:docstring>
Contains type-specific location information. GSM_LAC_CI data is a string with the format "LAC,CI" (ex "84CD,00D30156") while GPS_NMEA is a string in NMEA-compatible format.
</tp:docstring>
</tp:member>
</tp:mapping>
<tp:flags name="MM_MODEM_LOCATION_CAPABILITIES" value-prefix="MM_MODEM_LOCATION_CAPABILITY" type="u">
<tp:flag suffix="UNKNOWN" value="0x0">
<tp:docstring>Unknown or no capabilties.</tp:docstring>
</tp:flag>
<tp:flag suffix="ANY" value="0x1">
<tp:docstring>Reserved.</tp:docstring>
</tp:flag>
<tp:flag suffix="GPS_NMEA" value="0x2">
<tp:docstring>The device is capable of providing GPS NMEA-format location information.</tp:docstring>
</tp:flag>
<tp:flag suffix="GSM_LAC_CI" value="0x4">
<tp:docstring>The device is capable of providing GSM Location Area Code/Cell ID location information.</tp:docstring>
</tp:flag>
</tp:flags>
</interface>
</node>

View File

@@ -287,40 +287,6 @@ mm_hso_modem_authenticate (MMModemHso *self,
/*****************************************************************************/ /*****************************************************************************/
static void
enable_done (MMModem *modem, GError *error, gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (modem), error, info);
}
static void
parent_enable_done (MMModem *modem, GError *error, gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
MMGenericGsm *self = MM_GENERIC_GSM (modem);
if (error) {
mm_generic_gsm_enable_complete (self, error, info);
return;
}
/* HSO needs manual PIN checking */
mm_generic_gsm_check_pin (self, enable_done, info);
}
static void
enable (MMModem *modem, MMModemFn callback, gpointer user_data)
{
MMModem *parent_modem_iface;
MMCallbackInfo *info;
info = mm_callback_info_new (modem, callback, user_data);
parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (info->modem));
parent_modem_iface->enable (info->modem, parent_enable_done, info);
}
static void static void
parent_disable_done (MMModem *modem, GError *error, gpointer user_data) parent_disable_done (MMModem *modem, GError *error, gpointer user_data)
{ {
@@ -681,8 +647,6 @@ grab_port (MMModem *modem,
if (ptype == MM_PORT_TYPE_PRIMARY) { if (ptype == MM_PORT_TYPE_PRIMARY) {
GRegex *regex; GRegex *regex;
mm_generic_gsm_set_unsolicited_registration (gsm, TRUE);
regex = g_regex_new ("_OWANCALL: (\\d),\\s*(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); regex = g_regex_new ("_OWANCALL: (\\d),\\s*(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, connection_enabled, modem, NULL); mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, connection_enabled, modem, NULL);
g_regex_unref (regex); g_regex_unref (regex);
@@ -712,7 +676,6 @@ modem_simple_init (MMModemSimple *class)
static void static void
modem_init (MMModem *modem_class) modem_init (MMModem *modem_class)
{ {
modem_class->enable = enable;
modem_class->disable = disable; modem_class->disable = disable;
modem_class->connect = do_connect; modem_class->connect = do_connect;
modem_class->get_ip4_config = get_ip4_config; modem_class->get_ip4_config = get_ip4_config;

View File

@@ -11,7 +11,7 @@
* GNU General Public License for more details: * GNU General Public License for more details:
* *
* Copyright (C) 2008 - 2009 Novell, Inc. * Copyright (C) 2008 - 2009 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc. * Copyright (C) 2009 - 2010 Red Hat, Inc.
*/ */
#include <stdlib.h> #include <stdlib.h>
@@ -41,7 +41,6 @@ G_DEFINE_TYPE_EXTENDED (MMModemHuaweiGsm, mm_modem_huawei_gsm, MM_TYPE_GENERIC_G
typedef struct { typedef struct {
/* Cached state */ /* Cached state */
guint signal_quality; guint signal_quality;
MMModemGsmMode mode;
MMModemGsmBand band; MMModemGsmBand band;
} MMModemHuaweiGsmPrivate; } MMModemHuaweiGsmPrivate;
@@ -68,23 +67,28 @@ parse_syscfg (MMModemHuaweiGsm *self,
int *mode_b, int *mode_b,
guint32 *band, guint32 *band,
int *unknown1, int *unknown1,
int *unknown2) int *unknown2,
MMModemGsmAllowedMode *out_mode)
{ {
if (reply == NULL || strncmp (reply, "^SYSCFG:", 8)) if (reply == NULL || strncmp (reply, "^SYSCFG:", 8))
return FALSE; return FALSE;
if (sscanf (reply + 8, "%d,%d,%x,%d,%d", mode_a, mode_b, band, unknown1, unknown2)) { if (sscanf (reply + 8, "%d,%d,%x,%d,%d", mode_a, mode_b, band, unknown1, unknown2)) {
MMModemHuaweiGsmPrivate *priv = MM_MODEM_HUAWEI_GSM_GET_PRIVATE (self); MMModemHuaweiGsmPrivate *priv = MM_MODEM_HUAWEI_GSM_GET_PRIVATE (self);
MMModemGsmAllowedMode new_mode = MM_MODEM_GSM_ALLOWED_MODE_ANY;
/* Network mode */ /* Network mode */
if (*mode_a == 2 && *mode_b == 1) if (*mode_a == 2 && *mode_b == 1)
priv->mode = MM_MODEM_GSM_MODE_2G_PREFERRED; new_mode = MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED;
else if (*mode_a == 2 && *mode_b == 2) else if (*mode_a == 2 && *mode_b == 2)
priv->mode = MM_MODEM_GSM_MODE_3G_PREFERRED; new_mode = MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED;
else if (*mode_a == 13 && *mode_b == 1) else if (*mode_a == 13 && *mode_b == 1)
priv->mode = MM_MODEM_GSM_MODE_2G_ONLY; new_mode = MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY;
else if (*mode_a == 14 && *mode_b == 2) else if (*mode_a == 14 && *mode_b == 2)
priv->mode = MM_MODEM_GSM_MODE_3G_ONLY; new_mode = MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY;
if (out_mode)
*out_mode = new_mode;
/* Band */ /* Band */
if (*band == 0x3FFFFFFF) if (*band == 0x3FFFFFFF)
@@ -101,26 +105,21 @@ parse_syscfg (MMModemHuaweiGsm *self,
} }
static void static void
set_network_mode_done (MMAtSerialPort *port, set_allowed_mode_done (MMAtSerialPort *port,
GString *response, GString *response,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
{ {
MMCallbackInfo *info = (MMCallbackInfo *) user_data; MMCallbackInfo *info = (MMCallbackInfo *) user_data;
MMModemHuaweiGsm *self = MM_MODEM_HUAWEI_GSM (info->modem);
MMModemHuaweiGsmPrivate *priv = MM_MODEM_HUAWEI_GSM_GET_PRIVATE (self);
if (error) if (error)
info->error = g_error_copy (error); info->error = g_error_copy (error);
else
/* Success, cache the value */
priv->mode = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "mode"));
mm_callback_info_schedule (info); mm_callback_info_schedule (info);
} }
static void static void
set_network_mode_get_done (MMAtSerialPort *port, set_allowed_mode_get_done (MMAtSerialPort *port,
GString *response, GString *response,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
@@ -134,33 +133,29 @@ set_network_mode_get_done (MMAtSerialPort *port,
int a, b, u1, u2; int a, b, u1, u2;
guint32 band; guint32 band;
if (parse_syscfg (MM_MODEM_HUAWEI_GSM (info->modem), response->str, &a, &b, &band, &u1, &u2)) { if (parse_syscfg (MM_MODEM_HUAWEI_GSM (info->modem), response->str, &a, &b, &band, &u1, &u2, NULL)) {
MMModemGsmAllowedMode mode;
char *command; char *command;
switch (GPOINTER_TO_UINT (mm_callback_info_get_data (info, "mode"))) { mode = GPOINTER_TO_UINT (mm_callback_info_get_data (info, "mode"));
case MM_MODEM_GSM_MODE_ANY: switch (mode) {
case MM_MODEM_GSM_ALLOWED_MODE_ANY:
a = 2; a = 2;
b = 0; b = 0;
break; break;
case MM_MODEM_GSM_MODE_GPRS: case MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY:
case MM_MODEM_GSM_MODE_EDGE:
case MM_MODEM_GSM_MODE_2G_ONLY:
a = 13; a = 13;
b = 1; b = 1;
break; break;
case MM_MODEM_GSM_MODE_UMTS: case MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY:
case MM_MODEM_GSM_MODE_HSDPA:
case MM_MODEM_GSM_MODE_HSUPA:
case MM_MODEM_GSM_MODE_HSPA:
case MM_MODEM_GSM_MODE_3G_ONLY:
a = 14; a = 14;
b = 2; b = 2;
break; break;
case MM_MODEM_GSM_MODE_2G_PREFERRED: case MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED:
a = 2; a = 2;
b = 1; b = 1;
break; break;
case MM_MODEM_GSM_MODE_3G_PREFERRED: case MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED:
a = 2; a = 2;
b = 2; b = 2;
break; break;
@@ -169,93 +164,65 @@ set_network_mode_get_done (MMAtSerialPort *port,
} }
command = g_strdup_printf ("AT^SYSCFG=%d,%d,%X,%d,%d", a, b, band, u1, u2); command = g_strdup_printf ("AT^SYSCFG=%d,%d,%X,%d,%d", a, b, band, u1, u2);
mm_at_serial_port_queue_command (port, command, 3, set_network_mode_done, info); mm_at_serial_port_queue_command (port, command, 3, set_allowed_mode_done, info);
g_free (command); g_free (command);
} }
} }
} }
static void static void
set_network_mode (MMModemGsmNetwork *modem, set_allowed_mode (MMGenericGsm *gsm,
MMModemGsmMode mode, MMModemGsmAllowedMode mode,
MMModemFn callback, MMModemFn callback,
gpointer user_data) gpointer user_data)
{ {
MMCallbackInfo *info; MMCallbackInfo *info;
MMAtSerialPort *primary; MMAtSerialPort *primary;
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data); info = mm_callback_info_new (MM_MODEM (gsm), callback, user_data);
switch (mode) { mm_callback_info_set_data (info, "mode", GUINT_TO_POINTER (mode), NULL);
case MM_MODEM_GSM_MODE_ANY: primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (gsm), MM_PORT_TYPE_PRIMARY);
case MM_MODEM_GSM_MODE_GPRS: g_assert (primary);
case MM_MODEM_GSM_MODE_EDGE:
case MM_MODEM_GSM_MODE_UMTS:
case MM_MODEM_GSM_MODE_HSDPA:
case MM_MODEM_GSM_MODE_HSUPA:
case MM_MODEM_GSM_MODE_HSPA:
case MM_MODEM_GSM_MODE_2G_PREFERRED:
case MM_MODEM_GSM_MODE_3G_PREFERRED:
case MM_MODEM_GSM_MODE_2G_ONLY:
case MM_MODEM_GSM_MODE_3G_ONLY:
/* Allowed values */
mm_callback_info_set_data (info, "mode", GUINT_TO_POINTER (mode), NULL);
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
g_assert (primary);
mm_at_serial_port_queue_command (primary, "AT^SYSCFG?", 3, set_network_mode_get_done, info);
return;
default:
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, "Invalid mode.");
break;
}
mm_callback_info_schedule (info); /* Get current configuration first so we don't change band and other
* stuff when updating the mode.
*/
mm_at_serial_port_queue_command (primary, "AT^SYSCFG?", 3, set_allowed_mode_get_done, info);
} }
static void static void
get_network_mode_done (MMAtSerialPort *port, get_allowed_mode_done (MMAtSerialPort *port,
GString *response, GString *response,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
{ {
MMCallbackInfo *info = (MMCallbackInfo *) user_data; MMCallbackInfo *info = (MMCallbackInfo *) user_data;
MMModemHuaweiGsm *self = MM_MODEM_HUAWEI_GSM (info->modem); MMModemHuaweiGsm *self = MM_MODEM_HUAWEI_GSM (info->modem);
MMModemHuaweiGsmPrivate *priv = MM_MODEM_HUAWEI_GSM_GET_PRIVATE (self);
int mode_a, mode_b, u1, u2; int mode_a, mode_b, u1, u2;
guint32 band; guint32 band;
MMModemGsmAllowedMode mode = MM_MODEM_GSM_ALLOWED_MODE_ANY;
if (error) if (error)
info->error = g_error_copy (error); info->error = g_error_copy (error);
else if (parse_syscfg (self, response->str, &mode_a, &mode_b, &band, &u1, &u2)) else if (parse_syscfg (self, response->str, &mode_a, &mode_b, &band, &u1, &u2, &mode))
mm_callback_info_set_result (info, GUINT_TO_POINTER (priv->mode), NULL); mm_callback_info_set_result (info, GUINT_TO_POINTER (mode), NULL);
mm_callback_info_schedule (info); mm_callback_info_schedule (info);
} }
static void static void
get_network_mode (MMModemGsmNetwork *modem, get_allowed_mode (MMGenericGsm *gsm,
MMModemUIntFn callback, MMModemUIntFn callback,
gpointer user_data) gpointer user_data)
{ {
MMModemHuaweiGsmPrivate *priv = MM_MODEM_HUAWEI_GSM_GET_PRIVATE (modem); MMCallbackInfo *info;
MMAtSerialPort *primary;
if (priv->mode != MM_MODEM_GSM_MODE_ANY) { info = mm_callback_info_uint_new (MM_MODEM (gsm), callback, user_data);
/* have cached mode (from an unsolicited message). Use that */ primary = mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY);
MMCallbackInfo *info; g_assert (primary);
mm_at_serial_port_queue_command (primary, "AT^SYSCFG?", 3, get_allowed_mode_done, info);
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
mm_callback_info_set_result (info, GUINT_TO_POINTER (priv->mode), NULL);
mm_callback_info_schedule (info);
} else {
/* Get it from modem */
MMCallbackInfo *info;
MMAtSerialPort *primary;
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
g_assert (primary);
mm_at_serial_port_queue_command (primary, "AT^SYSCFG?", 3, get_network_mode_done, info);
}
} }
static void static void
@@ -293,7 +260,7 @@ set_band_get_done (MMAtSerialPort *port,
int a, b, u1, u2; int a, b, u1, u2;
guint32 band; guint32 band;
if (parse_syscfg (self, response->str, &a, &b, &band, &u1, &u2)) { if (parse_syscfg (self, response->str, &a, &b, &band, &u1, &u2, NULL)) {
char *command; char *command;
switch (GPOINTER_TO_UINT (mm_callback_info_get_data (info, "band"))) { switch (GPOINTER_TO_UINT (mm_callback_info_get_data (info, "band"))) {
@@ -370,7 +337,7 @@ get_band_done (MMAtSerialPort *port,
if (error) if (error)
info->error = g_error_copy (error); info->error = g_error_copy (error);
else if (parse_syscfg (self, response->str, &mode_a, &mode_b, &band, &u1, &u2)) else if (parse_syscfg (self, response->str, &mode_a, &mode_b, &band, &u1, &u2, NULL))
mm_callback_info_set_result (info, GUINT_TO_POINTER (priv->band), NULL); mm_callback_info_set_result (info, GUINT_TO_POINTER (priv->band), NULL);
mm_callback_info_schedule (info); mm_callback_info_schedule (info);
@@ -459,7 +426,7 @@ handle_mode_change (MMAtSerialPort *port,
gpointer user_data) gpointer user_data)
{ {
MMModemHuaweiGsm *self = MM_MODEM_HUAWEI_GSM (user_data); MMModemHuaweiGsm *self = MM_MODEM_HUAWEI_GSM (user_data);
MMModemHuaweiGsmPrivate *priv = MM_MODEM_HUAWEI_GSM_GET_PRIVATE (self); MMModemGsmAccessTech act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
char *str; char *str;
int a; int a;
int b; int b;
@@ -472,25 +439,29 @@ handle_mode_change (MMAtSerialPort *port,
b = atoi (str); b = atoi (str);
g_free (str); g_free (str);
if (a == 3 && b == 2) if (a == 3) { /* GSM/GPRS mode */
priv->mode = MM_MODEM_GSM_MODE_GPRS; if (b == 1)
else if (a == 3 && b == 3) act = MM_MODEM_GSM_ACCESS_TECH_GSM;
priv->mode = MM_MODEM_GSM_MODE_EDGE; else if (b == 2)
else if (a == 5 && b == 4) act = MM_MODEM_GSM_ACCESS_TECH_GPRS;
priv->mode = MM_MODEM_GSM_MODE_UMTS; else if (b == 3)
else if (a == 5 && b == 5) act = MM_MODEM_GSM_ACCESS_TECH_EDGE;
priv->mode = MM_MODEM_GSM_MODE_HSDPA; } else if (a == 5) { /* WCDMA mode */
else if (a == 5 && b == 6) if (b == 4)
priv->mode = MM_MODEM_GSM_MODE_HSUPA; act = MM_MODEM_GSM_ACCESS_TECH_UMTS;
else if (a == 5 && b == 7) else if (b == 5)
priv->mode = MM_MODEM_GSM_MODE_HSPA; act = MM_MODEM_GSM_ACCESS_TECH_HSDPA;
else { else if (b == 6)
act = MM_MODEM_GSM_ACCESS_TECH_HSUPA;
else if (b == 7)
act = MM_MODEM_GSM_ACCESS_TECH_HSPA;
} else {
g_warning ("Couldn't parse mode change value: '%s'", str); g_warning ("Couldn't parse mode change value: '%s'", str);
return; return;
} }
g_debug ("Mode: %d", priv->mode); g_debug ("Access Technology: %d", act);
mm_modem_gsm_network_mode (MM_MODEM_GSM_NETWORK (self), priv->mode); mm_generic_gsm_update_access_technology (MM_GENERIC_GSM (self), act);
} }
static void static void
@@ -556,28 +527,25 @@ grab_port (MMModem *modem,
port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error); port = mm_generic_gsm_grab_port (gsm, subsys, name, ptype, error);
if (port && MM_IS_AT_SERIAL_PORT (port)) { if (port && MM_IS_AT_SERIAL_PORT (port)) {
GRegex *regex;
g_object_set (G_OBJECT (port), MM_PORT_CARRIER_DETECT, FALSE, NULL); g_object_set (G_OBJECT (port), MM_PORT_CARRIER_DETECT, FALSE, NULL);
if (ptype == MM_PORT_TYPE_SECONDARY) {
GRegex *regex;
mm_generic_gsm_set_unsolicited_registration (MM_GENERIC_GSM (modem), TRUE); regex = g_regex_new ("\\r\\n\\^RSSI:(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_signal_quality_change, modem, NULL);
g_regex_unref (regex);
regex = g_regex_new ("\\r\\n\\^RSSI:(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); regex = g_regex_new ("\\r\\n\\^MODE:(\\d),(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_signal_quality_change, modem, NULL); mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_mode_change, modem, NULL);
g_regex_unref (regex); g_regex_unref (regex);
regex = g_regex_new ("\\r\\n\\^MODE:(\\d),(\\d)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); regex = g_regex_new ("\\r\\n\\^DSFLOWRPT:(.+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_mode_change, modem, NULL); mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_status_change, modem, NULL);
g_regex_unref (regex); g_regex_unref (regex);
regex = g_regex_new ("\\r\\n\\^DSFLOWRPT:(.+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); regex = g_regex_new ("\\r\\n\\^BOOT:.+\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, handle_status_change, modem, NULL); mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, NULL, modem, NULL);
g_regex_unref (regex); g_regex_unref (regex);
regex = g_regex_new ("\\r\\n\\^BOOT:.+\\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, modem, NULL);
g_regex_unref (regex);
}
} }
out: out:
@@ -598,8 +566,6 @@ modem_init (MMModem *modem_class)
static void static void
modem_gsm_network_init (MMModemGsmNetwork *class) modem_gsm_network_init (MMModemGsmNetwork *class)
{ {
class->set_network_mode = set_network_mode;
class->get_network_mode = get_network_mode;
class->set_band = set_band; class->set_band = set_band;
class->get_band = get_band; class->get_band = get_band;
class->get_signal_quality = get_signal_quality; class->get_signal_quality = get_signal_quality;
@@ -614,8 +580,12 @@ static void
mm_modem_huawei_gsm_class_init (MMModemHuaweiGsmClass *klass) mm_modem_huawei_gsm_class_init (MMModemHuaweiGsmClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
MMGenericGsmClass *gsm_class = MM_GENERIC_GSM_CLASS (klass);
mm_modem_huawei_gsm_parent_class = g_type_class_peek_parent (klass); mm_modem_huawei_gsm_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (object_class, sizeof (MMModemHuaweiGsmPrivate)); g_type_class_add_private (object_class, sizeof (MMModemHuaweiGsmPrivate));
gsm_class->set_allowed_mode = set_allowed_mode;
gsm_class->get_allowed_mode = get_allowed_mode;
} }

View File

@@ -1,11 +1,13 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* /*
* Copyright (C) 2008 Ericsson AB * Copyright (C) 2008 - 2010 Ericsson AB
* Copyright (C) 2009 - 2010 Red Hat, Inc.
* *
* Author: Per Hallsmark <per.hallsmark@ericsson.com> * Author: Per Hallsmark <per.hallsmark@ericsson.com>
* Bjorn Runaker <bjorn.runaker@ericsson.com> * Bjorn Runaker <bjorn.runaker@ericsson.com>
* Torgny Johansson <torgny.johansson@ericsson.com> * Torgny Johansson <torgny.johansson@ericsson.com>
* Jonas Sjöquist <jonas.sjoquist@ericsson.com> * Jonas Sjöquist <jonas.sjoquist@ericsson.com>
* Dan Williams <dcbw@redhat.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@@ -163,21 +165,16 @@ do_register (MMModemGsmNetwork *modem,
} }
static int static int
mbm_parse_network_mode (MMModemGsmMode network_mode) mbm_parse_allowed_mode (MMModemGsmAllowedMode network_mode)
{ {
switch (network_mode) { switch (network_mode) {
case MM_MODEM_GSM_MODE_ANY: case MM_MODEM_GSM_ALLOWED_MODE_ANY:
case MM_MODEM_GSM_MODE_3G_PREFERRED: case MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED:
case MM_MODEM_GSM_MODE_2G_PREFERRED: case MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED:
return MBM_NETWORK_MODE_ANY; return MBM_NETWORK_MODE_ANY;
case MM_MODEM_GSM_MODE_GPRS: case MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY:
case MM_MODEM_GSM_MODE_EDGE:
case MM_MODEM_GSM_MODE_2G_ONLY:
return MBM_NETWORK_MODE_2G; return MBM_NETWORK_MODE_2G;
case MM_MODEM_GSM_MODE_3G_ONLY: case MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY:
case MM_MODEM_GSM_MODE_HSDPA:
case MM_MODEM_GSM_MODE_HSUPA:
case MM_MODEM_GSM_MODE_HSPA:
return MBM_NETWORK_MODE_3G; return MBM_NETWORK_MODE_3G;
default: default:
return MBM_NETWORK_MODE_ANY; return MBM_NETWORK_MODE_ANY;
@@ -185,7 +182,7 @@ mbm_parse_network_mode (MMModemGsmMode network_mode)
} }
static void static void
mbm_set_network_mode_done (MMAtSerialPort *port, mbm_set_allowed_mode_done (MMAtSerialPort *port,
GString *response, GString *response,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
@@ -199,8 +196,8 @@ mbm_set_network_mode_done (MMAtSerialPort *port,
} }
static void static void
set_network_mode (MMModemGsmNetwork *modem, set_allowed_mode (MMGenericGsm *gsm,
MMModemGsmMode mode, MMModemGsmAllowedMode mode,
MMModemFn callback, MMModemFn callback,
gpointer user_data) gpointer user_data)
{ {
@@ -208,15 +205,16 @@ set_network_mode (MMModemGsmNetwork *modem,
char *command; char *command;
MMAtSerialPort *primary; MMAtSerialPort *primary;
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data); info = mm_callback_info_new (MM_MODEM (gsm), callback, user_data);
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY); primary = mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY);
g_assert (primary); g_assert (primary);
command = g_strdup_printf ("+CFUN=%d", mbm_parse_network_mode (mode)); command = g_strdup_printf ("+CFUN=%d", mbm_parse_allowed_mode (mode));
mm_at_serial_port_queue_command (primary, command, 3, mbm_set_network_mode_done, info); mm_at_serial_port_queue_command (primary, command, 3, mbm_set_allowed_mode_done, info);
g_free (command); g_free (command);
} }
#if 0
static void static void
get_network_mode_done (MMAtSerialPort *port, get_network_mode_done (MMAtSerialPort *port,
GString *response, GString *response,
@@ -266,19 +264,52 @@ done:
mm_callback_info_schedule (info); mm_callback_info_schedule (info);
} }
#endif
static void static void
get_network_mode (MMModemGsmNetwork *modem, get_allowed_mode_done (MMAtSerialPort *port,
GString *response,
GError *error,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
gboolean parsed = FALSE;
if (error)
info->error = g_error_copy (error);
else if (!g_str_has_prefix (response->str, "CFUN: ")) {
MMModemGsmAllowedMode mode = MM_MODEM_GSM_ALLOWED_MODE_ANY;
int a;
a = atoi (response->str + 6);
if (a == MBM_NETWORK_MODE_2G)
mode = MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY;
else if (a == MBM_NETWORK_MODE_3G)
mode = MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY;
mm_callback_info_set_result (info, GUINT_TO_POINTER (mode), NULL);
parsed = TRUE;
}
if (!error && !parsed)
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
"Could not parse allowed mode results");
mm_callback_info_schedule (info);
}
static void
get_allowed_mode (MMGenericGsm *gsm,
MMModemUIntFn callback, MMModemUIntFn callback,
gpointer user_data) gpointer user_data)
{ {
MMCallbackInfo *info; MMCallbackInfo *info;
MMAtSerialPort *primary; MMAtSerialPort *primary;
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data); info = mm_callback_info_uint_new (MM_MODEM (gsm), callback, user_data);
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY); primary = mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY);
g_assert (primary); g_assert (primary);
mm_at_serial_port_queue_command (primary, "*ERINFO?", 3, get_network_mode_done, info); mm_at_serial_port_queue_command (primary, "CFUN?", 3, get_allowed_mode_done, info);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -300,7 +331,22 @@ simple_connect (MMModemSimple *simple,
priv->password = mbm_simple_get_string_property (properties, "password", &info->error); priv->password = mbm_simple_get_string_property (properties, "password", &info->error);
network_mode = mbm_simple_get_uint_property (properties, "network_mode", &info->error); network_mode = mbm_simple_get_uint_property (properties, "network_mode", &info->error);
priv->network_mode = mbm_parse_network_mode (network_mode); switch (network_mode) {
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_ANY:
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_PREFERRED:
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_PREFERRED:
priv->network_mode = MBM_NETWORK_MODE_ANY;
break;
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_ONLY:
priv->network_mode = MBM_NETWORK_MODE_2G;
break;
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_ONLY:
priv->network_mode = MBM_NETWORK_MODE_3G;
break;
default:
priv->network_mode = MBM_NETWORK_MODE_ANY;
break;
}
parent_iface = g_type_interface_peek_parent (MM_MODEM_SIMPLE_GET_INTERFACE (simple)); parent_iface = g_type_interface_peek_parent (MM_MODEM_SIMPLE_GET_INTERFACE (simple));
parent_iface->connect (MM_MODEM_SIMPLE (simple), properties, callback, info); parent_iface->connect (MM_MODEM_SIMPLE (simple), properties, callback, info);
@@ -521,14 +567,23 @@ mbm_ciev_received (MMAtSerialPort *port,
} }
static void static void
mbm_do_connect_done (MMModemMbm *self) mbm_do_connect_done (MMModemMbm *self, gboolean success)
{ {
MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (self); MMModemMbmPrivate *priv = MM_MODEM_MBM_GET_PRIVATE (self);
if (priv->pending_connect_info) { if (!priv->pending_connect_info)
return;
if (success)
mm_generic_gsm_connect_complete (MM_GENERIC_GSM (self), NULL, priv->pending_connect_info); mm_generic_gsm_connect_complete (MM_GENERIC_GSM (self), NULL, priv->pending_connect_info);
priv->pending_connect_info = NULL; else {
GError *connect_error;
connect_error = mm_modem_connect_error_for_code (MM_MODEM_CONNECT_ERROR_BUSY);
mm_generic_gsm_connect_complete (MM_GENERIC_GSM (self), connect_error, priv->pending_connect_info);
g_error_free (connect_error);
} }
priv->pending_connect_info = NULL;
} }
static void static void
@@ -543,17 +598,18 @@ mbm_e2nap_received (MMAtSerialPort *port,
if (str) if (str)
state = atoi (str); state = atoi (str);
if (MBM_E2NAP_DISCONNECTED == state) if (MBM_E2NAP_DISCONNECTED == state) {
g_debug ("%s, disconnected", __func__); g_debug ("%s: disconnected", __func__);
else if (MBM_E2NAP_CONNECTED == state) { mbm_do_connect_done (MM_MODEM_MBM (user_data), FALSE);
g_debug ("%s, connected", __func__); } else if (MBM_E2NAP_CONNECTED == state) {
mbm_do_connect_done (MM_MODEM_MBM (user_data)); g_debug ("%s: connected", __func__);
mbm_do_connect_done (MM_MODEM_MBM (user_data), TRUE);
} else if (MBM_E2NAP_CONNECTING == state) } else if (MBM_E2NAP_CONNECTING == state)
g_debug("%s, connecting", __func__); g_debug("%s: connecting", __func__);
else { else {
/* Should not happen */ /* Should not happen */
g_debug("%s, undefined e2nap status",__FUNCTION__); g_debug("%s: unhandled E2NAP state %d", __func__, state);
g_assert_not_reached (); mbm_do_connect_done (MM_MODEM_MBM (user_data), FALSE);
} }
} }
@@ -620,7 +676,6 @@ enap_done (MMAtSerialPort *port,
tid = g_timeout_add_seconds (1, enap_poll, user_data); tid = g_timeout_add_seconds (1, enap_poll, user_data);
/* remember poll id as callback info object, with source_remove as free func */ /* remember poll id as callback info object, with source_remove as free func */
mm_callback_info_set_data (info, "mbm-enap-poll-id", GUINT_TO_POINTER (tid), (GFreeFunc) g_source_remove); mm_callback_info_set_data (info, "mbm-enap-poll-id", GUINT_TO_POINTER (tid), (GFreeFunc) g_source_remove);
mm_at_serial_port_queue_command (port, "AT*E2NAP=1", 3, NULL, NULL);
} }
static void static void
@@ -640,6 +695,9 @@ mbm_auth_done (MMAtSerialPort *port,
} }
cid = mm_generic_gsm_get_cid (modem); cid = mm_generic_gsm_get_cid (modem);
mm_at_serial_port_queue_command (port, "AT*E2NAP=1", 3, NULL, NULL);
command = g_strdup_printf ("AT*ENAP=1,%d", cid); command = g_strdup_printf ("AT*ENAP=1,%d", cid);
mm_at_serial_port_queue_command (port, command, 3, enap_done, user_data); mm_at_serial_port_queue_command (port, command, 3, enap_done, user_data);
g_free (command); g_free (command);
@@ -736,8 +794,6 @@ grab_port (MMModem *modem,
if (port && MM_IS_AT_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) { if (port && MM_IS_AT_SERIAL_PORT (port) && (ptype == MM_PORT_TYPE_PRIMARY)) {
GRegex *regex; GRegex *regex;
mm_generic_gsm_set_unsolicited_registration (MM_GENERIC_GSM (modem), TRUE);
regex = g_regex_new ("\\r\\n\\*EMRDY: \\d\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); regex = g_regex_new ("\\r\\n\\*EMRDY: \\d\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, mbm_emrdy_received, modem, NULL); mm_at_serial_port_add_unsolicited_msg_handler (MM_AT_SERIAL_PORT (port), regex, mbm_emrdy_received, modem, NULL);
g_regex_unref (regex); g_regex_unref (regex);
@@ -773,8 +829,6 @@ static void
modem_gsm_network_init (MMModemGsmNetwork *class) modem_gsm_network_init (MMModemGsmNetwork *class)
{ {
class->do_register = do_register; class->do_register = do_register;
class->get_network_mode = get_network_mode;
class->set_network_mode = set_network_mode;
} }
static void static void
@@ -823,5 +877,7 @@ mm_modem_mbm_class_init (MMModemMbmClass *klass)
object_class->finalize = finalize; object_class->finalize = finalize;
gsm_class->do_enable = do_enable; gsm_class->do_enable = do_enable;
gsm_class->get_allowed_mode = get_allowed_mode;
gsm_class->set_allowed_mode = set_allowed_mode;
} }

View File

@@ -48,78 +48,6 @@ mm_modem_novatel_gsm_new (const char *device,
/* Modem class override functions */ /* Modem class override functions */
/*****************************************************************************/ /*****************************************************************************/
static void
init_modem_done (MMAtSerialPort *port,
GString *response,
GError *error,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info);
}
static void
pin_check_done (MMModem *modem, GError *error, gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
MMGenericGsm *self = MM_GENERIC_GSM (modem);
MMAtSerialPort *primary;
if (error) {
mm_generic_gsm_enable_complete (self, error, info);
return;
}
/* Finish the initialization */
primary = mm_generic_gsm_get_at_port (self, MM_PORT_TYPE_PRIMARY);
g_assert (primary);
mm_at_serial_port_queue_command (primary, "Z E0 V1 X4 &C1 +CMEE=1;+CFUN=1", 10, init_modem_done, info);
}
static void
pre_init_done (MMAtSerialPort *port,
GString *response,
GError *error,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
if (error) {
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info);
return;
}
/* Now check the PIN explicitly, novatel doesn't seem to report
* that it needs it otherwise.
*/
mm_generic_gsm_check_pin (MM_GENERIC_GSM (info->modem), pin_check_done, info);
}
static void
enable_flash_done (MMSerialPort *port, GError *error, gpointer user_data)
{
MMCallbackInfo *info = user_data;
if (error)
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info);
else
mm_at_serial_port_queue_command (MM_AT_SERIAL_PORT (port), "E0 V1", 3, pre_init_done, user_data);
}
static void
do_enable (MMGenericGsm *modem, MMModemFn callback, gpointer user_data)
{
MMCallbackInfo *info;
MMAtSerialPort *primary;
primary = mm_generic_gsm_get_at_port (modem, MM_PORT_TYPE_PRIMARY);
g_assert (primary);
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
mm_serial_port_flash (MM_SERIAL_PORT (primary), 100, enable_flash_done, info);
}
static void static void
dmat_callback (MMAtSerialPort *port, dmat_callback (MMAtSerialPort *port,
GString *response, GString *response,
@@ -175,10 +103,6 @@ mm_modem_novatel_gsm_init (MMModemNovatelGsm *self)
static void static void
mm_modem_novatel_gsm_class_init (MMModemNovatelGsmClass *klass) mm_modem_novatel_gsm_class_init (MMModemNovatelGsmClass *klass)
{ {
MMGenericGsmClass *gsm_class = MM_GENERIC_GSM_CLASS (klass);
mm_modem_novatel_gsm_parent_class = g_type_class_peek_parent (klass); mm_modem_novatel_gsm_parent_class = g_type_class_peek_parent (klass);
gsm_class->do_enable = do_enable;
} }

View File

@@ -22,13 +22,13 @@
#include "mm-errors.h" #include "mm-errors.h"
#include "mm-callback-info.h" #include "mm-callback-info.h"
static void modem_init (MMModem *modem_class); G_DEFINE_TYPE (MMModemOption, mm_modem_option, MM_TYPE_GENERIC_GSM)
static void modem_gsm_network_init (MMModemGsmNetwork *gsm_network_class);
G_DEFINE_TYPE_EXTENDED (MMModemOption, mm_modem_option, MM_TYPE_GENERIC_GSM, 0, #define MM_MODEM_OPTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_MODEM_OPTION, MMModemOptionPrivate))
G_IMPLEMENT_INTERFACE (MM_TYPE_MODEM, modem_init)
G_IMPLEMENT_INTERFACE (MM_TYPE_MODEM_GSM_NETWORK, modem_gsm_network_init))
typedef struct {
guint enable_wait_id;
} MMModemOptionPrivate;
MMModem * MMModem *
mm_modem_option_new (const char *device, mm_modem_option_new (const char *device,
@@ -48,57 +48,46 @@ mm_modem_option_new (const char *device,
/*****************************************************************************/ /*****************************************************************************/
static void
pin_check_done (MMModem *modem, GError *error, gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (modem), error, info);
}
static gboolean static gboolean
option_enabled (gpointer data) option_enabled (gpointer user_data)
{ {
MMCallbackInfo *info = (MMCallbackInfo *) data; MMCallbackInfo *info = user_data;
MMGenericGsm *modem;
MMModemOptionPrivate *priv;
/* Now check the PIN explicitly, option doesn't seem to report /* Make sure we don't use an invalid modem that may have been removed */
* that it needs it otherwise. if (info->modem) {
*/ modem = MM_GENERIC_GSM (info->modem);
mm_generic_gsm_check_pin (MM_GENERIC_GSM (info->modem), pin_check_done, info); priv = MM_MODEM_OPTION_GET_PRIVATE (modem);
priv->enable_wait_id = 0;
MM_GENERIC_GSM_CLASS (mm_modem_option_parent_class)->do_enable_power_up_done (modem, NULL, NULL, info);
}
return FALSE; return FALSE;
} }
static void static void
parent_enable_done (MMModem *modem, GError *error, gpointer user_data) real_do_enable_power_up_done (MMGenericGsm *gsm,
GString *response,
GError *error,
MMCallbackInfo *info)
{ {
MMCallbackInfo *info = (MMCallbackInfo *) user_data; MMModemOptionPrivate *priv = MM_MODEM_OPTION_GET_PRIVATE (gsm);
if (error) { if (error) {
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (modem), error, info); /* Chain up to parent */
MM_GENERIC_GSM_CLASS (mm_modem_option_parent_class)->do_enable_power_up_done (gsm, NULL, error, info);
return; return;
} }
/* Option returns OK on +CFUN=1 right away but needs some time /* Some Option devices return OK on +CFUN=1 right away but need some time
* to finish initialization * to finish initialization.
*/ */
g_timeout_add_seconds (10, option_enabled, info); g_warn_if_fail (priv->enable_wait_id == 0);
priv->enable_wait_id = g_timeout_add_seconds (10, option_enabled, info);
} }
static void static void
enable (MMModem *modem, get_allowed_mode_done (MMAtSerialPort *port,
MMModemFn callback,
gpointer user_data)
{
MMModem *parent_modem_iface;
MMCallbackInfo *info;
info = mm_callback_info_new (modem, callback, user_data);
parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (modem));
parent_modem_iface->enable (modem, parent_enable_done, info);
}
static void
get_network_mode_done (MMAtSerialPort *port,
GString *response, GString *response,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
@@ -112,20 +101,20 @@ get_network_mode_done (MMAtSerialPort *port,
int a, b; int a, b;
if (sscanf (response->str + 8, "%d,%d", &a, &b)) { if (sscanf (response->str + 8, "%d,%d", &a, &b)) {
MMModemGsmMode mode = MM_MODEM_GSM_MODE_ANY; MMModemGsmAllowedMode mode = MM_MODEM_GSM_ALLOWED_MODE_ANY;
switch (a) { switch (a) {
case 0: case 0:
mode = MM_MODEM_GSM_MODE_2G_ONLY; mode = MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY;
break; break;
case 1: case 1:
mode = MM_MODEM_GSM_MODE_3G_ONLY; mode = MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY;
break; break;
case 2: case 2:
mode = MM_MODEM_GSM_MODE_2G_PREFERRED; mode = MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED;
break; break;
case 3: case 3:
mode = MM_MODEM_GSM_MODE_3G_PREFERRED; mode = MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED;
break; break;
default: default:
break; break;
@@ -138,27 +127,27 @@ get_network_mode_done (MMAtSerialPort *port,
if (!error && !parsed) if (!error && !parsed)
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
"Could not parse network mode results"); "Could not parse allowed mode results");
mm_callback_info_schedule (info); mm_callback_info_schedule (info);
} }
static void static void
get_network_mode (MMModemGsmNetwork *modem, get_allowed_mode (MMGenericGsm *gsm,
MMModemUIntFn callback, MMModemUIntFn callback,
gpointer user_data) gpointer user_data)
{ {
MMCallbackInfo *info; MMCallbackInfo *info;
MMAtSerialPort *primary; MMAtSerialPort *primary;
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data); info = mm_callback_info_uint_new (MM_MODEM (gsm), callback, user_data);
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY); primary = mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY);
g_assert (primary); g_assert (primary);
mm_at_serial_port_queue_command (primary, "AT_OPSYS?", 3, get_network_mode_done, info); mm_at_serial_port_queue_command (primary, "AT_OPSYS?", 3, get_allowed_mode_done, info);
} }
static void static void
set_network_mode_done (MMAtSerialPort *port, set_allowed_mode_done (MMAtSerialPort *port,
GString *response, GString *response,
GError *error, GError *error,
gpointer user_data) gpointer user_data)
@@ -167,13 +156,13 @@ set_network_mode_done (MMAtSerialPort *port,
if (error) if (error)
info->error = g_error_copy (error); info->error = g_error_copy (error);
mm_callback_info_schedule (info); mm_callback_info_schedule (info);
} }
static void static void
set_network_mode (MMModemGsmNetwork *modem, set_allowed_mode (MMGenericGsm *gsm,
MMModemGsmMode mode, MMModemGsmAllowedMode mode,
MMModemFn callback, MMModemFn callback,
gpointer user_data) gpointer user_data)
{ {
@@ -182,63 +171,62 @@ set_network_mode (MMModemGsmNetwork *modem,
char *command; char *command;
int i; int i;
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data); info = mm_callback_info_new (MM_MODEM (gsm), callback, user_data);
switch (mode) { switch (mode) {
case MM_MODEM_GSM_MODE_ANY: case MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY:
case MM_MODEM_GSM_MODE_GPRS:
case MM_MODEM_GSM_MODE_EDGE:
case MM_MODEM_GSM_MODE_2G_ONLY:
i = 0; i = 0;
break; break;
case MM_MODEM_GSM_MODE_UMTS: case MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY:
case MM_MODEM_GSM_MODE_HSDPA:
case MM_MODEM_GSM_MODE_HSUPA:
case MM_MODEM_GSM_MODE_HSPA:
case MM_MODEM_GSM_MODE_3G_ONLY:
i = 1; i = 1;
break; break;
case MM_MODEM_GSM_MODE_2G_PREFERRED: case MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED:
i = 2; i = 2;
break; break;
case MM_MODEM_GSM_MODE_3G_PREFERRED: case MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED:
i = 3; i = 3;
break; break;
case MM_MODEM_GSM_ALLOWED_MODE_ANY:
default: default:
i = 5; i = 5;
break; break;
} }
command = g_strdup_printf ("AT_OPSYS=%d,2", i); command = g_strdup_printf ("AT_OPSYS=%d,2", i);
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY); primary = mm_generic_gsm_get_at_port (gsm, MM_PORT_TYPE_PRIMARY);
g_assert (primary); g_assert (primary);
mm_at_serial_port_queue_command (primary, command, 3, set_network_mode_done, info); mm_at_serial_port_queue_command (primary, command, 3, set_allowed_mode_done, info);
g_free (command); g_free (command);
} }
/*****************************************************************************/ /*****************************************************************************/
static void
modem_init (MMModem *modem_class)
{
modem_class->enable = enable;
}
static void
modem_gsm_network_init (MMModemGsmNetwork *class)
{
class->set_network_mode = set_network_mode;
class->get_network_mode = get_network_mode;
}
static void static void
mm_modem_option_init (MMModemOption *self) mm_modem_option_init (MMModemOption *self)
{ {
} }
static void static void
mm_modem_option_class_init (MMModemOptionClass *klass) dispose (GObject *object)
{ {
mm_modem_option_parent_class = g_type_class_peek_parent (klass); MMModemOptionPrivate *priv = MM_MODEM_OPTION_GET_PRIVATE (object);
if (priv->enable_wait_id)
g_source_remove (priv->enable_wait_id);
}
static void
mm_modem_option_class_init (MMModemOptionClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
MMGenericGsmClass *gsm_class = MM_GENERIC_GSM_CLASS (klass);
mm_modem_option_parent_class = g_type_class_peek_parent (klass);
g_type_class_add_private (object_class, sizeof (MMModemOptionPrivate));
object_class->dispose = dispose;
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;
} }

View File

@@ -27,6 +27,11 @@ static void modem_init (MMModem *modem_class);
G_DEFINE_TYPE_EXTENDED (MMModemSierraGsm, mm_modem_sierra_gsm, MM_TYPE_GENERIC_GSM, 0, 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, modem_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;
} MMModemSierraGsmPrivate;
MMModem * MMModem *
mm_modem_sierra_gsm_new (const char *device, mm_modem_sierra_gsm_new (const char *device,
@@ -48,51 +53,42 @@ mm_modem_sierra_gsm_new (const char *device,
/* Modem class override functions */ /* Modem class override functions */
/*****************************************************************************/ /*****************************************************************************/
static void
pin_check_done (MMModem *modem, GError *error, gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (modem), error, info);
}
static gboolean static gboolean
sierra_enabled (gpointer data) sierra_enabled (gpointer user_data)
{ {
MMCallbackInfo *info = (MMCallbackInfo *) data; MMCallbackInfo *info = user_data;
MMGenericGsm *modem;
MMModemSierraGsmPrivate *priv;
/* Now check the PIN explicitly, sierra doesn't seem to report /* Make sure we don't use an invalid modem that may have been removed */
* that it needs it otherwise. if (info->modem) {
*/ modem = MM_GENERIC_GSM (info->modem);
mm_generic_gsm_check_pin (MM_GENERIC_GSM (info->modem), pin_check_done, info); priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (modem);
priv->enable_wait_id = 0;
MM_GENERIC_GSM_CLASS (mm_modem_sierra_gsm_parent_class)->do_enable_power_up_done (modem, NULL, NULL, info);
}
return FALSE; return FALSE;
} }
static void static void
parent_enable_done (MMModem *modem, GError *error, gpointer user_data) real_do_enable_power_up_done (MMGenericGsm *gsm,
GString *response,
GError *error,
MMCallbackInfo *info)
{ {
MMCallbackInfo *info = (MMCallbackInfo *) user_data; MMModemSierraGsmPrivate *priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (gsm);
if (error) { if (error) {
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (modem), error, info); /* Chain up to parent */
MM_GENERIC_GSM_CLASS (mm_modem_sierra_gsm_parent_class)->do_enable_power_up_done (gsm, NULL, error, info);
return; return;
} }
/* Sierra returns OK on +CFUN=1 right away but needs some time /* Some Sierra devices return OK on +CFUN=1 right away but need some time
* to finish initialization. * to finish initialization.
*/ */
g_timeout_add_seconds (10, sierra_enabled, info); g_warn_if_fail (priv->enable_wait_id == 0);
} priv->enable_wait_id = g_timeout_add_seconds (10, sierra_enabled, info);
static void
enable (MMModem *modem, MMModemFn callback, gpointer user_data)
{
MMModem *parent_modem_iface;
MMCallbackInfo *info;
info = mm_callback_info_new (modem, callback, user_data);
parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (modem));
parent_modem_iface->enable (modem, parent_enable_done, info);
} }
static gboolean static gboolean
@@ -135,7 +131,6 @@ grab_port (MMModem *modem,
static void static void
modem_init (MMModem *modem_class) modem_init (MMModem *modem_class)
{ {
modem_class->enable = enable;
modem_class->grab_port = grab_port; modem_class->grab_port = grab_port;
} }
@@ -145,8 +140,24 @@ mm_modem_sierra_gsm_init (MMModemSierraGsm *self)
} }
static void static void
mm_modem_sierra_gsm_class_init (MMModemSierraGsmClass *klass) dispose (GObject *object)
{ {
mm_modem_sierra_gsm_parent_class = g_type_class_peek_parent (klass); MMModemSierraGsmPrivate *priv = MM_MODEM_SIERRA_GSM_GET_PRIVATE (object);
if (priv->enable_wait_id)
g_source_remove (priv->enable_wait_id);
}
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->do_enable_power_up_done = real_do_enable_power_up_done;
} }

View File

@@ -118,23 +118,6 @@ init_modem_done (MMAtSerialPort *port,
mm_at_serial_port_queue_command (port, "+CPMS?", 10, cpms_try_done, info); mm_at_serial_port_queue_command (port, "+CPMS?", 10, cpms_try_done, info);
} }
static void
pin_check_done (MMModem *modem, GError *error, gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
MMAtSerialPort *primary;
if (error) {
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (modem), error, info);
return;
}
/* Finish the initialization */
primary = mm_generic_gsm_get_at_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
g_assert (primary);
mm_at_serial_port_queue_command (primary, "Z E0 V1 X4 &C1 +CMEE=1;+CFUN=1;", 10, init_modem_done, info);
}
static void enable_flash_done (MMSerialPort *port, static void enable_flash_done (MMSerialPort *port,
GError *error, GError *error,
gpointer user_data); gpointer user_data);
@@ -157,9 +140,8 @@ pre_init_done (MMAtSerialPort *port,
} else } else
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info); mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info);
} else { } else {
/* Now check the PIN explicitly, zte doesn't seem to report /* Finish the initialization */
that it needs it otherwise */ mm_at_serial_port_queue_command (port, "Z E0 V1 X4 &C1 +CMEE=1;+CFUN=1;", 10, init_modem_done, info);
mm_generic_gsm_check_pin (MM_GENERIC_GSM (info->modem), pin_check_done, info);
} }
} }
@@ -229,7 +211,6 @@ grab_port (MMModem *modem,
if (port && MM_IS_AT_SERIAL_PORT (port)) { if (port && MM_IS_AT_SERIAL_PORT (port)) {
GRegex *regex; GRegex *regex;
mm_generic_gsm_set_unsolicited_registration (gsm, TRUE);
g_object_set (port, MM_PORT_CARRIER_DETECT, FALSE, NULL); g_object_set (port, MM_PORT_CARRIER_DETECT, FALSE, NULL);
regex = g_regex_new ("\\r\\n\\+ZUSIMR:(.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); regex = g_regex_new ("\\r\\n\\+ZUSIMR:(.*)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);

View File

@@ -284,16 +284,9 @@ grab_port (MMPluginBase *base,
caps = mm_plugin_base_supports_task_get_probed_capabilities (task); caps = mm_plugin_base_supports_task_get_probed_capabilities (task);
if (!existing) { if (!existing) {
if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) { if (caps & MM_PLUGIN_BASE_PORT_CAP_GSM) {
if (product == 0x1001) { modem = mm_modem_huawei_gsm_new (sysfs_path,
/* This modem is handled by generic GSM driver */ mm_plugin_base_supports_task_get_driver (task),
modem = mm_generic_gsm_new (sysfs_path, mm_plugin_get_name (MM_PLUGIN (base)));
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
} else {
modem = mm_modem_huawei_gsm_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task),
mm_plugin_get_name (MM_PLUGIN (base)));
}
} else if (caps & CAP_CDMA) { } else if (caps & CAP_CDMA) {
modem = mm_modem_huawei_cdma_new (sysfs_path, modem = mm_modem_huawei_cdma_new (sysfs_path,
mm_plugin_base_supports_task_get_driver (task), mm_plugin_base_supports_task_get_driver (task),
@@ -313,7 +306,7 @@ grab_port (MMPluginBase *base,
MMPortType ptype = MM_PORT_TYPE_UNKNOWN; MMPortType ptype = MM_PORT_TYPE_UNKNOWN;
info = g_object_get_data (G_OBJECT (task), TAG_SUPPORTS_INFO); info = g_object_get_data (G_OBJECT (task), TAG_SUPPORTS_INFO);
if (info && info->secondary && (product != 0x1001)) if (info && info->secondary)
ptype = MM_PORT_TYPE_SECONDARY; ptype = MM_PORT_TYPE_SECONDARY;
modem = existing; modem = existing;

View File

@@ -9,9 +9,18 @@
<vendor_url>http://www.freedesktop.org/wiki/ModemManager</vendor_url> <vendor_url>http://www.freedesktop.org/wiki/ModemManager</vendor_url>
<icon_name>modem-manager</icon_name> <icon_name>modem-manager</icon_name>
<action id="org.freedesktop.ModemManager.Device"> <action id="org.freedesktop.ModemManager.Device.Control">
<_description>Unlock and retrieve mobile broadband device information</_description> <_description>Unlock and control a mobile broadband device</_description>
<_message>System policy prevents unlocking the device or requesting information from it.</_message> <_message>System policy prevents unlocking or controlling the mobile broadband device.</_message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_self_keep</allow_active>
</defaults>
</action>
<action id="org.freedesktop.ModemManager.Device.Info">
<_description>Request mobile broadband device identifying information</_description>
<_message>System policy prevents requesting identifying information from the mobile broadband device.</_message>
<defaults> <defaults>
<allow_inactive>no</allow_inactive> <allow_inactive>no</allow_inactive>
<allow_active>auth_self_keep</allow_active> <allow_active>auth_self_keep</allow_active>

View File

@@ -22,9 +22,10 @@
#include "mm-auth-request.h" #include "mm-auth-request.h"
/* Authorizations */ /* Authorizations */
#define MM_AUTHORIZATION_DEVICE "org.freedesktop.ModemManager.Device" #define MM_AUTHORIZATION_DEVICE_INFO "org.freedesktop.ModemManager.Device.Info"
#define MM_AUTHORIZATION_CONTACTS "org.freedesktop.ModemManager.Contacts" #define MM_AUTHORIZATION_DEVICE_CONTROL "org.freedesktop.ModemManager.Device.Control"
#define MM_AUTHORIZATION_SMS "org.freedesktop.ModemManager.SMS" #define MM_AUTHORIZATION_CONTACTS "org.freedesktop.ModemManager.Contacts"
#define MM_AUTHORIZATION_SMS "org.freedesktop.ModemManager.SMS"
/******************/ /******************/

File diff suppressed because it is too large Load Diff

View File

@@ -11,7 +11,7 @@
* GNU General Public License for more details: * GNU General Public License for more details:
* *
* Copyright (C) 2008 - 2009 Novell, Inc. * Copyright (C) 2008 - 2009 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc. * Copyright (C) 2009 - 2010 Red Hat, Inc.
*/ */
#ifndef MM_GENERIC_GSM_H #ifndef MM_GENERIC_GSM_H
@@ -43,7 +43,9 @@ typedef enum {
MM_GENERIC_GSM_PROP_INIT_CMD, MM_GENERIC_GSM_PROP_INIT_CMD,
MM_GENERIC_GSM_PROP_SUPPORTED_BANDS, MM_GENERIC_GSM_PROP_SUPPORTED_BANDS,
MM_GENERIC_GSM_PROP_SUPPORTED_MODES, MM_GENERIC_GSM_PROP_SUPPORTED_MODES,
MM_GENERIC_GSM_PROP_INIT_CMD_OPTIONAL MM_GENERIC_GSM_PROP_INIT_CMD_OPTIONAL,
MM_GENERIC_GSM_PROP_ALLOWED_MODE,
MM_GENERIC_GSM_PROP_ACCESS_TECHNOLOGY
} MMGenericGsmProp; } MMGenericGsmProp;
@@ -59,9 +61,41 @@ typedef struct {
* that need to perform custom initialization sequences or other setup should * that need to perform custom initialization sequences or other setup should
* generally override this method instead of the MMModem interface's enable() * generally override this method instead of the MMModem interface's enable()
* method, unless the customization must happen *after* the generic init * method, unless the customization must happen *after* the generic init
* sequence has completed. * sequence has completed. When the subclass' enable attempt is complete
* the subclass should call mm_generic_gsm_enable_complete() with any error
* encountered during the process and the MMCallbackInfo created from the
* callback and user_data passed in here.
*/ */
void (*do_enable) (MMGenericGsm *self, MMModemFn callback, gpointer user_data); void (*do_enable) (MMGenericGsm *self, MMModemFn callback, gpointer user_data);
/* Called after the generic class has attempted to power up the modem.
* Subclasses can handle errors here if they know the device supports their
* power up command. Will only be called if the device does *not* override
* the MMModem enable() command or allows the generic class' do_enable()
* handler to execute.
*/
void (*do_enable_power_up_done) (MMGenericGsm *self,
GString *response,
GError *error,
MMCallbackInfo *info);
/* Called by the generic class to set the allowed operating mode of the device */
void (*set_allowed_mode) (MMGenericGsm *self,
MMModemGsmAllowedMode mode,
MMModemFn callback,
gpointer user_data);
/* Called by the generic class to get the allowed operating mode of the device */
void (*get_allowed_mode) (MMGenericGsm *self,
MMModemUIntFn callback,
gpointer user_data);
/* Called by the generic class to the current radio access technology the
* device is using while communicating with the base station.
*/
void (*get_access_technology) (MMGenericGsm *self,
MMModemUIntFn callback,
gpointer user_data);
} MMGenericGsmClass; } MMGenericGsmClass;
GType mm_generic_gsm_get_type (void); GType mm_generic_gsm_get_type (void);
@@ -74,10 +108,7 @@ MMModem *mm_generic_gsm_new (const char *device,
#define MM_GENERIC_GSM_PREV_STATE_TAG "prev-state" #define MM_GENERIC_GSM_PREV_STATE_TAG "prev-state"
void mm_generic_gsm_set_unsolicited_registration (MMGenericGsm *modem, void mm_generic_gsm_pending_registration_stop (MMGenericGsm *modem);
gboolean enabled);
void mm_generic_gsm_pending_registration_stop (MMGenericGsm *modem);
void mm_generic_gsm_set_cid (MMGenericGsm *modem, void mm_generic_gsm_set_cid (MMGenericGsm *modem,
guint32 cid); guint32 cid);
@@ -86,6 +117,22 @@ guint32 mm_generic_gsm_get_cid (MMGenericGsm *modem);
void mm_generic_gsm_set_reg_status (MMGenericGsm *modem, void mm_generic_gsm_set_reg_status (MMGenericGsm *modem,
MMModemGsmNetworkRegStatus status); MMModemGsmNetworkRegStatus status);
/* Called to asynchronously update the current allowed operating mode that the
* device is allowed to use when connecting to a network. This isn't the
* specific access technology the device is currently using (see
* mm_generic_gsm_set_access_technology() for that) but the mode the device is
* allowed to choose from when connecting.
*/
void mm_generic_gsm_update_allowed_mode (MMGenericGsm *modem,
MMModemGsmAllowedMode mode);
/* Called to asynchronously update the current access technology of the device;
* this is NOT the 2G/3G mode preference, but the current radio access
* technology being used to communicate with the base station.
*/
void mm_generic_gsm_update_access_technology (MMGenericGsm *modem,
MMModemGsmAccessTech act);
void mm_generic_gsm_check_pin (MMGenericGsm *modem, void mm_generic_gsm_check_pin (MMGenericGsm *modem,
MMModemFn callback, MMModemFn callback,
gpointer user_data); gpointer user_data);

View File

@@ -265,6 +265,9 @@ mm_modem_base_init (MMModemBase *self)
mm_properties_changed_signal_register_property (G_OBJECT (self), mm_properties_changed_signal_register_property (G_OBJECT (self),
MM_MODEM_ENABLED, MM_MODEM_ENABLED,
MM_MODEM_DBUS_INTERFACE); MM_MODEM_DBUS_INTERFACE);
mm_properties_changed_signal_register_property (G_OBJECT (self),
MM_MODEM_UNLOCK_REQUIRED,
MM_MODEM_DBUS_INTERFACE);
} }
static void static void

View File

@@ -212,7 +212,7 @@ impl_modem_cdma_get_esn (MMModemCdma *self, DBusGMethodInvocation *context)
/* Make sure the caller is authorized to get the ESN */ /* Make sure the caller is authorized to get the ESN */
if (!mm_modem_auth_request (MM_MODEM (self), if (!mm_modem_auth_request (MM_MODEM (self),
MM_AUTHORIZATION_DEVICE, MM_AUTHORIZATION_DEVICE_INFO,
context, context,
esn_auth_cb, esn_auth_cb,
NULL, NULL,

View File

@@ -225,7 +225,7 @@ impl_gsm_modem_get_imei (MMModemGsmCard *modem, DBusGMethodInvocation *context)
/* Make sure the caller is authorized to get the IMEI */ /* Make sure the caller is authorized to get the IMEI */
if (!mm_modem_auth_request (MM_MODEM (modem), if (!mm_modem_auth_request (MM_MODEM (modem),
MM_AUTHORIZATION_DEVICE, MM_AUTHORIZATION_DEVICE_INFO,
context, context,
imei_auth_cb, imei_auth_cb,
NULL, NULL,
@@ -262,7 +262,7 @@ impl_gsm_modem_get_imsi (MMModemGsmCard *modem, DBusGMethodInvocation *context)
/* Make sure the caller is authorized to get the IMSI */ /* Make sure the caller is authorized to get the IMSI */
if (!mm_modem_auth_request (MM_MODEM (modem), if (!mm_modem_auth_request (MM_MODEM (modem),
MM_AUTHORIZATION_DEVICE, MM_AUTHORIZATION_DEVICE_INFO,
context, context,
imsi_auth_cb, imsi_auth_cb,
NULL, NULL,
@@ -343,7 +343,7 @@ impl_gsm_modem_send_puk (MMModemGsmCard *modem,
/* Make sure the caller is authorized to send the PUK */ /* Make sure the caller is authorized to send the PUK */
if (!mm_modem_auth_request (MM_MODEM (modem), if (!mm_modem_auth_request (MM_MODEM (modem),
MM_AUTHORIZATION_DEVICE, MM_AUTHORIZATION_DEVICE_CONTROL,
context, context,
send_puk_auth_cb, send_puk_auth_cb,
info, info,
@@ -386,7 +386,7 @@ impl_gsm_modem_send_pin (MMModemGsmCard *modem,
/* Make sure the caller is authorized to unlock the modem */ /* Make sure the caller is authorized to unlock the modem */
if (!mm_modem_auth_request (MM_MODEM (modem), if (!mm_modem_auth_request (MM_MODEM (modem),
MM_AUTHORIZATION_DEVICE, MM_AUTHORIZATION_DEVICE_CONTROL,
context, context,
send_pin_auth_cb, send_pin_auth_cb,
info, info,
@@ -430,7 +430,7 @@ impl_gsm_modem_enable_pin (MMModemGsmCard *modem,
/* Make sure the caller is authorized to enable a PIN */ /* Make sure the caller is authorized to enable a PIN */
if (!mm_modem_auth_request (MM_MODEM (modem), if (!mm_modem_auth_request (MM_MODEM (modem),
MM_AUTHORIZATION_DEVICE, MM_AUTHORIZATION_DEVICE_CONTROL,
context, context,
enable_pin_auth_cb, enable_pin_auth_cb,
info, info,
@@ -474,7 +474,7 @@ impl_gsm_modem_change_pin (MMModemGsmCard *modem,
/* Make sure the caller is authorized to change the PIN */ /* Make sure the caller is authorized to change the PIN */
if (!mm_modem_auth_request (MM_MODEM (modem), if (!mm_modem_auth_request (MM_MODEM (modem),
MM_AUTHORIZATION_DEVICE, MM_AUTHORIZATION_DEVICE_CONTROL,
context, context,
change_pin_auth_cb, change_pin_auth_cb,
info, info,
@@ -503,7 +503,7 @@ mm_modem_gsm_card_init (gpointer g_iface)
"Supported Modes", "Supported Modes",
"Supported frequency bands of the card", "Supported frequency bands of the card",
MM_MODEM_GSM_BAND_UNKNOWN, MM_MODEM_GSM_BAND_UNKNOWN,
MM_MODEM_GSM_BAND_LAST, G_MAXUINT32,
MM_MODEM_GSM_BAND_UNKNOWN, MM_MODEM_GSM_BAND_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
@@ -513,7 +513,7 @@ mm_modem_gsm_card_init (gpointer g_iface)
"Supported Modes", "Supported Modes",
"Supported modes of the card (ex 2G preferred, 3G preferred, 2G only, etc", "Supported modes of the card (ex 2G preferred, 3G preferred, 2G only, etc",
MM_MODEM_GSM_MODE_UNKNOWN, MM_MODEM_GSM_MODE_UNKNOWN,
MM_MODEM_GSM_MODE_LAST, G_MAXUINT32,
MM_MODEM_GSM_MODE_UNKNOWN, MM_MODEM_GSM_MODE_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
} }

View File

@@ -11,6 +11,7 @@
* GNU General Public License for more details: * GNU General Public License for more details:
* *
* Copyright (C) 2008 Novell, Inc. * Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2010 Red Hat, Inc.
*/ */
#include <string.h> #include <string.h>
@@ -42,8 +43,12 @@ static void impl_gsm_modem_set_band (MMModemGsmNetwork *modem,
static void impl_gsm_modem_get_band (MMModemGsmNetwork *modem, static void impl_gsm_modem_get_band (MMModemGsmNetwork *modem,
DBusGMethodInvocation *context); DBusGMethodInvocation *context);
static void impl_gsm_modem_set_allowed_mode (MMModemGsmNetwork *modem,
MMModemGsmAllowedMode mode,
DBusGMethodInvocation *context);
static void impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem, static void impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem,
MMModemGsmMode mode, MMModemDeprecatedMode old_mode,
DBusGMethodInvocation *context); DBusGMethodInvocation *context);
static void impl_gsm_modem_get_network_mode (MMModemGsmNetwork *modem, static void impl_gsm_modem_get_network_mode (MMModemGsmNetwork *modem,
@@ -68,6 +73,47 @@ static guint signals[LAST_SIGNAL] = { 0 };
/*****************************************************************************/ /*****************************************************************************/
MMModemGsmAllowedMode
mm_modem_gsm_network_old_mode_to_allowed (MMModemDeprecatedMode old_mode)
{
/* Translate deprecated mode into new mode */
switch (old_mode) {
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_PREFERRED:
return MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED;
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_PREFERRED:
return MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED;
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_ONLY:
return MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY;
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_ONLY:
return MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY;
case MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_ANY:
default:
return MM_MODEM_GSM_ALLOWED_MODE_ANY;
}
}
MMModemDeprecatedMode
mm_modem_gsm_network_act_to_old_mode (MMModemGsmAccessTech act)
{
/* Translate new mode into old deprecated mode */
if (act & MM_MODEM_GSM_ACCESS_TECH_GPRS)
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_GPRS;
else if (act & MM_MODEM_GSM_ACCESS_TECH_EDGE)
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_EDGE;
else if (act & MM_MODEM_GSM_ACCESS_TECH_UMTS)
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_UMTS;
else if (act & MM_MODEM_GSM_ACCESS_TECH_HSDPA)
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSDPA;
else if (act & MM_MODEM_GSM_ACCESS_TECH_HSUPA)
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSUPA;
else if (act & MM_MODEM_GSM_ACCESS_TECH_HSPA)
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSPA;
return MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_ANY;
}
/*****************************************************************************/
static void static void
async_call_done (MMModem *modem, GError *error, gpointer user_data) async_call_done (MMModem *modem, GError *error, gpointer user_data)
{ {
@@ -305,34 +351,20 @@ mm_modem_gsm_network_get_band (MMModemGsmNetwork *self,
} }
void void
mm_modem_gsm_network_set_mode (MMModemGsmNetwork *self, mm_modem_gsm_network_set_allowed_mode (MMModemGsmNetwork *self,
MMModemGsmMode mode, MMModemGsmAllowedMode mode,
MMModemFn callback, MMModemFn callback,
gpointer user_data) gpointer user_data)
{ {
g_return_if_fail (MM_IS_MODEM_GSM_NETWORK (self)); g_return_if_fail (MM_IS_MODEM_GSM_NETWORK (self));
g_return_if_fail (callback != NULL); g_return_if_fail (callback != NULL);
if (MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->set_network_mode) if (MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->set_allowed_mode)
MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->set_network_mode (self, mode, callback, user_data); MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->set_allowed_mode (self, mode, callback, user_data);
else else
async_call_not_supported (self, callback, user_data); async_call_not_supported (self, callback, user_data);
} }
void
mm_modem_gsm_network_get_mode (MMModemGsmNetwork *self,
MMModemUIntFn callback,
gpointer user_data)
{
g_return_if_fail (MM_IS_MODEM_GSM_NETWORK (self));
g_return_if_fail (callback != NULL);
if (MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->get_network_mode)
MM_MODEM_GSM_NETWORK_GET_INTERFACE (self)->get_network_mode (self, callback, user_data);
else
uint_call_not_supported (self, callback, user_data);
}
void void
mm_modem_gsm_network_get_registration_info (MMModemGsmNetwork *self, mm_modem_gsm_network_get_registration_info (MMModemGsmNetwork *self,
MMModemGsmNetworkRegInfoFn callback, MMModemGsmNetworkRegInfoFn callback,
@@ -369,15 +401,6 @@ mm_modem_gsm_network_registration_info (MMModemGsmNetwork *self,
oper_name ? oper_name : ""); oper_name ? oper_name : "");
} }
void
mm_modem_gsm_network_mode (MMModemGsmNetwork *self,
MMModemGsmMode mode)
{
g_return_if_fail (MM_IS_MODEM_GSM_NETWORK (self));
g_signal_emit (self, signals[NETWORK_MODE], 0, mode);
}
/*****************************************************************************/ /*****************************************************************************/
static void static void
@@ -422,7 +445,7 @@ impl_gsm_modem_scan (MMModemGsmNetwork *modem,
/* Make sure the caller is authorized to request a scan */ /* Make sure the caller is authorized to request a scan */
if (!mm_modem_auth_request (MM_MODEM (modem), if (!mm_modem_auth_request (MM_MODEM (modem),
MM_AUTHORIZATION_DEVICE, MM_AUTHORIZATION_DEVICE_CONTROL,
context, context,
scan_auth_cb, scan_auth_cb,
NULL, NULL,
@@ -493,7 +516,28 @@ impl_gsm_modem_get_band (MMModemGsmNetwork *modem,
static void static void
impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem, impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem,
MMModemGsmMode mode, MMModemDeprecatedMode old_mode,
DBusGMethodInvocation *context)
{
if (!check_for_single_value (old_mode)) {
GError *error;
error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_OPERATION_NOT_SUPPORTED,
"Invalid arguments (more than one value given)");
dbus_g_method_return_error (context, error);
g_error_free (error);
return;
}
mm_modem_gsm_network_set_allowed_mode (modem,
mm_modem_gsm_network_old_mode_to_allowed (old_mode),
async_call_done,
context);
}
static void
impl_gsm_modem_set_allowed_mode (MMModemGsmNetwork *modem,
MMModemGsmAllowedMode mode,
DBusGMethodInvocation *context) DBusGMethodInvocation *context)
{ {
if (!check_for_single_value (mode)) { if (!check_for_single_value (mode)) {
@@ -506,14 +550,20 @@ impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem,
return; return;
} }
mm_modem_gsm_network_set_mode (modem, mode, async_call_done, context); mm_modem_gsm_network_set_allowed_mode (modem, mode, async_call_done, context);
} }
static void static void
impl_gsm_modem_get_network_mode (MMModemGsmNetwork *modem, impl_gsm_modem_get_network_mode (MMModemGsmNetwork *modem,
DBusGMethodInvocation *context) DBusGMethodInvocation *context)
{ {
mm_modem_gsm_network_get_mode (modem, uint_call_done, context); MMModemGsmAccessTech act = MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
/* DEPRECATED; it's now a property so it's quite easy to handle */
g_object_get (G_OBJECT (modem),
MM_MODEM_GSM_NETWORK_ACCESS_TECHNOLOGY, &act,
NULL);
dbus_g_method_return (context, mm_modem_gsm_network_act_to_old_mode (act));
} }
static void static void
@@ -534,6 +584,28 @@ mm_modem_gsm_network_init (gpointer g_iface)
if (initialized) if (initialized)
return; return;
/* Properties */
g_object_interface_install_property
(g_iface,
g_param_spec_uint (MM_MODEM_GSM_NETWORK_ALLOWED_MODE,
"Allowed Mode",
"Allowed network access mode",
MM_MODEM_GSM_ALLOWED_MODE_ANY,
MM_MODEM_GSM_ALLOWED_MODE_LAST,
MM_MODEM_GSM_ALLOWED_MODE_ANY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_interface_install_property
(g_iface,
g_param_spec_uint (MM_MODEM_GSM_NETWORK_ACCESS_TECHNOLOGY,
"Access Technology",
"Current access technology in use when connected to "
"a mobile network.",
MM_MODEM_GSM_ACCESS_TECH_UNKNOWN,
MM_MODEM_GSM_ACCESS_TECH_LAST,
MM_MODEM_GSM_ACCESS_TECH_UNKNOWN,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
/* Signals */ /* Signals */
signals[SIGNAL_QUALITY] = signals[SIGNAL_QUALITY] =
g_signal_new ("signal-quality", g_signal_new ("signal-quality",
@@ -559,8 +631,7 @@ mm_modem_gsm_network_init (gpointer g_iface)
g_signal_new ("network-mode", g_signal_new ("network-mode",
iface_type, iface_type,
G_SIGNAL_RUN_FIRST, G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (MMModemGsmNetwork, network_mode), 0, NULL, NULL,
NULL, NULL,
g_cclosure_marshal_VOID__UINT, g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
G_TYPE_UINT); G_TYPE_UINT);

View File

@@ -11,7 +11,7 @@
* GNU General Public License for more details: * GNU General Public License for more details:
* *
* Copyright (C) 2008 Novell, Inc. * Copyright (C) 2008 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc. * Copyright (C) 2009 - 2010 Red Hat, Inc.
*/ */
#ifndef MM_MODEM_GSM_NETWORK_H #ifndef MM_MODEM_GSM_NETWORK_H
@@ -20,11 +20,23 @@
#include <mm-modem.h> #include <mm-modem.h>
#include <mm-modem-gsm.h> #include <mm-modem-gsm.h>
#define MM_MODEM_GSM_NETWORK_DBUS_INTERFACE "org.freedesktop.ModemManager.Modem.Gsm.Network"
#define MM_TYPE_MODEM_GSM_NETWORK (mm_modem_gsm_network_get_type ()) #define MM_TYPE_MODEM_GSM_NETWORK (mm_modem_gsm_network_get_type ())
#define MM_MODEM_GSM_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_GSM_NETWORK, MMModemGsmNetwork)) #define MM_MODEM_GSM_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_MODEM_GSM_NETWORK, MMModemGsmNetwork))
#define MM_IS_MODEM_GSM_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_GSM_NETWORK)) #define MM_IS_MODEM_GSM_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MM_TYPE_MODEM_GSM_NETWORK))
#define MM_MODEM_GSM_NETWORK_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_MODEM_GSM_NETWORK, MMModemGsmNetwork)) #define MM_MODEM_GSM_NETWORK_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), MM_TYPE_MODEM_GSM_NETWORK, MMModemGsmNetwork))
#define MM_MODEM_GSM_NETWORK_ALLOWED_MODE "allowed-mode"
#define MM_MODEM_GSM_NETWORK_ACCESS_TECHNOLOGY "access-technology"
typedef enum {
MM_MODEM_GSM_NETWORK_PROP_FIRST = 0x1200,
MM_MODEM_GSM_NETWORK_PROP_ALLOWED_MODE = MM_MODEM_GSM_NETWORK_PROP_FIRST,
MM_MODEM_GSM_NETWORK_PROP_ACCESS_TECHNOLOGY,
} MMModemGsmNetworkProp;
typedef enum { typedef enum {
MM_MODEM_GSM_NETWORK_REG_STATUS_IDLE = 0, MM_MODEM_GSM_NETWORK_REG_STATUS_IDLE = 0,
MM_MODEM_GSM_NETWORK_REG_STATUS_HOME = 1, MM_MODEM_GSM_NETWORK_REG_STATUS_HOME = 1,
@@ -80,15 +92,11 @@ struct _MMModemGsmNetwork {
MMModemUIntFn callback, MMModemUIntFn callback,
gpointer user_data); gpointer user_data);
void (*set_network_mode) (MMModemGsmNetwork *self, void (*set_allowed_mode) (MMModemGsmNetwork *self,
MMModemGsmMode mode, MMModemGsmAllowedMode mode,
MMModemFn callback, MMModemFn callback,
gpointer user_data); gpointer user_data);
void (*get_network_mode) (MMModemGsmNetwork *self,
MMModemUIntFn callback,
gpointer user_data);
void (*get_registration_info) (MMModemGsmNetwork *self, void (*get_registration_info) (MMModemGsmNetwork *self,
MMModemGsmNetworkRegInfoFn callback, MMModemGsmNetworkRegInfoFn callback,
gpointer user_data); gpointer user_data);
@@ -101,9 +109,6 @@ struct _MMModemGsmNetwork {
MMModemGsmNetworkRegStatus status, MMModemGsmNetworkRegStatus status,
const char *open_code, const char *open_code,
const char *oper_name); const char *oper_name);
void (*network_mode) (MMModemGsmNetwork *self,
MMModemGsmMode mode);
}; };
GType mm_modem_gsm_network_get_type (void); GType mm_modem_gsm_network_get_type (void);
@@ -135,15 +140,6 @@ void mm_modem_gsm_network_get_band (MMModemGsmNetwork *self,
MMModemUIntFn callback, MMModemUIntFn callback,
gpointer user_data); gpointer user_data);
void mm_modem_gsm_network_set_mode (MMModemGsmNetwork *self,
MMModemGsmMode mode,
MMModemFn callback,
gpointer user_data);
void mm_modem_gsm_network_get_mode (MMModemGsmNetwork *self,
MMModemUIntFn callback,
gpointer user_data);
void mm_modem_gsm_network_get_registration_info (MMModemGsmNetwork *self, void mm_modem_gsm_network_get_registration_info (MMModemGsmNetwork *self,
MMModemGsmNetworkRegInfoFn callback, MMModemGsmNetworkRegInfoFn callback,
gpointer user_data); gpointer user_data);
@@ -153,12 +149,19 @@ void mm_modem_gsm_network_get_registration_info (MMModemGsmNetwork *self,
void mm_modem_gsm_network_signal_quality (MMModemGsmNetwork *self, void mm_modem_gsm_network_signal_quality (MMModemGsmNetwork *self,
guint32 quality); guint32 quality);
void mm_modem_gsm_network_set_allowed_mode (MMModemGsmNetwork *self,
MMModemGsmAllowedMode mode,
MMModemFn callback,
gpointer user_data);
void mm_modem_gsm_network_registration_info (MMModemGsmNetwork *self, void mm_modem_gsm_network_registration_info (MMModemGsmNetwork *self,
MMModemGsmNetworkRegStatus status, MMModemGsmNetworkRegStatus status,
const char *oper_code, const char *oper_code,
const char *oper_name); const char *oper_name);
void mm_modem_gsm_network_mode (MMModemGsmNetwork *self, /* Private */
MMModemGsmMode mode); MMModemDeprecatedMode mm_modem_gsm_network_act_to_old_mode (MMModemGsmAccessTech act);
MMModemGsmAllowedMode mm_modem_gsm_network_old_mode_to_allowed (MMModemDeprecatedMode old_mode);
#endif /* MM_MODEM_GSM_NETWORK_H */ #endif /* MM_MODEM_GSM_NETWORK_H */

View File

@@ -30,10 +30,34 @@ typedef enum {
MM_MODEM_GSM_MODE_3G_ONLY = 0x00000100, MM_MODEM_GSM_MODE_3G_ONLY = 0x00000100,
MM_MODEM_GSM_MODE_HSUPA = 0x00000200, MM_MODEM_GSM_MODE_HSUPA = 0x00000200,
MM_MODEM_GSM_MODE_HSPA = 0x00000400, MM_MODEM_GSM_MODE_HSPA = 0x00000400,
MM_MODEM_GSM_MODE_GSM = 0x00000800,
MM_MODEM_GSM_MODE_LAST = MM_MODEM_GSM_MODE_HSPA MM_MODEM_GSM_MODE_GSM_COMPACT = 0x00001000,
} MMModemGsmMode; } MMModemGsmMode;
typedef enum {
MM_MODEM_GSM_ALLOWED_MODE_ANY = 0,
MM_MODEM_GSM_ALLOWED_MODE_2G_PREFERRED = 1,
MM_MODEM_GSM_ALLOWED_MODE_3G_PREFERRED = 2,
MM_MODEM_GSM_ALLOWED_MODE_2G_ONLY = 3,
MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY = 4,
MM_MODEM_GSM_ALLOWED_MODE_LAST = MM_MODEM_GSM_ALLOWED_MODE_3G_ONLY
} MMModemGsmAllowedMode;
typedef enum {
MM_MODEM_GSM_ACCESS_TECH_UNKNOWN = 0,
MM_MODEM_GSM_ACCESS_TECH_GSM = 1,
MM_MODEM_GSM_ACCESS_TECH_GSM_COMPACT = 2,
MM_MODEM_GSM_ACCESS_TECH_GPRS = 3,
MM_MODEM_GSM_ACCESS_TECH_EDGE = 4, /* GSM w/EGPRS */
MM_MODEM_GSM_ACCESS_TECH_UMTS = 5, /* UTRAN */
MM_MODEM_GSM_ACCESS_TECH_HSDPA = 6, /* UTRAN w/HSDPA */
MM_MODEM_GSM_ACCESS_TECH_HSUPA = 7, /* UTRAN w/HSUPA */
MM_MODEM_GSM_ACCESS_TECH_HSPA = 8, /* UTRAN w/HSDPA and HSUPA */
MM_MODEM_GSM_ACCESS_TECH_LAST = MM_MODEM_GSM_ACCESS_TECH_HSPA
} MMModemGsmAccessTech;
typedef enum { typedef enum {
MM_MODEM_GSM_BAND_UNKNOWN = 0x00000000, MM_MODEM_GSM_BAND_UNKNOWN = 0x00000000,
MM_MODEM_GSM_BAND_ANY = 0x00000001, MM_MODEM_GSM_BAND_ANY = 0x00000001,
@@ -53,5 +77,18 @@ typedef enum {
} MMModemGsmBand; } MMModemGsmBand;
#endif /* MM_MODEM_GSM_H */ typedef enum {
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_ANY = 0,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_GPRS,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_EDGE,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_UMTS,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSDPA,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_PREFERRED,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_PREFERRED,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_2G_ONLY,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_3G_ONLY,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSUPA,
MM_MODEM_GSM_NETWORK_DEPRECATED_MODE_HSPA
} MMModemDeprecatedMode;
#endif /* MM_MODEM_GSM_H */

View File

@@ -17,6 +17,7 @@
#include <glib.h> #include <glib.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include <stdlib.h>
#include "mm-errors.h" #include "mm-errors.h"
#include "mm-modem-helpers.h" #include "mm-modem-helpers.h"
@@ -201,3 +202,230 @@ mm_gsm_destroy_scan_data (gpointer data)
g_ptr_array_free (results, TRUE); g_ptr_array_free (results, TRUE);
} }
/*************************************************************************/
/* +CREG: <stat> (GSM 07.07 CREG=1 unsolicited) */
#define CREG1 "\\+CG?REG:\\s*(\\d{1})"
/* +CREG: <n>,<stat> (GSM 07.07 CREG=1 solicited) */
#define CREG2 "\\+CG?REG:\\s*(\\d{1}),\\s*(\\d{1})"
/* +CREG: <stat>,<lac>,<ci> (GSM 07.07 CREG=2 unsolicited) */
#define CREG3 "\\+CG?REG:\\s*(\\d{1}),\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)"
/* +CREG: <n>,<stat>,<lac>,<ci> (GSM 07.07 solicited and some CREG=2 unsolicited) */
#define CREG4 "\\+CG?REG:\\s*(\\d{1}),\\s*(\\d{1})\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)"
/* +CREG: <stat>,<lac>,<ci>,<AcT> (ETSI 27.007 CREG=2 unsolicited) */
#define CREG5 "\\+CG?REG:\\s*(\\d{1})\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(\\d{1,2})"
/* +CREG: <n>,<stat>,<lac>,<ci>,<AcT> (ETSI 27.007 solicited and some CREG=2 unsolicited) */
#define CREG6 "\\+CG?REG:\\s*(\\d{1}),\\s*(\\d{1})\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(\\d{1,2})"
GPtrArray *
mm_gsm_creg_regex_get (gboolean solicited)
{
GPtrArray *array = g_ptr_array_sized_new (6);
GRegex *regex;
/* #1 */
if (solicited)
regex = g_regex_new (CREG1 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
else
regex = g_regex_new ("\\r\\n" CREG1 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
g_assert (regex);
g_ptr_array_add (array, regex);
/* #2 */
if (solicited)
regex = g_regex_new (CREG2 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
else
regex = g_regex_new ("\\r\\n" CREG2 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
g_assert (regex);
g_ptr_array_add (array, regex);
/* #3 */
if (solicited)
regex = g_regex_new (CREG3 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
else
regex = g_regex_new ("\\r\\n" CREG3 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
g_assert (regex);
g_ptr_array_add (array, regex);
/* #4 */
if (solicited)
regex = g_regex_new (CREG4 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
else
regex = g_regex_new ("\\r\\n" CREG4 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
g_assert (regex);
g_ptr_array_add (array, regex);
/* #5 */
if (solicited)
regex = g_regex_new (CREG5 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
else
regex = g_regex_new ("\\r\\n" CREG5 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
g_assert (regex);
g_ptr_array_add (array, regex);
/* #6 */
if (solicited)
regex = g_regex_new (CREG6 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
else
regex = g_regex_new ("\\r\\n" CREG6 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
g_assert (regex);
g_ptr_array_add (array, regex);
return array;
}
void
mm_gsm_creg_regex_destroy (GPtrArray *array)
{
g_ptr_array_foreach (array, (GFunc) g_regex_unref, NULL);
g_ptr_array_free (array, TRUE);
}
/*************************************************************************/
static gulong
parse_uint (char *str, int base, glong nmin, glong nmax, gboolean *valid)
{
gulong ret = 0;
char *endquote;
*valid = FALSE;
if (!str)
return 0;
/* Strip quotes */
if (str[0] == '"')
str++;
endquote = strchr (str, '"');
if (endquote)
*endquote = '\0';
if (strlen (str)) {
ret = strtol (str, NULL, base);
if ((nmin == nmax) || (ret >= nmin && ret <= nmax))
*valid = TRUE;
}
return *valid ? (guint) ret : 0;
}
gboolean
mm_gsm_parse_creg_response (GMatchInfo *info,
guint32 *out_reg_state,
gulong *out_lac,
gulong *out_ci,
gint *out_act,
gboolean *out_greg,
GError **error)
{
gboolean success = FALSE, foo;
gint n_matches, act = -1;
gulong stat = 0, lac = 0, ci = 0;
guint istat = 0, ilac = 0, ici = 0, iact = 0;
char *str;
const char *orig_str;
g_return_val_if_fail (info != NULL, FALSE);
g_return_val_if_fail (out_reg_state != NULL, FALSE);
g_return_val_if_fail (out_lac != NULL, FALSE);
g_return_val_if_fail (out_ci != NULL, FALSE);
g_return_val_if_fail (out_act != NULL, FALSE);
g_return_val_if_fail (out_greg != NULL, FALSE);
/* Normally the number of matches could be used to determine what each
* item is, but we have overlap in one case.
*/
n_matches = g_match_info_get_match_count (info);
if (n_matches == 2) {
/* CREG=1: +CREG: <stat> */
istat = 1;
} else if (n_matches == 3) {
/* Solicited response: +CREG: <n>,<stat> */
istat = 2;
} else if (n_matches == 4) {
/* CREG=2 (GSM 07.07): +CREG: <stat>,<lac>,<ci> */
istat = 1;
ilac = 2;
ici = 3;
} else if (n_matches == 5) {
/* CREG=2 (ETSI 27.007): +CREG: <stat>,<lac>,<ci>,<AcT>
* CREG=2 (non-standard): +CREG: <n>,<stat>,<lac>,<ci>
*/
/* To distinguish, check length of the second match item. If it's
* more than one digit or has quotes in it, then we have the first format.
*/
str = g_match_info_fetch (info, 2);
if (str && (strchr (str, '"') || strlen (str) > 1)) {
g_free (str);
istat = 1;
ilac = 2;
ici = 3;
iact = 4;
} else {
istat = 2;
ilac = 3;
ici = 4;
}
} else if (n_matches == 6) {
/* CREG=2 (non-standard): +CREG: <n>,<stat>,<lac>,<ci>,<AcT> */
istat = 2;
ilac = 3;
ici = 4;
iact = 5;
}
/* Status */
str = g_match_info_fetch (info, istat);
stat = parse_uint (str, 10, 0, 5, &success);
g_free (str);
if (!success) {
g_set_error_literal (error,
MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
"Could not parse the registration status response");
return FALSE;
}
/* Location Area Code */
if (ilac) {
/* FIXME: some phones apparently swap the LAC bytes (LG, SonyEricsson,
* Sagem). Need to handle that.
*/
str = g_match_info_fetch (info, ilac);
lac = parse_uint (str, 16, 1, 0xFFFF, &foo);
g_free (str);
}
/* Cell ID */
if (ici) {
str = g_match_info_fetch (info, ici);
ci = parse_uint (str, 16, 1, 0x0FFFFFFE, &foo);
g_free (str);
}
/* Access Technology */
if (iact) {
str = g_match_info_fetch (info, iact);
act = (gint) parse_uint (str, 10, 0, 7, &foo);
g_free (str);
if (!foo)
act = -1;
}
orig_str = g_match_info_get_string (info);
*out_greg = !!strstr (orig_str, "+CGREG");
*out_reg_state = (guint32) stat;
if (stat != 4) {
/* Don't fill in lac/ci/act if the device's state is unknown */
*out_lac = lac;
*out_ci = ci;
*out_act = act;
}
return TRUE;
}

View File

@@ -27,5 +27,17 @@ GPtrArray *mm_gsm_parse_scan_response (const char *reply, GError **error);
void mm_gsm_destroy_scan_data (gpointer data); void mm_gsm_destroy_scan_data (gpointer data);
GPtrArray *mm_gsm_creg_regex_get (gboolean solicited);
void mm_gsm_creg_regex_destroy (GPtrArray *array);
gboolean mm_gsm_parse_creg_response (GMatchInfo *info,
guint32 *out_reg_state,
gulong *out_lac,
gulong *out_ci,
gint *out_act,
gboolean *out_greg,
GError **error);
#endif /* MM_MODEM_HELPERS_H */ #endif /* MM_MODEM_HELPERS_H */

View File

@@ -18,6 +18,11 @@
#include "mm-modem-helpers.h" #include "mm-modem-helpers.h"
typedef struct {
GPtrArray *solicited_creg;
GPtrArray *unsolicited_creg;
} TestData;
#define MM_SCAN_TAG_STATUS "status" #define MM_SCAN_TAG_STATUS "status"
#define MM_SCAN_TAG_OPER_LONG "operator-long" #define MM_SCAN_TAG_OPER_LONG "operator-long"
#define MM_SCAN_TAG_OPER_SHORT "operator-short" #define MM_SCAN_TAG_OPER_SHORT "operator-short"
@@ -35,10 +40,10 @@ typedef struct {
#define ARRAY_LEN(i) (sizeof (i) / sizeof (i[0])) #define ARRAY_LEN(i) (sizeof (i) / sizeof (i[0]))
static void static void
test_results (const char *desc, test_cops_results (const char *desc,
const char *reply, const char *reply,
OperEntry *expected_results, OperEntry *expected_results,
guint32 expected_results_len) guint32 expected_results_len)
{ {
guint i; guint i;
GError *error = NULL; GError *error = NULL;
@@ -101,7 +106,7 @@ test_cops_response_tm506 (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" } { "1", "AT&T", "AT&T", "310410", "0" }
}; };
test_results ("TM-506", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("TM-506", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -113,7 +118,7 @@ test_cops_response_gt3gplus (void *f, gpointer d)
{ "1", "Cingular", "Cingular", "310410", "0" }, { "1", "Cingular", "Cingular", "310410", "0" },
}; };
test_results ("GlobeTrotter 3G+ (nozomi)", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("GlobeTrotter 3G+ (nozomi)", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -126,7 +131,7 @@ test_cops_response_ac881 (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" }, { "1", "AT&T", "AT&T", "310410", "0" },
}; };
test_results ("Sierra AirCard 881", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Sierra AirCard 881", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -139,7 +144,7 @@ test_cops_response_gtmax36 (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" }, { "1", "AT&T", "AT&T", "310410", "0" },
}; };
test_results ("Option GlobeTrotter MAX 3.6", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Option GlobeTrotter MAX 3.6", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -152,7 +157,7 @@ test_cops_response_ac860 (void *f, gpointer d)
{ "1", "Cingular", "Cinglr", "310410", "0" }, { "1", "Cingular", "Cinglr", "310410", "0" },
}; };
test_results ("Sierra AirCard 860", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Sierra AirCard 860", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -165,7 +170,7 @@ test_cops_response_gtm378 (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" }, { "1", "AT&T", "AT&T", "310410", "0" },
}; };
test_results ("Option GTM378", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Option GTM378", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -177,7 +182,7 @@ test_cops_response_motoc (void *f, gpointer d)
{ "0", "Cingular Wireless", NULL, "310410", NULL }, { "0", "Cingular Wireless", NULL, "310410", NULL },
}; };
test_results ("BUSlink SCWi275u (Motorola C-series)", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("BUSlink SCWi275u (Motorola C-series)", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -189,7 +194,7 @@ test_cops_response_mf627a (void *f, gpointer d)
{ "3", "Voicestream Wireless Corporation", "VSTREAM", "31026", "0" }, { "3", "Voicestream Wireless Corporation", "VSTREAM", "31026", "0" },
}; };
test_results ("ZTE MF627 (A)", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("ZTE MF627 (A)", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -201,7 +206,7 @@ test_cops_response_mf627b (void *f, gpointer d)
{ "3", NULL, NULL, "31026", "0" }, { "3", NULL, NULL, "31026", "0" },
}; };
test_results ("ZTE MF627 (B)", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("ZTE MF627 (B)", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -213,7 +218,7 @@ test_cops_response_e160g (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" }, { "1", "AT&T", "AT&T", "310410", "0" },
}; };
test_results ("Huawei E160G", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Huawei E160G", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -226,7 +231,7 @@ test_cops_response_mercury (void *f, gpointer d)
{ "1", "T-Mobile", "TMO", "31026", "0" }, { "1", "T-Mobile", "TMO", "31026", "0" },
}; };
test_results ("Sierra AT&T USBConnect Mercury", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Sierra AT&T USBConnect Mercury", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -239,7 +244,7 @@ test_cops_response_quicksilver (void *f, gpointer d)
{ "1", "AT&T", NULL, "310260", "0" }, { "1", "AT&T", NULL, "310260", "0" },
}; };
test_results ("Option AT&T Quicksilver", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Option AT&T Quicksilver", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -251,7 +256,7 @@ test_cops_response_icon225 (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" }, { "1", "AT&T", "AT&T", "310410", "0" },
}; };
test_results ("Option iCON 225", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Option iCON 225", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -265,7 +270,7 @@ test_cops_response_icon452 (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" } { "1", "AT&T", "AT&T", "310410", "0" }
}; };
test_results ("Option iCON 452", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Option iCON 452", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -278,7 +283,7 @@ test_cops_response_f3507g (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "2" } { "1", "AT&T", "AT&T", "310410", "2" }
}; };
test_results ("Ericsson F3507g", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Ericsson F3507g", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -291,7 +296,7 @@ test_cops_response_f3607gw (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" } { "1", "AT&T", "AT&T", "310410", "0" }
}; };
test_results ("Ericsson F3607gw", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Ericsson F3607gw", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -304,7 +309,7 @@ test_cops_response_mc8775 (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" } { "1", "AT&T", "AT&T", "310410", "0" }
}; };
test_results ("Sierra MC8775", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Sierra MC8775", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -317,7 +322,7 @@ test_cops_response_n80 (void *f, gpointer d)
{ "1", "Cingular", NULL, "31041", NULL }, { "1", "Cingular", NULL, "31041", NULL },
}; };
test_results ("Nokia N80", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Nokia N80", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -329,7 +334,7 @@ test_cops_response_e1550 (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" }, { "1", "AT&T", "AT&T", "310410", "0" },
}; };
test_results ("Huawei E1550", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Huawei E1550", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -341,7 +346,7 @@ test_cops_response_mf622 (void *f, gpointer d)
{ "1", NULL, NULL, "310410", "0" }, { "1", NULL, NULL, "310410", "0" },
}; };
test_results ("ZTE MF622", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("ZTE MF622", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -354,7 +359,7 @@ test_cops_response_e226 (void *f, gpointer d)
{ "1", NULL, NULL, "310410", "0" }, { "1", NULL, NULL, "310410", "0" },
}; };
test_results ("Huawei E226", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Huawei E226", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -367,7 +372,7 @@ test_cops_response_xu870 (void *f, gpointer d)
{ "1", "T-Mobile", "TMO", "31026", "0" }, { "1", "T-Mobile", "TMO", "31026", "0" },
}; };
test_results ("Novatel XU870", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Novatel XU870", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -380,7 +385,7 @@ test_cops_response_gtultraexpress (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" }, { "1", "AT&T", "AT&T", "310410", "0" },
}; };
test_results ("Option GlobeTrotter Ultra Express", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Option GlobeTrotter Ultra Express", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -392,7 +397,7 @@ test_cops_response_n2720 (void *f, gpointer d)
{ "1", "AT&T", NULL, "310410", "0" }, { "1", "AT&T", NULL, "310410", "0" },
}; };
test_results ("Nokia 2720", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Nokia 2720", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -405,7 +410,7 @@ test_cops_response_gobi (void *f, gpointer d)
{ "1", "AT&T", "AT&T", "310410", "0" }, { "1", "AT&T", "AT&T", "310410", "0" },
}; };
test_results ("Qualcomm Gobi", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Qualcomm Gobi", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -426,7 +431,7 @@ test_cops_response_sek600i (void *f, gpointer d)
{ "3", NULL, NULL, "26207", NULL }, { "3", NULL, NULL, "26207", NULL },
}; };
test_results ("Sony-Ericsson K600i", reply, &expected[0], ARRAY_LEN (expected)); test_cops_results ("Sony-Ericsson K600i", reply, &expected[0], ARRAY_LEN (expected));
} }
static void static void
@@ -453,6 +458,238 @@ test_cops_response_umts_invalid (void *f, gpointer d)
g_assert (error == NULL); g_assert (error == NULL);
} }
typedef struct {
guint32 state;
gulong lac;
gulong ci;
gint act;
guint regex_num;
gboolean cgreg;
} CregResult;
static void
test_creg_match (const char *test,
gboolean solicited,
const char *reply,
TestData *data,
const CregResult *result)
{
int i;
GMatchInfo *info = NULL;
guint32 state = 0;
gulong lac = 0, ci = 0;
gint access_tech = -1;
GError *error = NULL;
gboolean success, cgreg = FALSE;
guint regex_num = 0;
GPtrArray *array;
g_assert (reply);
g_assert (test);
g_assert (data);
g_assert (result);
g_print ("\nTesting %s +CREG %s response...\n",
test,
solicited ? "solicited" : "unsolicited");
array = solicited ? data->solicited_creg : data->unsolicited_creg;
for (i = 0; i < array->len; i++) {
GRegex *r = g_ptr_array_index (array, i);
if (g_regex_match (r, reply, 0, &info)) {
regex_num = i + 1;
break;
}
g_match_info_free (info);
info = NULL;
}
g_assert (info != NULL);
g_assert (regex_num == result->regex_num);
success = mm_gsm_parse_creg_response (info, &state, &lac, &ci, &access_tech, &cgreg, &error);
g_assert (success);
g_assert (error == NULL);
g_assert (state == result->state);
g_assert (lac == result->lac);
g_assert (ci == result->ci);
g_assert (access_tech == result->act);
g_assert (cgreg == result->cgreg);
}
static void
test_creg1_solicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "+CREG: 1,3";
const CregResult result = { 3, 0, 0, -1 , 2, FALSE};
test_creg_match ("CREG=1", TRUE, reply, data, &result);
}
static void
test_creg1_unsolicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "\r\n+CREG: 3\r\n";
const CregResult result = { 3, 0, 0, -1 , 1, FALSE};
test_creg_match ("CREG=1", FALSE, reply, data, &result);
}
static void
test_creg2_mercury_solicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "+CREG: 0,1,84CD,00D30173";
const CregResult result = { 1, 0x84cd, 0xd30173, -1 , 4, FALSE};
test_creg_match ("Sierra Mercury CREG=2", TRUE, reply, data, &result);
}
static void
test_creg2_mercury_unsolicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "\r\n+CREG: 1,84CD,00D30156\r\n";
const CregResult result = { 1, 0x84cd, 0xd30156, -1 , 3, FALSE};
test_creg_match ("Sierra Mercury CREG=2", FALSE, reply, data, &result);
}
static void
test_creg2_sek850i_solicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "+CREG: 2,1,\"CE00\",\"01CEAD8F\"";
const CregResult result = { 1, 0xce00, 0x01cead8f, -1 , 4, FALSE};
test_creg_match ("Sony Ericsson K850i CREG=2", TRUE, reply, data, &result);
}
static void
test_creg2_sek850i_unsolicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "\r\n+CREG: 1,\"CE00\",\"00005449\"\r\n";
const CregResult result = { 1, 0xce00, 0x5449, -1 , 3, FALSE};
test_creg_match ("Sony Ericsson K850i CREG=2", FALSE, reply, data, &result);
}
static void
test_creg2_e160g_solicited_unregistered (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "+CREG: 2,0,00,0";
const CregResult result = { 0, 0, 0, -1 , 4, FALSE};
test_creg_match ("Huawei E160G unregistered CREG=2", TRUE, reply, data, &result);
}
static void
test_creg2_e160g_solicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "+CREG: 2,1,8BE3,2BAF";
const CregResult result = { 1, 0x8be3, 0x2baf, -1 , 4, FALSE};
test_creg_match ("Huawei E160G CREG=2", TRUE, reply, data, &result);
}
static void
test_creg2_e160g_unsolicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "\r\n+CREG: 2,8BE3,2BAF\r\n";
const CregResult result = { 2, 0x8be3, 0x2baf, -1 , 3, FALSE};
test_creg_match ("Huawei E160G CREG=2", FALSE, reply, data, &result);
}
static void
test_creg2_tm506_solicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "+CREG: 2,1,\"8BE3\",\"00002BAF\"";
const CregResult result = { 1, 0x8BE3, 0x2BAF, -1 , 4, FALSE};
/* Test leading zeros in the CI */
test_creg_match ("Sony Ericsson TM-506 CREG=2", TRUE, reply, data, &result);
}
static void
test_creg2_xu870_unsolicited_unregistered (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "\r\n+CREG: 2,,\r\n";
const CregResult result = { 2, 0, 0, -1 , 3, FALSE};
test_creg_match ("Novatel XU870 unregistered CREG=2", FALSE, reply, data, &result);
}
static void
test_cgreg1_solicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "+CGREG: 1,3";
const CregResult result = { 3, 0, 0, -1 , 2, TRUE};
test_creg_match ("CGREG=1", TRUE, reply, data, &result);
}
static void
test_cgreg1_unsolicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "\r\n+CGREG: 3\r\n";
const CregResult result = { 3, 0, 0, -1 , 1, TRUE};
test_creg_match ("CGREG=1", FALSE, reply, data, &result);
}
static void
test_cgreg2_f3607gw_solicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "+CGREG: 2,1,\"8BE3\",\"00002B5D\",3";
const CregResult result = { 1, 0x8BE3, 0x2B5D, 3 , 6, TRUE};
test_creg_match ("Ericsson F3607gw CGREG=2", TRUE, reply, data, &result);
}
static void
test_cgreg2_f3607gw_unsolicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "\r\n+CGREG: 1,\"8BE3\",\"00002B5D\",3\r\n";
const CregResult result = { 1, 0x8BE3, 0x2B5D, 3 , 5, TRUE};
test_creg_match ("Ericsson F3607gw CGREG=2", FALSE, reply, data, &result);
}
static TestData *
test_data_new (void)
{
TestData *data;
data = g_malloc0 (sizeof (TestData));
data->solicited_creg = mm_gsm_creg_regex_get (TRUE);
data->unsolicited_creg = mm_gsm_creg_regex_get (FALSE);
return data;
}
static void
test_data_free (TestData *data)
{
mm_gsm_creg_regex_destroy (data->solicited_creg);
mm_gsm_creg_regex_destroy (data->unsolicited_creg);
g_free (data);
}
typedef void (*TCFunc)(void); typedef void (*TCFunc)(void);
@@ -461,10 +698,13 @@ typedef void (*TCFunc)(void);
int main (int argc, char **argv) int main (int argc, char **argv)
{ {
GTestSuite *suite; GTestSuite *suite;
TestData *data;
gint result;
g_test_init (&argc, &argv, NULL); g_test_init (&argc, &argv, NULL);
suite = g_test_get_root (); suite = g_test_get_root ();
data = test_data_new ();
g_test_suite_add (suite, TESTCASE (test_cops_response_tm506, NULL)); g_test_suite_add (suite, TESTCASE (test_cops_response_tm506, NULL));
g_test_suite_add (suite, TESTCASE (test_cops_response_gt3gplus, NULL)); g_test_suite_add (suite, TESTCASE (test_cops_response_gt3gplus, NULL));
@@ -496,6 +736,27 @@ int main (int argc, char **argv)
g_test_suite_add (suite, TESTCASE (test_cops_response_gsm_invalid, NULL)); g_test_suite_add (suite, TESTCASE (test_cops_response_gsm_invalid, NULL));
g_test_suite_add (suite, TESTCASE (test_cops_response_umts_invalid, NULL)); g_test_suite_add (suite, TESTCASE (test_cops_response_umts_invalid, NULL));
return g_test_run (); g_test_suite_add (suite, TESTCASE (test_creg1_solicited, data));
g_test_suite_add (suite, TESTCASE (test_creg1_unsolicited, data));
g_test_suite_add (suite, TESTCASE (test_creg2_mercury_solicited, data));
g_test_suite_add (suite, TESTCASE (test_creg2_mercury_unsolicited, data));
g_test_suite_add (suite, TESTCASE (test_creg2_sek850i_solicited, data));
g_test_suite_add (suite, TESTCASE (test_creg2_sek850i_unsolicited, data));
g_test_suite_add (suite, TESTCASE (test_creg2_e160g_solicited_unregistered, data));
g_test_suite_add (suite, TESTCASE (test_creg2_e160g_solicited, data));
g_test_suite_add (suite, TESTCASE (test_creg2_e160g_unsolicited, data));
g_test_suite_add (suite, TESTCASE (test_creg2_tm506_solicited, data));
g_test_suite_add (suite, TESTCASE (test_creg2_xu870_unsolicited_unregistered, data));
g_test_suite_add (suite, TESTCASE (test_cgreg1_solicited, data));
g_test_suite_add (suite, TESTCASE (test_cgreg1_unsolicited, data));
g_test_suite_add (suite, TESTCASE (test_cgreg2_f3607gw_solicited, data));
g_test_suite_add (suite, TESTCASE (test_cgreg2_f3607gw_unsolicited, data));
result = g_test_run ();
test_data_free (data);
return result;
} }