aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmm-common/mm-simple-connect-properties.c38
-rw-r--r--libmm-common/mm-simple-connect-properties.h4
-rw-r--r--src/mm-iface-modem-simple.c58
3 files changed, 61 insertions, 39 deletions
diff --git a/libmm-common/mm-simple-connect-properties.c b/libmm-common/mm-simple-connect-properties.c
index a0ef96a7..d36ee00e 100644
--- a/libmm-common/mm-simple-connect-properties.c
+++ b/libmm-common/mm-simple-connect-properties.c
@@ -33,6 +33,7 @@ struct _MMSimpleConnectPropertiesPrivate {
/* Operator ID */
gchar *operator_id;
/* Bands */
+ gboolean bands_set;
MMModemBand *bands;
guint n_bands;
/* Modes */
@@ -78,6 +79,7 @@ mm_simple_connect_properties_set_bands (MMSimpleConnectProperties *self,
memcpy (self->priv->bands,
bands,
sizeof (MMModemBand) * self->priv->n_bands);
+ self->priv->bands_set = TRUE;
}
void
@@ -178,30 +180,40 @@ mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *self)
return self->priv->operator_id;
}
-void
+gboolean
mm_simple_connect_properties_get_bands (MMSimpleConnectProperties *self,
const MMModemBand **bands,
guint *n_bands)
{
- g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
- g_return_if_fail (bands != NULL);
- g_return_if_fail (n_bands != NULL);
+ g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), FALSE);
+ g_return_val_if_fail (bands != NULL, FALSE);
+ g_return_val_if_fail (n_bands != NULL, FALSE);
- *bands = self->priv->bands;
- *n_bands = self->priv->n_bands;
+ if (self->priv->bands_set) {
+ *bands = self->priv->bands;
+ *n_bands = self->priv->n_bands;
+ return TRUE;
+ }
+
+ return FALSE;
}
-void
+gboolean
mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *self,
MMModemMode *allowed,
MMModemMode *preferred)
{
- g_return_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self));
- g_return_if_fail (allowed != NULL);
- g_return_if_fail (preferred != NULL);
+ g_return_val_if_fail (MM_IS_SIMPLE_CONNECT_PROPERTIES (self), FALSE);
+ g_return_val_if_fail (allowed != NULL, FALSE);
+ g_return_val_if_fail (preferred != NULL, FALSE);
+
+ if (self->priv->allowed_modes_set) {
+ *allowed = self->priv->allowed_modes;
+ *preferred = self->priv->preferred_mode;
+ return TRUE;
+ }
- *allowed = self->priv->allowed_modes;
- *preferred = self->priv->preferred_mode;
+ return FALSE;
}
const gchar *
@@ -542,7 +554,7 @@ mm_simple_connect_properties_init (MMSimpleConnectProperties *self)
self->priv->allowed_modes = MM_MODEM_MODE_ANY;
self->priv->preferred_mode = MM_MODEM_MODE_NONE;
self->priv->bands = g_new (MMModemBand, 1);
- self->priv->bands[0] = MM_MODEM_BAND_ANY;
+ self->priv->bands[0] = MM_MODEM_BAND_UNKNOWN;
self->priv->n_bands = 1;
}
diff --git a/libmm-common/mm-simple-connect-properties.h b/libmm-common/mm-simple-connect-properties.h
index 04c8d34b..2a2e72f0 100644
--- a/libmm-common/mm-simple-connect-properties.h
+++ b/libmm-common/mm-simple-connect-properties.h
@@ -76,10 +76,10 @@ void mm_simple_connect_properties_set_number (MMSimpleConnectProperties *
const gchar *mm_simple_connect_properties_get_pin (MMSimpleConnectProperties *properties);
const gchar *mm_simple_connect_properties_get_operator_id (MMSimpleConnectProperties *properties);
-void mm_simple_connect_properties_get_bands (MMSimpleConnectProperties *properties,
+gboolean mm_simple_connect_properties_get_bands (MMSimpleConnectProperties *properties,
const MMModemBand **bands,
guint *n_bands);
-void mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *properties,
+gboolean mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *properties,
MMModemMode *allowed,
MMModemMode *preferred);
const gchar *mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *properties);
diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c
index bfc30943..399fb2ab 100644
--- a/src/mm-iface-modem-simple.c
+++ b/src/mm-iface-modem-simple.c
@@ -522,40 +522,50 @@ connection_step (ConnectionContext *ctx)
mm_info ("Simple connect state (%d/%d): Allowed mode",
ctx->step, CONNECTION_STEP_LAST);
- mm_simple_connect_properties_get_allowed_modes (ctx->properties,
- &allowed_modes,
- &preferred_mode);
- mm_iface_modem_set_allowed_modes (MM_IFACE_MODEM (ctx->self),
- allowed_modes,
- preferred_mode,
- (GAsyncReadyCallback)set_allowed_modes_ready,
- ctx);
- return;
+ /* Don't set modes unless explicitly requested to do so */
+ if (mm_simple_connect_properties_get_allowed_modes (ctx->properties,
+ &allowed_modes,
+ &preferred_mode)) {
+ mm_iface_modem_set_allowed_modes (MM_IFACE_MODEM (ctx->self),
+ allowed_modes,
+ preferred_mode,
+ (GAsyncReadyCallback)set_allowed_modes_ready,
+ ctx);
+ return;
+ }
+
+ /* Fall down to next step */
+ ctx->step++;
}
case CONNECTION_STEP_BANDS: {
- GArray *array;
const MMModemBand *bands = NULL;
guint n_bands = 0;
- guint i;
mm_info ("Simple connect state (%d/%d): Bands",
ctx->step, CONNECTION_STEP_LAST);
- mm_simple_connect_properties_get_bands (ctx->properties,
- &bands,
- &n_bands);
-
- array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n_bands);
- for (i = 0; i < n_bands; i++)
- g_array_insert_val (array, i, bands[i]);
+ /* Don't set bands unless explicitly requested to do so */
+ if (mm_simple_connect_properties_get_bands (ctx->properties,
+ &bands,
+ &n_bands)) {
+ GArray *array;
+ guint i;
+
+ array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n_bands);
+ for (i = 0; i < n_bands; i++)
+ g_array_insert_val (array, i, bands[i]);
+
+ mm_iface_modem_set_bands (MM_IFACE_MODEM (ctx->self),
+ array,
+ (GAsyncReadyCallback)set_bands_ready,
+ ctx);
+ g_array_unref (array);
+ return;
+ }
- mm_iface_modem_set_bands (MM_IFACE_MODEM (ctx->self),
- array,
- (GAsyncReadyCallback)set_bands_ready,
- ctx);
- g_array_unref (array);
- return;
+ /* Fall down to next step */
+ ctx->step++;
}
case CONNECTION_STEP_REGISTER: