aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Chan <benchan@chromium.org>2013-01-30 01:07:54 -0800
committerAleksander Morgado <aleksander@lanedo.com>2013-01-30 23:11:59 +0100
commit87a556dbb18fa21d47331c2504350820480414c9 (patch)
tree3de251beb738c1e44a257e7d49aad207b75538ca
parent24b28d1a72a71a38399184d2c2f85a34612f3a2a (diff)
novatel-lte: retry $NWQMISTATUS check upon error during disconnect
$NWQMISTATUS sometimes returns 'ERROR'. This patch modifies the Novatel LTE plugin to retry $NWQMISTATUS (up to 5 times) to determine if the disconnect operation succeeds. It also changes the plugin to assume that the disconnect operation succeeds if $NWQMISTATUS fails to report the current connection status.
-rw-r--r--plugins/novatel/mm-broadband-bearer-novatel-lte.c68
1 files changed, 51 insertions, 17 deletions
diff --git a/plugins/novatel/mm-broadband-bearer-novatel-lte.c b/plugins/novatel/mm-broadband-bearer-novatel-lte.c
index 80c74645..4b67cd64 100644
--- a/plugins/novatel/mm-broadband-bearer-novatel-lte.c
+++ b/plugins/novatel/mm-broadband-bearer-novatel-lte.c
@@ -325,6 +325,7 @@ typedef struct {
MMAtSerialPort *secondary;
MMPort *data;
GSimpleAsyncResult *result;
+ gint retries;
} DetailedDisconnectContext;
static DetailedDisconnectContext *
@@ -348,6 +349,7 @@ detailed_disconnect_context_new (MMBroadbandBearer *self,
callback,
user_data,
detailed_disconnect_context_new);
+ ctx->retries = 4;
return ctx;
}
@@ -373,34 +375,72 @@ disconnect_3gpp_finish (MMBroadbandBearer *self,
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
+static gboolean disconnect_3gpp_qmistatus (DetailedDisconnectContext *ctx);
+
static void
-disconnect_3gpp_status_complete (MMBaseModem *modem,
- GAsyncResult *res,
- DetailedDisconnectContext *ctx)
+disconnect_3gpp_status_ready (MMBaseModem *modem,
+ GAsyncResult *res,
+ DetailedDisconnectContext *ctx)
{
const gchar *result;
GError *error = NULL;
+ gboolean is_connected = FALSE;
result = mm_base_modem_at_command_finish (MM_BASE_MODEM (modem),
res,
&error);
- if (error) {
- mm_dbg("QMI connection status failed: %s", error->message);
+ if (result) {
+ mm_dbg ("QMI connection status: %s", result);
+ if (is_qmistatus_disconnected (result)) {
+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
+ detailed_disconnect_context_complete_and_free (ctx);
+ return;
+ } else if (is_qmistatus_connected (result)) {
+ is_connected = TRUE;
+ }
+ } else {
+ mm_dbg ("QMI connection status failed: %s", error->message);
g_error_free (error);
}
- if (result && is_qmistatus_disconnected (result))
- g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
- else
+ if (ctx->retries > 0) {
+ ctx->retries--;
+ mm_dbg ("Retrying status check in a second. %d retries left.",
+ ctx->retries);
+ g_timeout_add_seconds (1, (GSourceFunc)disconnect_3gpp_qmistatus, ctx);
+ return;
+ }
+
+ /* If $NWQMISTATUS reports a CONNECTED QMI state, returns an error such that
+ * the modem state remains 'connected'. Otherwise, assumes the modem is
+ * disconnected from the network successfully. */
+ if (is_connected)
g_simple_async_result_set_error (ctx->result,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
- "Error checking if disconnected (%s)",
- result ? result : "no result");
+ "QMI disconnect failed: %s",
+ result);
+ else
+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
detailed_disconnect_context_complete_and_free (ctx);
}
+static gboolean
+disconnect_3gpp_qmistatus (DetailedDisconnectContext *ctx)
+{
+ mm_base_modem_at_command (
+ ctx->modem,
+ "$NWQMISTATUS",
+ 3, /* timeout */
+ FALSE, /* allow_cached */
+ (GAsyncReadyCallback)disconnect_3gpp_status_ready, /* callback */
+ ctx); /* user_data */
+
+ return FALSE;
+}
+
+
static void
disconnect_3gpp_check_status (MMBaseModem *modem,
GAsyncResult *res,
@@ -416,13 +456,7 @@ disconnect_3gpp_check_status (MMBaseModem *modem,
g_error_free (error);
}
- mm_base_modem_at_command (
- ctx->modem,
- "$NWQMISTATUS",
- 3, /* timeout */
- FALSE, /* allow_cached */
- (GAsyncReadyCallback)disconnect_3gpp_status_complete,
- ctx); /* user_data */
+ disconnect_3gpp_qmistatus (ctx);
}
static void