aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-08-30 16:36:38 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-30 16:36:38 +0200
commit3132e34dc143e90542746f3c85102584279433b0 (patch)
treeb7500f4882101e06f00fe2a94a07483ccdc75b79 /src
parentaa51a16f70178e2c0edb1be0db30b816d02d8f85 (diff)
iface-mode-simple: when setting bands or modes, wait some time to settle down
When bands or allowed modes are changed, the modem will very likely reset its current registration and start from scratch. We will now give it some seconds to settle down before going on with the connection request, so that the modem has enough time to report being unregistered. Without this sleep time, the unsolicited message reporting being unregistered may arrive *after* having checked registration status in the Simple connect sequence, and therefore we end up failing the connection request.
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-modem-simple.c56
1 files changed, 42 insertions, 14 deletions
diff --git a/src/mm-iface-modem-simple.c b/src/mm-iface-modem-simple.c
index 399fb2ab..e4bc466e 100644
--- a/src/mm-iface-modem-simple.c
+++ b/src/mm-iface-modem-simple.c
@@ -272,6 +272,15 @@ register_in_3gpp_or_cdma_network_ready (MMIfaceModemSimple *self,
connection_step (ctx);
}
+static gboolean
+after_set_allowed_modes_timeout_cb (ConnectionContext *ctx)
+{
+ /* Allowed modes set... almost there! */
+ ctx->step++;
+ connection_step (ctx);
+ return FALSE;
+}
+
static void
set_allowed_modes_ready (MMBaseModem *self,
GAsyncResult *res,
@@ -280,19 +289,33 @@ set_allowed_modes_ready (MMBaseModem *self,
GError *error = NULL;
if (!mm_iface_modem_set_allowed_modes_finish (MM_IFACE_MODEM (self), res, &error)) {
- /* If setting allowed modes is unsupported, keep on */
- if (!g_error_matches (error,
- MM_CORE_ERROR,
- MM_CORE_ERROR_UNSUPPORTED)) {
+ if (g_error_matches (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED)) {
+ /* If setting bands is unsupported, keep on without sleep */
+ ctx->step++;
+ connection_step (ctx);
+ } else {
g_dbus_method_invocation_take_error (ctx->invocation, error);
connection_context_free (ctx);
- return;
}
+ return;
}
- /* Allowed modes set... almost there! */
+ /* Setting allowed modes will reset the current registration, so we'll need
+ * a couple of seconds to settle down. This sleep time just makes sure that
+ * the modem has enough time to report being unregistered. */
+ mm_dbg ("Will wait to settle down after updating allowed modes");
+ g_timeout_add_seconds (2, (GSourceFunc)after_set_allowed_modes_timeout_cb, ctx);
+}
+
+static gboolean
+after_set_bands_timeout_cb (ConnectionContext *ctx)
+{
+ /* Bands set... almost there! */
ctx->step++;
connection_step (ctx);
+ return FALSE;
}
static void
@@ -303,19 +326,24 @@ set_bands_ready (MMBaseModem *self,
GError *error = NULL;
if (!mm_iface_modem_set_bands_finish (MM_IFACE_MODEM (self), res, &error)) {
- /* If setting bands is unsupported, keep on */
- if (!g_error_matches (error,
- MM_CORE_ERROR,
- MM_CORE_ERROR_UNSUPPORTED)) {
+ if (g_error_matches (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED)) {
+ /* If setting bands is unsupported, keep on without sleep */
+ ctx->step++;
+ connection_step (ctx);
+ } else {
g_dbus_method_invocation_take_error (ctx->invocation, error);
connection_context_free (ctx);
- return;
}
+ return;
}
- /* Bands set... almost there! */
- ctx->step++;
- connection_step (ctx);
+ /* Setting bands will reset the current registration, so we'll need a couple
+ * of seconds to settle down. This sleep time just makes sure that the modem
+ * has enough time to report being unregistered. */
+ mm_dbg ("Will wait to settle down after updating bands");
+ g_timeout_add_seconds (2, (GSourceFunc)after_set_bands_timeout_cb, ctx);
}
static void