aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Stevens <Nick.Stevens@digi.com>2015-09-14 18:06:48 +0000
committerAleksander Morgado <aleksander@aleksander.es>2015-09-15 16:26:03 +0200
commit48cd903189c2bc664da0f26ba7e6845e1950091e (patch)
tree84af8f5d91d20c5182852a50b16ada68cd0ac008 /src
parent2034918d7b015f1176ec135cc023d4d161db56f7 (diff)
core: enable unsolicited messages on secondary
Previously the enable unsolicited messages command (+CNMI) was only being sent on the primary. This patch adds support for sending the enable on the secondary as well. If the secondary doesn't exist, or if setting the enable causes an error, a warning is logged but no error is propagated up. This change is needed for proper SMS operation on the Telit HE910, which requires that +CNMI be sent to both primary and secondary. Since a failure to send the +CNMI command on the secondary is a non-fatal error, it is unlikely that this will cause issues with other modems. Signed-off-by: Nick Stevens <Nick.Stevens@digi.com>
Diffstat (limited to 'src')
-rw-r--r--src/mm-broadband-modem.c91
1 files changed, 78 insertions, 13 deletions
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index f176b808..1f067140 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -5791,7 +5791,7 @@ set_messaging_unsolicited_events_handlers (MMIfaceModemMessaging *self,
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
- /* Enable unsolicited events in given port */
+ /* Add messaging unsolicited events handler for port primary and secondary */
for (i = 0; i < 2; i++) {
if (!ports[i])
continue;
@@ -5845,15 +5845,7 @@ modem_messaging_enable_unsolicited_events_finish (MMIfaceModemMessaging *self,
GAsyncResult *res,
GError **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;
+ return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
static gboolean
@@ -5895,17 +5887,90 @@ static const MMBaseModemAtCommand cnmi_sequence[] = {
};
static void
+modem_messaging_enable_unsolicited_events_secondary_ready (MMBaseModem *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *final_result)
+{
+ GError *inner_error = NULL;
+ MMPortSerialAt *secondary = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
+
+ /* Since the secondary is not required, we don't propagate the error anywhere */
+ mm_base_modem_at_sequence_full_finish (MM_BASE_MODEM (self), res, NULL, &inner_error);
+ if (inner_error) {
+ mm_warn("(%s) Unable to enable messaging unsolicited events on modem secondary",
+ mm_port_get_device (MM_PORT (secondary)));
+ g_error_free(inner_error);
+ }
+
+ mm_dbg ("(%s) Messaging unsolicited events enabled on secondary",
+ mm_port_get_device (MM_PORT (secondary)));
+
+ g_simple_async_result_complete (final_result);
+ g_object_unref (final_result);
+}
+
+static void
+modem_messaging_enable_unsolicited_events_primary_ready (MMBaseModem *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *final_result)
+{
+ GError *inner_error = NULL;
+ MMPortSerialAt *primary = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
+ MMPortSerialAt *secondary = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
+
+ mm_base_modem_at_sequence_full_finish (MM_BASE_MODEM (self), res, NULL, &inner_error);
+ if (inner_error) {
+ g_simple_async_result_take_error (final_result, inner_error);
+ g_simple_async_result_complete (final_result);
+ g_object_unref (final_result);
+ return;
+ }
+
+ mm_dbg ("(%s) Messaging unsolicited events enabled on primary",
+ mm_port_get_device (MM_PORT (primary)));
+
+ /* Try to enable unsolicited events for secondary port */
+ if (secondary) {
+ mm_dbg ("(%s) Enabling messaging unsolicited events on modem secondary",
+ mm_port_get_device (MM_PORT (secondary)));
+ mm_base_modem_at_sequence_full (
+ MM_BASE_MODEM (self),
+ secondary,
+ cnmi_sequence,
+ NULL, /* response_processor_context */
+ NULL, /* response_processor_context_free */
+ NULL,
+ (GAsyncReadyCallback)modem_messaging_enable_unsolicited_events_secondary_ready,
+ final_result);
+ } else {
+ g_simple_async_result_complete (final_result);
+ g_object_unref (final_result);
+ }
+}
+
+static void
modem_messaging_enable_unsolicited_events (MMIfaceModemMessaging *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
- mm_base_modem_at_sequence (
+ GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ modem_messaging_enable_unsolicited_events);
+ MMPortSerialAt *primary = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
+
+ /* Enable unsolicited events for primary port */
+ mm_dbg ("(%s) Enabling messaging unsolicited events on modem primary",
+ mm_port_get_device (MM_PORT (primary)));
+ mm_base_modem_at_sequence_full (
MM_BASE_MODEM (self),
+ primary,
cnmi_sequence,
NULL, /* response_processor_context */
NULL, /* response_processor_context_free */
- callback,
- user_data);
+ NULL,
+ (GAsyncReadyCallback)modem_messaging_enable_unsolicited_events_primary_ready,
+ result);
}
/*****************************************************************************/