summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-11-26 19:55:07 (GMT)
committerDan Williams <dcbw@redhat.com>2012-11-27 15:56:25 (GMT)
commit33f440c88543c32b70b0ba9458dc047c35ad23c9 (patch)
tree550e8288d1d708a4e5facfc9a13989923f610db7
parent562055b53b7878e7bb0e240ae121d4bcd6926e93 (diff)
broadband-modem: fall back to +CSQ if +CIND signal quality checking fails
If +CIND fails for any reason (generic failure, wrong indexes, etc) or reports zero signal strength (quirky modem) then fall back to +CSQ.
-rw-r--r--src/mm-broadband-modem.c72
1 files changed, 37 insertions, 35 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 174de9d..94c4144 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -1426,53 +1426,55 @@ signal_quality_cind_ready (MMBroadbandModem *self,
GError *error = NULL;
const gchar *result;
GByteArray *indicators;
- guint quality;
+ guint quality = 0;
result = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
- if (!error)
- indicators = mm_3gpp_parse_cind_read_response (result, &error);
-
if (error) {
- g_simple_async_result_take_error (ctx->result, error);
- signal_quality_context_complete_and_free (ctx);
- return;
+ g_clear_error (&error);
+ goto try_csq;
}
- if (indicators->len < self->priv->modem_cind_indicator_signal_quality) {
- g_simple_async_result_set_error (ctx->result,
- MM_CORE_ERROR,
- MM_CORE_ERROR_FAILED,
- "Could not parse CIND signal quality results "
- "signal index (%u) outside received range (0-%u)",
- self->priv->modem_cind_indicator_signal_quality,
- indicators->len);
- g_byte_array_free (indicators, TRUE);
- signal_quality_context_complete_and_free (ctx);
- return;
+ indicators = mm_3gpp_parse_cind_read_response (result, &error);
+ if (!indicators) {
+ mm_dbg ("(%s) Could not parse CIND signal quality results: %s",
+ mm_port_get_device (MM_PORT (ctx->port)),
+ error->message);
+ g_clear_error (&error);
+ goto try_csq;
}
- quality = g_array_index (indicators,
- guint8,
- self->priv->modem_cind_indicator_signal_quality);
+ if (indicators->len < self->priv->modem_cind_indicator_signal_quality) {
+ mm_dbg ("(%s) Could not parse CIND signal quality results; signal "
+ "index (%u) outside received range (0-%u)",
+ mm_port_get_device (MM_PORT (ctx->port)),
+ self->priv->modem_cind_indicator_signal_quality,
+ indicators->len);
+ } else {
+ quality = g_array_index (indicators,
+ guint8,
+ self->priv->modem_cind_indicator_signal_quality);
+ quality = normalize_ciev_cind_signal_quality (quality,
+ self->priv->modem_cind_min_signal_quality,
+ self->priv->modem_cind_max_signal_quality);
+ }
g_byte_array_free (indicators, TRUE);
- quality = normalize_ciev_cind_signal_quality (quality,
- self->priv->modem_cind_min_signal_quality,
- self->priv->modem_cind_max_signal_quality);
-
- /* Some LTE devices say they support signal via CIND,
- * but always report zero even though they have signal. So
- * if we get zero signal, try CSQ too. (bgo #636040)
- */
- if (quality == 0) {
- signal_quality_csq (ctx);
+ if (quality > 0) {
+ /* +CIND success */
+ g_simple_async_result_set_op_res_gpointer (ctx->result,
+ GUINT_TO_POINTER (quality),
+ NULL);
+ signal_quality_context_complete_and_free (ctx);
return;
}
- g_simple_async_result_set_op_res_gpointer (ctx->result,
- GUINT_TO_POINTER (quality),
- NULL);
- signal_quality_context_complete_and_free (ctx);
+try_csq:
+ /* Always fall back to +CSQ if for whatever reason +CIND failed. Also,
+ * some QMI-based devices say they support signal via CIND, but always
+ * report zero even though they have signal. So if we get zero signal
+ * from +CIND, try CSQ too. (bgo #636040)
+ */
+ signal_quality_csq (ctx);
}
static void