novatel-lte: normalize QMI status when included in DBus error message

This patches normalize a response for the AT$NWQMISTATUS command, by
replacing white-space characters with a space, before the response is
included in a DBus error message.
This commit is contained in:
Ben Chan
2013-05-27 20:55:35 -07:00
committed by Aleksander Morgado
parent 05ac6b6cf1
commit c4f0ad6905

View File

@@ -42,6 +42,22 @@ struct _MMBroadbandBearerNovatelLtePrivate {
guint connection_poller; guint connection_poller;
}; };
static gchar *
normalize_qmistatus (const gchar *status)
{
gchar *normalized_status, *iter;
if (!status)
return NULL;
normalized_status = g_strdup (status);
for (iter = normalized_status; *iter; iter++)
if (g_ascii_isspace (*iter))
*iter = ' ';
return normalized_status;
}
/*****************************************************************************/ /*****************************************************************************/
/* 3GPP Connection sequence */ /* 3GPP Connection sequence */
@@ -146,6 +162,7 @@ connect_3gpp_qmistatus_ready (MMBaseModem *modem,
DetailedConnectContext *ctx) DetailedConnectContext *ctx)
{ {
const gchar *result; const gchar *result;
gchar *normalized_result;
GError *error = NULL; GError *error = NULL;
result = mm_base_modem_at_command_finish (MM_BASE_MODEM (ctx->modem), result = mm_base_modem_at_command_finish (MM_BASE_MODEM (ctx->modem),
@@ -188,10 +205,13 @@ connect_3gpp_qmistatus_ready (MMBaseModem *modem,
} }
/* Already exhausted all retries */ /* Already exhausted all retries */
normalized_result = normalize_qmistatus (result);
g_simple_async_result_set_error (ctx->result, g_simple_async_result_set_error (ctx->result,
MM_CORE_ERROR, MM_CORE_ERROR,
MM_CORE_ERROR_FAILED, MM_CORE_ERROR_FAILED,
"%s", result); "QMI connect failed: %s",
normalized_result);
g_free (normalized_result);
detailed_connect_context_complete_and_free (ctx); detailed_connect_context_complete_and_free (ctx);
} }
@@ -385,6 +405,7 @@ disconnect_3gpp_status_ready (MMBaseModem *modem,
} else { } else {
mm_dbg ("QMI connection status failed: %s", error->message); mm_dbg ("QMI connection status failed: %s", error->message);
g_error_free (error); g_error_free (error);
result = "Unknown error";
} }
if (ctx->retries > 0) { if (ctx->retries > 0) {
@@ -398,13 +419,17 @@ disconnect_3gpp_status_ready (MMBaseModem *modem,
/* If $NWQMISTATUS reports a CONNECTED QMI state, returns an error such that /* If $NWQMISTATUS reports a CONNECTED QMI state, returns an error such that
* the modem state remains 'connected'. Otherwise, assumes the modem is * the modem state remains 'connected'. Otherwise, assumes the modem is
* disconnected from the network successfully. */ * disconnected from the network successfully. */
if (is_connected) if (is_connected) {
gchar *normalized_result;
normalized_result = normalize_qmistatus (result);
g_simple_async_result_set_error (ctx->result, g_simple_async_result_set_error (ctx->result,
MM_CORE_ERROR, MM_CORE_ERROR,
MM_CORE_ERROR_FAILED, MM_CORE_ERROR_FAILED,
"QMI disconnect failed: %s", "QMI disconnect failed: %s",
result); normalized_result);
else g_free (normalized_result);
} else
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
detailed_disconnect_context_complete_and_free (ctx); detailed_disconnect_context_complete_and_free (ctx);