[PATCH] Adding 3gpp unsolicited events support for Telit modems

Daniele Palmas dnlplm at gmail.com
Fri Mar 13 08:25:48 PDT 2015


Mobile Equipment Event Reporting command for Telit modems (+CMER)
does not support <ind>=1. Changing to <ind>=2
---
 plugins/telit/mm-broadband-modem-telit.c | 52 +++++++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/plugins/telit/mm-broadband-modem-telit.c b/plugins/telit/mm-broadband-modem-telit.c
index 2f44a4b..971e85e 100644
--- a/plugins/telit/mm-broadband-modem-telit.c
+++ b/plugins/telit/mm-broadband-modem-telit.c
@@ -29,12 +29,15 @@
 #include "mm-modem-helpers.h"
 #include "mm-base-modem-at.h"
 #include "mm-iface-modem.h"
+#include "mm-iface-modem-3gpp.h"
 #include "mm-broadband-modem-telit.h"
 
 static void iface_modem_init (MMIfaceModem *iface);
+static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
 
 G_DEFINE_TYPE_EXTENDED (MMBroadbandModemTelit, mm_broadband_modem_telit, MM_TYPE_BROADBAND_MODEM, 0,
-                        G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init));
+                        G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
+                        G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init));
 
 /*****************************************************************************/
 /* Load access technologies (Modem interface) */
@@ -221,6 +224,46 @@ setup_flow_control (MMIfaceModem *self,
 }
 
 /*****************************************************************************/
+/* Enabling unsolicited events (3GPP interface) */
+
+static gboolean
+modem_3gpp_enable_unsolicited_events_finish (MMIfaceModem3gpp *self,
+                                             GAsyncResult *res,
+                                             GError **error)
+{
+   /* Ignore errors */
+    mm_base_modem_at_sequence_full_finish (MM_BASE_MODEM (self),
+                                           res,
+                                           NULL,
+                                           NULL);
+    return TRUE;
+}
+
+static const MMBaseModemAtCommand unsolicited_enable_sequence[] = {
+    /* Enable +CIEV only for: signal, service, roam */
+    { "AT+CIND=0,1,1,0,0,0,1,0,0", 5, FALSE, NULL },
+    /* Telit modems +CMER command supports only <ind>=2 */
+    { "+CMER=3,0,0,2", 5, FALSE, NULL },
+    { NULL }
+};
+
+static void
+modem_3gpp_enable_unsolicited_events (MMIfaceModem3gpp *self,
+                                      GAsyncReadyCallback callback,
+                                      gpointer user_data)
+{
+    mm_base_modem_at_sequence_full (
+        MM_BASE_MODEM (self),
+        mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self)),
+        unsolicited_enable_sequence,
+        NULL,  /* response_processor_context */
+        NULL,  /* response_processor_context_free */
+        NULL,  /* cancellable */
+        callback,
+        user_data);
+}
+
+/*****************************************************************************/
 
 MMBroadbandModemTelit *
 mm_broadband_modem_telit_new (const gchar *device,
@@ -253,6 +296,13 @@ iface_modem_init (MMIfaceModem *iface)
 }
 
 static void
+iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
+{
+    iface->enable_unsolicited_events = modem_3gpp_enable_unsolicited_events;
+    iface->enable_unsolicited_events_finish = modem_3gpp_enable_unsolicited_events_finish;
+}
+
+static void
 mm_broadband_modem_telit_class_init (MMBroadbandModemTelitClass *klass)
 {
 }
-- 
1.9.1



More information about the ModemManager-devel mailing list