gsm: harmonize band/mode enums

Use the same enum for set/get of band and mode, as for exposing the
device's capabilities.
This commit is contained in:
Dan Williams
2009-08-05 13:03:59 -04:00
parent 356f8f097e
commit 2d194a5798
12 changed files with 320 additions and 316 deletions

View File

@@ -5,6 +5,7 @@ EXTRA_DIST = \
mm-modem-cdma.xml \
mm-modem-connect-error.xml \
mm-modem-error.xml \
mm-modem-gsm.xml \
mm-modem-gsm-card.xml \
mm-modem-gsm-contacts.xml \
mm-modem-gsm-hso.xml \

View File

@@ -95,51 +95,13 @@
</arg>
</method>
<property name="SupportedBands" type="u" access="read" tp:type="MM_MODEM_GSM_CARD_BANDS">
<tp:docstring>Bands supported by the card.</tp:docstring>
<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>
</property>
<tp:flags name="MM_MODEM_GSM_CARD_BANDS" value-prefix="MM_MODEM_GSM_CARD_BAND" type="u">
<tp:docstring>
GSM bands.
</tp:docstring>
<tp:flag suffix="UNKNOWN" value="0x0">
<tp:docstring>Unknown or invalid band</tp:docstring>
</tp:flag>
<tp:flag suffix="EGSM" value="0x1">
<tp:docstring>GSM/GPRS/EDGE 900 MHz</tp:docstring>
</tp:flag>
<tp:flag suffix="DCS" value="0x2">
<tp:docstring>GSM/GPRS/EDGE 1800 MHz</tp:docstring>
</tp:flag>
<tp:flag suffix="PCS" value="0x4">
<tp:docstring>GSM/GPRS/EDGE 1900 MHz</tp:docstring>
</tp:flag>
<tp:flag suffix="G850" value="0x8">
<tp:docstring>GSM/GPRS/EDGE 850 MHz</tp:docstring>
</tp:flag>
<tp:flag suffix="U2100" value="0x10">
<tp:docstring>WCDMA 2100 MHz (Class I)</tp:docstring>
</tp:flag>
<tp:flag suffix="U1700" value="0x20">
<tp:docstring>WCDMA 3GPP 1800 MHz (Class III)</tp:docstring>
</tp:flag>
<tp:flag suffix="U17IV" value="0x40">
<tp:docstring>WCDMA 3GPP AWS 1700/2100 MHz (Class IV)</tp:docstring>
</tp:flag>
<tp:flag suffix="U800" value="0x80">
<tp:docstring>WCDMA 3GPP UMTS 800 MHz (Class VI)</tp:docstring>
</tp:flag>
<tp:flag suffix="U850" value="0x100">
<tp:docstring>WCDMA 3GPP UMTS 850 MHz (Class V)</tp:docstring>
</tp:flag>
<tp:flag suffix="U900" value="0x200">
<tp:docstring>WCDMA 3GPP UMTS 900 MHz (Class VIII)</tp:docstring>
</tp:flag>
<tp:flag suffix="U17IX" value="0x400">
<tp:docstring>WCDMA 3GPP UMTS 1700 MHz (Class IX)</tp:docstring>
</tp:flag>
</tp:flags>
<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>
</property>
</interface>
</node>

View File

@@ -56,53 +56,53 @@
<method name="SetBand">
<tp:docstring>
Set the GSM band.
Sets the band the 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_band"/>
<arg name="band" type="u" direction="in" tp:type="MM_MODEM_GSM_NETWORK_BAND">
<tp:docstring>
The band.
</tp:docstring>
<arg name="band" type="u" direction="in" tp:type="MM_MODEM_GSM_BAND">
<tp:docstring>
The desired band. Only one band may be specified, and may not be UNKNOWN.
</tp:docstring>
</arg>
</method>
<method name="GetBand">
<tp:docstring>
Get the current band.
Returns the current band the device is using. (Note for plugin writers: returned value must not be ANY)
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_gsm_modem_get_band"/>
<arg name="band" type="u" direction="out" tp:type="MM_MODEM_GSM_NETWORK_BAND">
<tp:docstring>
The current band.
</tp:docstring>
<arg name="band" type="u" direction="out" tp:type="MM_MODEM_GSM_BAND">
<tp:docstring>
The current band.
</tp:docstring>
</arg>
</method>
<method name="SetNetworkMode">
<tp:docstring>
Set the GSM network mode.
Set the desired mode the device may 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_network_mode"/>
<arg name="mode" type="u" direction="in" tp:type="MM_MODEM_GSM_NETWORK_MODE">
<tp:docstring>
The GSM network mode.
</tp:docstring>
<arg name="mode" type="u" direction="in" tp:type="MM_MODEM_GSM_MODE">
<tp:docstring>
The desired network mode. Only one mode may be specified, and may not be UNKNOWN.
</tp:docstring>
</arg>
</method>
<method name="GetNetworkMode">
<tp:docstring>
Get the network mode.
Returns the current network mode of the device. (Note for plugin writers: returned value *may* be ANY)
</tp:docstring>
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<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_NETWORK_MODE">
<tp:docstring>
The current network mode.
</tp:docstring>
<arg name="mode" type="u" direction="out" tp:type="MM_MODEM_GSM_MODE">
<tp:docstring>
Returns the general network mode (ex. 2G/3G preference) of the device.
</tp:docstring>
</arg>
</method>
@@ -158,134 +158,13 @@
<tp:docstring>
The network mode changed.
</tp:docstring>
<arg name="mode" type="u" tp:type="MM_MODEM_GSM_NETWORK_MODE">
<arg name="mode" type="u" tp:type="MM_MODEM_GSM_MODE">
<tp:docstring>
The new network mode.
</tp:docstring>
</arg>
</signal>
<tp:enum name="MM_MODEM_GSM_NETWORK_MODE" type="u">
<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 or HSDPA).
</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 or HSDPA).
</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>
HSDPA and HSUPA.
</tp:docstring>
</tp:enumvalue>
</tp:enum>
<tp:enum name="MM_MODEM_GSM_NETWORK_BAND" type="u">
<tp:enumvalue suffix="ANY" value="0">
<tp:docstring>
Any band can be used.
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="EGSM" value="1">
<tp:docstring>
EGSM (900 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="DCS" value="2">
<tp:docstring>
DCS (1800 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="PCS" value="4">
<tp:docstring>
PCS (1900 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="G850" value="8">
<tp:docstring>
G850 (850 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="U2100" value="16">
<tp:docstring>
U2100 (WCDMA 2100 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="U1700" value="32">
<tp:docstring>
U1700 (WCDMA 3GPP UMTS1800 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="17IV" value="64">
<tp:docstring>
17IV (WCDMA 3GPP AWS 1700/2100 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="U800" value="128">
<tp:docstring>
U800 (WCDMA 3GPP UMTS800 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="U850" value="256">
<tp:docstring>
U850 (WCDMA 3GPP UMTS850 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="U900" value="512">
<tp:docstring>
U900 (WCDMA 3GPP UMTS900 MHz).
</tp:docstring>
</tp:enumvalue>
<tp:enumvalue suffix="U17IX" value="1024">
<tp:docstring>
U17IX (WCDMA 3GPP UMTS MHz).
</tp:docstring>
</tp:enumvalue>
</tp:enum>
<tp:enum name="MM_MODEM_GSM_NETWORK_REG_STATUS" type="u">
<tp:enumvalue suffix="IDLE" value="0">
<tp:docstring>

View File

@@ -0,0 +1,86 @@
<?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.Gsm">
<tp:flags name="MM_MODEM_GSM_MODE" value-prefix="MM_MODEM_GSM_MODE" type="u">
<tp:flag suffix="UNKNOWN" value="0x0">
<tp:docstring>Unknown or invalid mode.</tp:docstring>
</tp:flag>
<tp:flag suffix="ANY" value="0x1">
<tp:docstring>For certain operations, allow the modem to pick any available mode.</tp:docstring>
</tp:flag>
<tp:flag suffix="GPRS" value="0x2">
<tp:docstring>GPRS</tp:docstring>
</tp:flag>
<tp:flag suffix="EDGE" value="0x4">
<tp:docstring>EDGE</tp:docstring>
</tp:flag>
<tp:flag suffix="UMTS" value="0x8">
<tp:docstring>UMTS (3G)</tp:docstring>
</tp:flag>
<tp:flag suffix="HSDPA" value="0x10">
<tp:docstring>HSDPA</tp:docstring>
</tp:flag>
<tp:flag suffix="2G_PREFERRED" value="0x20">
<tp:docstring>Prefer 2G (GPRS or EDGE)</tp:docstring>
</tp:flag>
<tp:flag suffix="3G_PREFERRED" value="0x40">
<tp:docstring>Prefer 3G (UMTS or HSDPA)</tp:docstring>
</tp:flag>
<tp:flag suffix="2G_ONLY" value="0x80">
<tp:docstring>Use only 2G (GPRS or EDGE)</tp:docstring>
</tp:flag>
<tp:flag suffix="3G_ONLY" value="0x100">
<tp:docstring>Use only 3G (UMTS or HSDPA)</tp:docstring>
</tp:flag>
<tp:flag suffix="HSUPA" value="0x200">
<tp:docstring>HSUPA</tp:docstring>
</tp:flag>
</tp:flags>
<tp:flags name="MM_MODEM_GSM_BAND" value-prefix="MM_MODEM_GSM_BAND" type="u">
<tp:docstring>
GSM network and device bands.
</tp:docstring>
<tp:flag suffix="UNKNOWN" value="0x0">
<tp:docstring>Unknown or invalid band</tp:docstring>
</tp:flag>
<tp:flag suffix="ANY" value="0x1">
<tp:docstring>For certain operations, allow the modem to select a band automatically.</tp:docstring>
</tp:flag>
<tp:flag suffix="EGSM" value="0x2">
<tp:docstring>GSM/GPRS/EDGE 900 MHz</tp:docstring>
</tp:flag>
<tp:flag suffix="DCS" value="0x4">
<tp:docstring>GSM/GPRS/EDGE 1800 MHz</tp:docstring>
</tp:flag>
<tp:flag suffix="PCS" value="0x8">
<tp:docstring>GSM/GPRS/EDGE 1900 MHz</tp:docstring>
</tp:flag>
<tp:flag suffix="G850" value="0x10">
<tp:docstring>GSM/GPRS/EDGE 850 MHz</tp:docstring>
</tp:flag>
<tp:flag suffix="U2100" value="0x20">
<tp:docstring>WCDMA 2100 MHz (Class I)</tp:docstring>
</tp:flag>
<tp:flag suffix="U1800" value="0x40">
<tp:docstring>WCDMA 3GPP 1800 MHz (Class III)</tp:docstring>
</tp:flag>
<tp:flag suffix="U17IV" value="0x80">
<tp:docstring>WCDMA 3GPP AWS 1700/2100 MHz (Class IV)</tp:docstring>
</tp:flag>
<tp:flag suffix="U800" value="0x100">
<tp:docstring>WCDMA 3GPP UMTS 800 MHz (Class VI)</tp:docstring>
</tp:flag>
<tp:flag suffix="U850" value="0x200">
<tp:docstring>WCDMA 3GPP UMTS 850 MHz (Class V)</tp:docstring>
</tp:flag>
<tp:flag suffix="U900" value="0x400">
<tp:docstring>WCDMA 3GPP UMTS 900 MHz (Class VIII)</tp:docstring>
</tp:flag>
<tp:flag suffix="U17IX" value="0x800">
<tp:docstring>WCDMA 3GPP UMTS 1700 MHz (Class IX)</tp:docstring>
</tp:flag>
</tp:flags>
</interface>
</node>

View File

@@ -35,8 +35,8 @@ static gpointer mm_modem_huawei_parent_class = NULL;
typedef struct {
/* Cached state */
guint signal_quality;
MMModemGsmNetworkMode mode;
MMModemGsmNetworkBand band;
MMModemGsmMode mode;
MMModemGsmBand band;
} MMModemHuaweiPrivate;
MMModem *
@@ -72,21 +72,21 @@ parse_syscfg (MMModemHuawei *self,
/* Network mode */
if (*mode_a == 2 && *mode_b == 1)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_2G_PREFERRED;
priv->mode = MM_MODEM_GSM_MODE_2G_PREFERRED;
else if (*mode_a == 2 && *mode_b == 2)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_3G_PREFERRED;
priv->mode = MM_MODEM_GSM_MODE_3G_PREFERRED;
else if (*mode_a == 13 && *mode_b == 1)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_2G_ONLY;
priv->mode = MM_MODEM_GSM_MODE_2G_ONLY;
else if (*mode_a == 14 && *mode_b == 2)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_3G_ONLY;
priv->mode = MM_MODEM_GSM_MODE_3G_ONLY;
/* Band */
if (*band == 0x3FFFFFFF)
priv->band = MM_MODEM_GSM_NETWORK_BAND_ANY;
priv->band = MM_MODEM_GSM_BAND_ANY;
else if (*band == 0x400380)
priv->band = MM_MODEM_GSM_NETWORK_BAND_DCS;
priv->band = MM_MODEM_GSM_BAND_DCS;
else if (*band == 0x200000)
priv->band = MM_MODEM_GSM_NETWORK_BAND_PCS;
priv->band = MM_MODEM_GSM_BAND_PCS;
return TRUE;
}
@@ -132,25 +132,29 @@ set_network_mode_get_done (MMSerialPort *port,
char *command;
switch (GPOINTER_TO_UINT (mm_callback_info_get_data (info, "mode"))) {
case MM_MODEM_GSM_NETWORK_MODE_GPRS:
case MM_MODEM_GSM_NETWORK_MODE_EDGE:
case MM_MODEM_GSM_NETWORK_MODE_2G_ONLY:
case MM_MODEM_GSM_MODE_ANY:
a = 2;
b = 0;
break;
case MM_MODEM_GSM_MODE_GPRS:
case MM_MODEM_GSM_MODE_EDGE:
case MM_MODEM_GSM_MODE_2G_ONLY:
a = 13;
b = 1;
break;
case MM_MODEM_GSM_NETWORK_MODE_UMTS:
case MM_MODEM_GSM_NETWORK_MODE_HSDPA:
case MM_MODEM_GSM_NETWORK_MODE_HSUPA:
case MM_MODEM_GSM_NETWORK_MODE_HSPA:
case MM_MODEM_GSM_NETWORK_MODE_3G_ONLY:
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_3G_ONLY:
a = 14;
b = 2;
break;
case MM_MODEM_GSM_NETWORK_MODE_2G_PREFERRED:
case MM_MODEM_GSM_MODE_2G_PREFERRED:
a = 2;
b = 1;
break;
case MM_MODEM_GSM_NETWORK_MODE_3G_PREFERRED:
case MM_MODEM_GSM_MODE_3G_PREFERRED:
a = 2;
b = 2;
break;
@@ -167,7 +171,7 @@ set_network_mode_get_done (MMSerialPort *port,
static void
set_network_mode (MMModemGsmNetwork *modem,
MMModemGsmNetworkMode mode,
MMModemGsmMode mode,
MMModemFn callback,
gpointer user_data)
{
@@ -177,19 +181,17 @@ set_network_mode (MMModemGsmNetwork *modem,
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
switch (mode) {
case MM_MODEM_GSM_NETWORK_MODE_ANY:
/* Do nothing */
break;
case MM_MODEM_GSM_NETWORK_MODE_GPRS:
case MM_MODEM_GSM_NETWORK_MODE_EDGE:
case MM_MODEM_GSM_NETWORK_MODE_UMTS:
case MM_MODEM_GSM_NETWORK_MODE_HSDPA:
case MM_MODEM_GSM_NETWORK_MODE_HSUPA:
case MM_MODEM_GSM_NETWORK_MODE_HSPA:
case MM_MODEM_GSM_NETWORK_MODE_2G_PREFERRED:
case MM_MODEM_GSM_NETWORK_MODE_3G_PREFERRED:
case MM_MODEM_GSM_NETWORK_MODE_2G_ONLY:
case MM_MODEM_GSM_NETWORK_MODE_3G_ONLY:
case MM_MODEM_GSM_MODE_ANY:
case MM_MODEM_GSM_MODE_GPRS:
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_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
@@ -231,7 +233,7 @@ get_network_mode (MMModemGsmNetwork *modem,
{
MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (modem);
if (priv->mode != MM_MODEM_GSM_NETWORK_MODE_ANY) {
if (priv->mode != MM_MODEM_GSM_MODE_ANY) {
/* have cached mode (from an unsolicited message). Use that */
MMCallbackInfo *info;
@@ -289,17 +291,24 @@ set_band_get_done (MMSerialPort *port,
char *command;
switch (GPOINTER_TO_UINT (mm_callback_info_get_data (info, "band"))) {
case MM_MODEM_GSM_NETWORK_BAND_ANY:
case MM_MODEM_GSM_BAND_ANY:
band = 0x3FFFFFFF;
break;
case MM_MODEM_GSM_NETWORK_BAND_EGSM:
case MM_MODEM_GSM_NETWORK_BAND_DCS:
case MM_MODEM_GSM_NETWORK_BAND_U2100:
band = 0x400380;
case MM_MODEM_GSM_BAND_EGSM:
band = 0x100;
break;
case MM_MODEM_GSM_NETWORK_BAND_PCS:
case MM_MODEM_GSM_BAND_DCS:
band = 0x80;
break;
case MM_MODEM_GSM_BAND_U2100:
band = 0x400000;
break;
case MM_MODEM_GSM_BAND_PCS:
band = 0x200000;
break;
case MM_MODEM_GSM_BAND_G850:
band = 0x80000;
break;
default:
break;
}
@@ -313,7 +322,7 @@ set_band_get_done (MMSerialPort *port,
static void
set_band (MMModemGsmNetwork *modem,
MMModemGsmNetworkBand band,
MMModemGsmBand band,
MMModemFn callback,
gpointer user_data)
{
@@ -323,11 +332,11 @@ set_band (MMModemGsmNetwork *modem,
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
switch (band) {
case MM_MODEM_GSM_NETWORK_BAND_ANY:
case MM_MODEM_GSM_NETWORK_BAND_EGSM:
case MM_MODEM_GSM_NETWORK_BAND_DCS:
case MM_MODEM_GSM_NETWORK_BAND_U2100:
case MM_MODEM_GSM_NETWORK_BAND_PCS:
case MM_MODEM_GSM_BAND_ANY:
case MM_MODEM_GSM_BAND_EGSM:
case MM_MODEM_GSM_BAND_DCS:
case MM_MODEM_GSM_BAND_U2100:
case MM_MODEM_GSM_BAND_PCS:
mm_callback_info_set_data (info, "band", GUINT_TO_POINTER (band), NULL);
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
g_assert (primary);
@@ -369,7 +378,7 @@ get_band (MMModemGsmNetwork *modem,
MMModemHuaweiPrivate *priv = MM_MODEM_HUAWEI_GET_PRIVATE (modem);
MMSerialPort *primary;
if (priv->band != MM_MODEM_GSM_NETWORK_BAND_ANY) {
if (priv->band != MM_MODEM_GSM_BAND_ANY) {
/* have cached mode (from an unsolicited message). Use that */
MMCallbackInfo *info;
@@ -458,17 +467,17 @@ handle_mode_change (MMSerialPort *port,
g_free (str);
if (a == 3 && b == 2)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_GPRS;
priv->mode = MM_MODEM_GSM_MODE_GPRS;
else if (a == 3 && b == 3)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_EDGE;
priv->mode = MM_MODEM_GSM_MODE_EDGE;
else if (a == 5 && b == 4)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_UMTS;
priv->mode = MM_MODEM_GSM_MODE_UMTS;
else if (a == 5 && b == 5)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_HSDPA;
priv->mode = MM_MODEM_GSM_MODE_HSDPA;
else if (a == 5 && b == 6)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_HSUPA;
priv->mode = MM_MODEM_GSM_MODE_HSUPA;
else if (a == 5 && b == 7)
priv->mode = MM_MODEM_GSM_NETWORK_MODE_HSPA;
priv->mode = MM_MODEM_GSM_MODE_HSPA;
else {
g_warning ("Couldn't parse mode change value: '%s'", str);
return;

View File

@@ -194,19 +194,21 @@ get_signal_quality (MMModemGsmNetwork *modem,
}
static int
mbm_parse_network_mode (int network_mode)
mbm_parse_network_mode (MMModemGsmMode network_mode)
{
switch (network_mode) {
case MM_MODEM_GSM_NETWORK_MODE_ANY:
case MM_MODEM_GSM_NETWORK_MODE_3G_PREFERRED:
case MM_MODEM_GSM_NETWORK_MODE_2G_PREFERRED:
case MM_MODEM_GSM_MODE_ANY:
case MM_MODEM_GSM_MODE_3G_PREFERRED:
case MM_MODEM_GSM_MODE_2G_PREFERRED:
return MBM_NETWORK_MODE_ANY;
case MM_MODEM_GSM_NETWORK_MODE_GPRS:
case MM_MODEM_GSM_NETWORK_MODE_EDGE:
case MM_MODEM_GSM_NETWORK_MODE_2G_ONLY:
case MM_MODEM_GSM_MODE_GPRS:
case MM_MODEM_GSM_MODE_EDGE:
case MM_MODEM_GSM_MODE_2G_ONLY:
return MBM_NETWORK_MODE_2G;
case MM_MODEM_GSM_NETWORK_MODE_3G_ONLY:
case MM_MODEM_GSM_NETWORK_MODE_HSDPA:
case MM_MODEM_GSM_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;
default:
return MBM_NETWORK_MODE_ANY;
@@ -229,7 +231,7 @@ mbm_set_network_mode_done (MMSerialPort *port,
static void
set_network_mode (MMModemGsmNetwork *modem,
MMModemGsmNetworkMode mode,
MMModemGsmMode mode,
MMModemFn callback,
gpointer user_data)
{
@@ -270,16 +272,16 @@ get_network_mode_done (MMSerialPort *port,
goto done;
if (gsm || umts) {
MMModemGsmNetworkMode mm_mode = MM_MODEM_GSM_NETWORK_MODE_ANY;
MMModemGsmMode mm_mode = MM_MODEM_GSM_MODE_ANY;
if (gsm == MBM_ERINFO_2G_GPRS)
mm_mode = MM_MODEM_GSM_NETWORK_MODE_GPRS;
mm_mode = MM_MODEM_GSM_MODE_GPRS;
else if (gsm == MBM_ERINFO_2G_EGPRS)
mm_mode = MM_MODEM_GSM_NETWORK_MODE_EDGE;
mm_mode = MM_MODEM_GSM_MODE_EDGE;
else if (umts == MBM_ERINFO_3G_UMTS)
mm_mode = MM_MODEM_GSM_NETWORK_MODE_UMTS;
mm_mode = MM_MODEM_GSM_MODE_UMTS;
else if (umts == MBM_ERINFO_3G_HSDPA)
mm_mode = MM_MODEM_GSM_NETWORK_MODE_HSDPA;
mm_mode = MM_MODEM_GSM_MODE_HSDPA;
else
g_debug ("%s unknown network mode %d,%d", __FUNCTION__, gsm, umts);

View File

@@ -112,20 +112,20 @@ get_network_mode_done (MMSerialPort *port,
int a, b;
if (sscanf (response->str + 8, "%d,%d", &a, &b)) {
MMModemGsmNetworkMode mode = MM_MODEM_GSM_NETWORK_MODE_ANY;
MMModemGsmMode mode = MM_MODEM_GSM_MODE_ANY;
switch (a) {
case 0:
mode = MM_MODEM_GSM_NETWORK_MODE_2G_ONLY;
mode = MM_MODEM_GSM_MODE_2G_ONLY;
break;
case 1:
mode = MM_MODEM_GSM_NETWORK_MODE_3G_ONLY;
mode = MM_MODEM_GSM_MODE_3G_ONLY;
break;
case 2:
mode = MM_MODEM_GSM_NETWORK_MODE_2G_PREFERRED;
mode = MM_MODEM_GSM_MODE_2G_PREFERRED;
break;
case 3:
mode = MM_MODEM_GSM_NETWORK_MODE_3G_PREFERRED;
mode = MM_MODEM_GSM_MODE_3G_PREFERRED;
break;
default:
break;
@@ -173,7 +173,7 @@ set_network_mode_done (MMSerialPort *port,
static void
set_network_mode (MMModemGsmNetwork *modem,
MMModemGsmNetworkMode mode,
MMModemGsmMode mode,
MMModemFn callback,
gpointer user_data)
{
@@ -185,23 +185,23 @@ set_network_mode (MMModemGsmNetwork *modem,
info = mm_callback_info_new (MM_MODEM (modem), callback, user_data);
switch (mode) {
case MM_MODEM_GSM_NETWORK_MODE_ANY:
case MM_MODEM_GSM_NETWORK_MODE_GPRS:
case MM_MODEM_GSM_NETWORK_MODE_EDGE:
case MM_MODEM_GSM_NETWORK_MODE_2G_ONLY:
case MM_MODEM_GSM_MODE_ANY:
case MM_MODEM_GSM_MODE_GPRS:
case MM_MODEM_GSM_MODE_EDGE:
case MM_MODEM_GSM_MODE_2G_ONLY:
i = 0;
break;
case MM_MODEM_GSM_NETWORK_MODE_UMTS:
case MM_MODEM_GSM_NETWORK_MODE_HSDPA:
case MM_MODEM_GSM_NETWORK_MODE_HSUPA:
case MM_MODEM_GSM_NETWORK_MODE_HSPA:
case MM_MODEM_GSM_NETWORK_MODE_3G_ONLY:
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_3G_ONLY:
i = 1;
break;
case MM_MODEM_GSM_NETWORK_MODE_2G_PREFERRED:
case MM_MODEM_GSM_MODE_2G_PREFERRED:
i = 2;
break;
case MM_MODEM_GSM_NETWORK_MODE_3G_PREFERRED:
case MM_MODEM_GSM_MODE_3G_PREFERRED:
i = 3;
break;
default:

View File

@@ -35,6 +35,7 @@ modem_manager_SOURCES = \
mm-generic-gsm.h \
mm-modem-cdma.c \
mm-modem-cdma.h \
mm-modem-gsm.h \
mm-modem-gsm-card.c \
mm-modem-gsm-card.h \
mm-modem-gsm-network.c \

View File

@@ -3,6 +3,7 @@
#ifndef MM_GENERIC_GSM_H
#define MM_GENERIC_GSM_H
#include "mm-modem-gsm.h"
#include "mm-modem-gsm-network.h"
#include "mm-modem-base.h"
#include "mm-serial-port.h"

View File

@@ -23,14 +23,14 @@ static void impl_gsm_modem_get_signal_quality (MMModemGsmNetwork *modem,
DBusGMethodInvocation *context);
static void impl_gsm_modem_set_band (MMModemGsmNetwork *modem,
MMModemGsmNetworkBand band,
MMModemGsmBand band,
DBusGMethodInvocation *context);
static void impl_gsm_modem_get_band (MMModemGsmNetwork *modem,
DBusGMethodInvocation *context);
static void impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem,
MMModemGsmNetworkMode mode,
MMModemGsmMode mode,
DBusGMethodInvocation *context);
static void impl_gsm_modem_get_network_mode (MMModemGsmNetwork *modem,
@@ -264,7 +264,7 @@ mm_modem_gsm_network_get_signal_quality (MMModemGsmNetwork *self,
void
mm_modem_gsm_network_set_band (MMModemGsmNetwork *self,
MMModemGsmNetworkBand band,
MMModemGsmBand band,
MMModemFn callback,
gpointer user_data)
{
@@ -293,7 +293,7 @@ mm_modem_gsm_network_get_band (MMModemGsmNetwork *self,
void
mm_modem_gsm_network_set_mode (MMModemGsmNetwork *self,
MMModemGsmNetworkMode mode,
MMModemGsmMode mode,
MMModemFn callback,
gpointer user_data)
{
@@ -358,7 +358,7 @@ mm_modem_gsm_network_registration_info (MMModemGsmNetwork *self,
void
mm_modem_gsm_network_mode (MMModemGsmNetwork *self,
MMModemGsmNetworkMode mode)
MMModemGsmMode mode)
{
g_return_if_fail (MM_IS_MODEM_GSM_NETWORK (self));
@@ -406,11 +406,39 @@ impl_gsm_modem_get_signal_quality (MMModemGsmNetwork *modem,
mm_modem_gsm_network_get_signal_quality (modem, uint_call_done, context);
}
static gboolean
check_for_single_value (guint32 value)
{
gboolean found = FALSE;
guint32 i;
for (i = 1; i <= 32; i++) {
if (value & 0x1) {
if (found)
return FALSE; /* More than one bit set */
found = TRUE;
}
value >>= 1;
}
return TRUE;
}
static void
impl_gsm_modem_set_band (MMModemGsmNetwork *modem,
MMModemGsmNetworkBand band,
MMModemGsmBand band,
DBusGMethodInvocation *context)
{
if (!check_for_single_value (band)) {
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_band (modem, band, async_call_done, context);
}
@@ -423,9 +451,19 @@ impl_gsm_modem_get_band (MMModemGsmNetwork *modem,
static void
impl_gsm_modem_set_network_mode (MMModemGsmNetwork *modem,
MMModemGsmNetworkMode mode,
MMModemGsmMode mode,
DBusGMethodInvocation *context)
{
if (!check_for_single_value (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_mode (modem, mode, async_call_done, context);
}

View File

@@ -4,45 +4,13 @@
#define MM_MODEM_GSM_NETWORK_H
#include <mm-modem.h>
#include <mm-modem-gsm.h>
#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_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))
typedef enum {
MM_MODEM_GSM_NETWORK_MODE_ANY = 0,
MM_MODEM_GSM_NETWORK_MODE_GPRS = 1,
MM_MODEM_GSM_NETWORK_MODE_EDGE = 2,
MM_MODEM_GSM_NETWORK_MODE_UMTS = 3,
MM_MODEM_GSM_NETWORK_MODE_HSDPA = 4,
MM_MODEM_GSM_NETWORK_MODE_2G_PREFERRED = 5,
MM_MODEM_GSM_NETWORK_MODE_3G_PREFERRED = 6,
MM_MODEM_GSM_NETWORK_MODE_2G_ONLY = 7,
MM_MODEM_GSM_NETWORK_MODE_3G_ONLY = 8,
MM_MODEM_GSM_NETWORK_MODE_HSUPA = 9,
MM_MODEM_GSM_NETWORK_MODE_HSPA = 10,
MM_MODEM_GSM_NETWORK_MODE_LAST = MM_MODEM_GSM_NETWORK_MODE_HSPA
} MMModemGsmNetworkMode;
typedef enum {
MM_MODEM_GSM_NETWORK_BAND_ANY = 0,
MM_MODEM_GSM_NETWORK_BAND_EGSM = 1, /* 900 MHz */
MM_MODEM_GSM_NETWORK_BAND_DCS = 2, /* 1800 MHz */
MM_MODEM_GSM_NETWORK_BAND_PCS = 3, /* 1900 MHz */
MM_MODEM_GSM_NETWORK_BAND_G850 = 4, /* 850 MHz */
MM_MODEM_GSM_NETWORK_BAND_U2100 = 5, /* WCDMA 2100 MHz (Class I) */
MM_MODEM_GSM_NETWORK_BAND_U1700 = 6, /* WCDMA 3GPP UMTS1800 MHz (Class III) */
MM_MODEM_GSM_NETWORK_BAND_17IV = 7, /* WCDMA 3GPP AWS 1700/2100 MHz (Class IV) */
MM_MODEM_GSM_NETWORK_BAND_U800 = 8, /* WCDMA 3GPP UMTS800 MHz (Class VI) */
MM_MODEM_GSM_NETWORK_BAND_U850 = 9, /* WCDMA 3GPP UMTS850 MHz (Class V) */
MM_MODEM_GSM_NETWORK_BAND_U900 = 10, /* WCDMA 3GPP UMTS900 MHz (Class VIII) */
MM_MODEM_GSM_NETWORK_BAND_U17IX = 11, /* WCDMA 3GPP UMTS MHz (Class IX) */
MM_MODEM_GSM_NETWORK_BAND_LAST = MM_MODEM_GSM_NETWORK_BAND_U17IX
} MMModemGsmNetworkBand;
typedef enum {
MM_MODEM_GSM_NETWORK_REG_STATUS_IDLE = 0,
MM_MODEM_GSM_NETWORK_REG_STATUS_HOME = 1,
@@ -90,7 +58,7 @@ struct _MMModemGsmNetwork {
gpointer user_data);
void (*set_band) (MMModemGsmNetwork *self,
MMModemGsmNetworkBand band,
MMModemGsmBand band,
MMModemFn callback,
gpointer user_data);
@@ -99,7 +67,7 @@ struct _MMModemGsmNetwork {
gpointer user_data);
void (*set_network_mode) (MMModemGsmNetwork *self,
MMModemGsmNetworkMode mode,
MMModemGsmMode mode,
MMModemFn callback,
gpointer user_data);
@@ -121,7 +89,7 @@ struct _MMModemGsmNetwork {
const char *oper_name);
void (*network_mode) (MMModemGsmNetwork *self,
MMModemGsmNetworkMode mode);
MMModemGsmMode mode);
};
GType mm_modem_gsm_network_get_type (void);
@@ -145,7 +113,7 @@ void mm_modem_gsm_network_get_signal_quality (MMModemGsmNetwork *self,
gpointer user_data);
void mm_modem_gsm_network_set_band (MMModemGsmNetwork *self,
MMModemGsmNetworkBand band,
MMModemGsmBand band,
MMModemFn callback,
gpointer user_data);
@@ -154,7 +122,7 @@ void mm_modem_gsm_network_get_band (MMModemGsmNetwork *self,
gpointer user_data);
void mm_modem_gsm_network_set_mode (MMModemGsmNetwork *self,
MMModemGsmNetworkMode mode,
MMModemGsmMode mode,
MMModemFn callback,
gpointer user_data);
@@ -177,6 +145,6 @@ void mm_modem_gsm_network_registration_info (MMModemGsmNetwork *self,
const char *oper_name);
void mm_modem_gsm_network_mode (MMModemGsmNetwork *self,
MMModemGsmNetworkMode mode);
MMModemGsmMode mode);
#endif /* MM_MODEM_GSM_NETWORK_H */

57
src/mm-modem-gsm.h Normal file
View File

@@ -0,0 +1,57 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2008 - 2009 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc.
*/
#ifndef MM_MODEM_GSM_H
#define MM_MODEM_GSM_H
typedef enum {
MM_MODEM_GSM_MODE_UNKNOWN = 0x00000000,
MM_MODEM_GSM_MODE_ANY = 0x00000001,
MM_MODEM_GSM_MODE_GPRS = 0x00000002,
MM_MODEM_GSM_MODE_EDGE = 0x00000004,
MM_MODEM_GSM_MODE_UMTS = 0x00000008,
MM_MODEM_GSM_MODE_HSDPA = 0x00000010,
MM_MODEM_GSM_MODE_2G_PREFERRED = 0x00000020,
MM_MODEM_GSM_MODE_3G_PREFERRED = 0x00000040,
MM_MODEM_GSM_MODE_2G_ONLY = 0x00000080,
MM_MODEM_GSM_MODE_3G_ONLY = 0x00000100,
MM_MODEM_GSM_MODE_HSUPA = 0x00000200,
MM_MODEM_GSM_MODE_HSPA = 0x00000400,
MM_MODEM_GSM_MODE_LAST = MM_MODEM_GSM_MODE_HSPA
} MMModemGsmMode;
typedef enum {
MM_MODEM_GSM_BAND_UNKNOWN = 0x00000000,
MM_MODEM_GSM_BAND_ANY = 0x00000001,
MM_MODEM_GSM_BAND_EGSM = 0x00000002, /* 900 MHz */
MM_MODEM_GSM_BAND_DCS = 0x00000004, /* 1800 MHz */
MM_MODEM_GSM_BAND_PCS = 0x00000008, /* 1900 MHz */
MM_MODEM_GSM_BAND_G850 = 0x00000010, /* 850 MHz */
MM_MODEM_GSM_BAND_U2100 = 0x00000020, /* WCDMA 3GPP UMTS 2100 MHz (Class I) */
MM_MODEM_GSM_BAND_U1800 = 0x00000040, /* WCDMA 3GPP UMTS 1800 MHz (Class III) */
MM_MODEM_GSM_BAND_U17IV = 0x00000080, /* WCDMA 3GPP AWS 1700/2100 MHz (Class IV) */
MM_MODEM_GSM_BAND_U800 = 0x00000100, /* WCDMA 3GPP UMTS 800 MHz (Class VI) */
MM_MODEM_GSM_BAND_U850 = 0x00000200, /* WCDMA 3GPP UMTS 850 MHz (Class V) */
MM_MODEM_GSM_BAND_U900 = 0x00000400, /* WCDMA 3GPP UMTS 900 MHz (Class VIII) */
MM_MODEM_GSM_BAND_U17IX = 0x00000800, /* WCDMA 3GPP UMTS 1700 MHz (Class IX) */
MM_MODEM_GSM_BAND_LAST = MM_MODEM_GSM_BAND_U17IX
} MMModemGsmBand;
#endif /* MM_MODEM_GSM_H */