aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2012-08-31 12:31:00 +0200
committerAleksander Morgado <aleksander@lanedo.com>2012-08-31 12:31:00 +0200
commite8ca43e315688f04a4f896646abaffab2b3a395e (patch)
treeea115b0d326dec5aa2ff65ac78357f22ea640dd1 /src
parenta3d32c552c526a7f5850007428a5a32216766a64 (diff)
broadband-modem: if the generic CNMI request fails, try a Qualcomm-compatible one
This is the port to git master of the following commit: commit 1d9164ec90788d1be134482ff88c501e3c5d623c Author: Dan Williams <dcbw@redhat.com> Date: Mon Aug 27 18:20:33 2012 -0500 gsm: if the generic CNMI request fails, try a Qualcomm-compatible one Many devices based on Qualcomm chipsets don't support a <ds> value of '1', despite saying they do in the AT+CNMI=? response. But they do accept '2'. Since we're not doing much with delivery status reports yet, if we get a CME 303 (not supported) error when setting the message indication parameters via CNMI, fall back to the Qualcomm-compatible CNMI parameters. If we don't do this, we don't get SMS indications on these devices, because the original CNMI failed. Tested on Huawei E1550, Huawei E160G, ZTE MF622, and Novatel XU870.
Diffstat (limited to 'src')
-rw-r--r--src/mm-broadband-modem.c61
1 files changed, 54 insertions, 7 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 58f01d68..8c1cef6d 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -4410,20 +4410,67 @@ modem_messaging_enable_unsolicited_events_finish (MMIfaceModemMessaging *self,
GAsyncResult *res,
GError **error)
{
- return !!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
+ GError *inner_error = NULL;
+
+ mm_base_modem_at_sequence_finish (MM_BASE_MODEM (self), res, NULL, &inner_error);
+ if (inner_error) {
+ g_propagate_error (error, inner_error);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+cnmi_response_processor (MMBaseModem *self,
+ gpointer none,
+ const gchar *command,
+ const gchar *response,
+ gboolean last_command,
+ const GError *error,
+ GVariant **result,
+ GError **result_error)
+{
+ if (error) {
+ /* If we get a not-supported error and we're not in the last command, we
+ * won't set 'result_error', so we'll keep on the sequence */
+ if (!g_error_matches (error, MM_MESSAGE_ERROR, MM_MESSAGE_ERROR_NOT_SUPPORTED) ||
+ last_command)
+ *result_error = g_error_copy (error);
+
+ return FALSE;
+ }
+
+ *result = NULL;
+ return TRUE;
}
+/*
+ * Many devices based on Qualcomm chipsets don't support a <ds> value
+ * of '1', despite saying they do in the AT+CNMI=? response. But they
+ * do accept '2'. Since we're not doing much with delivery status
+ * reports yet, if we get a CME 303 (not supported) error when setting
+ * the message indication parameters via CNMI, fall back to the
+ * Qualcomm-compatible CNMI parameters.
+ */
+static const MMBaseModemAtCommand cnmi_sequence[] = {
+ { "+CNMI=2,1,2,1,0", 3, TRUE, cnmi_response_processor },
+ { "+CNMI=2,1,2,2,0", 3, TRUE, cnmi_response_processor },
+ { NULL }
+};
+
static void
modem_messaging_enable_unsolicited_events (MMIfaceModemMessaging *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- mm_base_modem_at_command (MM_BASE_MODEM (self),
- "+CNMI=2,1,2,1,0",
- 3,
- FALSE,
- callback,
- user_data);
+ mm_base_modem_at_sequence (
+ MM_BASE_MODEM (self),
+ cnmi_sequence,
+ NULL, /* response_processor_context */
+ NULL, /* response_processor_context_free */
+ callback,
+ user_data);
}
/*****************************************************************************/