From b1e58e0f6e5acb46af83fb2b15b28337d0e447c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20L=27h=C3=B4pital?= Date: Fri, 31 Jan 2025 15:50:14 +0100 Subject: [PATCH] src: plugins: quectel: add DTMF dbus notification support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The quectel modems that are not using QMI could receive DTMF events but no dbus notification was sent to the user space. This patch adds the DTMF notification support to the quectel plugin. Signed-off-by: Kévin L'hôpital --- src/plugins/quectel/mm-shared-quectel.c | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/plugins/quectel/mm-shared-quectel.c b/src/plugins/quectel/mm-shared-quectel.c index 6226dacd..24278bb6 100644 --- a/src/plugins/quectel/mm-shared-quectel.c +++ b/src/plugins/quectel/mm-shared-quectel.c @@ -26,6 +26,7 @@ #include "mm-iface-modem.h" #include "mm-iface-modem-firmware.h" #include "mm-iface-modem-location.h" +#include "mm-iface-modem-voice.h" #include "mm-base-modem.h" #include "mm-base-modem-at.h" #include "mm-shared-quectel.h" @@ -56,6 +57,7 @@ typedef struct { MMModemLocationSource provided_sources; MMModemLocationSource enabled_sources; FeatureSupport qgps_supported; + GRegex *dtmf_regex; GRegex *qgpsurc_regex; GRegex *qlwurc_regex; GRegex *rdy_regex; @@ -64,6 +66,7 @@ typedef struct { static void private_free (Private *priv) { + g_regex_unref (priv->dtmf_regex); g_regex_unref (priv->qgpsurc_regex); g_regex_unref (priv->qlwurc_regex); g_regex_unref (priv->rdy_regex); @@ -85,10 +88,12 @@ get_private (MMSharedQuectel *self) priv->provided_sources = MM_MODEM_LOCATION_SOURCE_NONE; priv->enabled_sources = MM_MODEM_LOCATION_SOURCE_NONE; priv->qgps_supported = FEATURE_SUPPORT_UNKNOWN; + priv->dtmf_regex = g_regex_new ("\\r\\n\\+QTONEDET:\\s*(\\d+)\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); priv->qgpsurc_regex = g_regex_new ("\\r\\n\\+QGPSURC:.*", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); priv->qlwurc_regex = g_regex_new ("\\r\\n\\+QLWURC:.*", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); priv->rdy_regex = g_regex_new ("\\r\\nRDY", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); + g_assert (priv->dtmf_regex); g_assert (priv->qgpsurc_regex); g_assert (priv->qlwurc_regex); g_assert (priv->rdy_regex); @@ -157,6 +162,21 @@ rdy_handler (MMPortSerialAt *port, mm_base_modem_set_valid (MM_BASE_MODEM (self), FALSE); } +/*****************************************************************************/ + +/* DTMF unsolicited event handler */ +static void +dtmf_handler (MMPortSerialAt *port, + GMatchInfo *match_info, + MMBroadbandModem *self) +{ + g_autofree gchar *dtmf = NULL; + dtmf = g_match_info_fetch (match_info, 1); + + mm_obj_dbg (self, "received DTMF: %s", dtmf); + mm_iface_modem_voice_received_dtmf (MM_IFACE_MODEM_VOICE (self), 0, dtmf); +} + /*****************************************************************************/ /* Setup ports (Broadband modem class) */ @@ -203,6 +223,14 @@ mm_shared_quectel_setup_ports (MMBroadbandModem *self) (MMPortSerialAtUnsolicitedMsgFn)rdy_handler, self, NULL); + + /* Handle DTMF */ + mm_port_serial_at_add_unsolicited_msg_handler ( + ports[i], + priv->dtmf_regex, + (MMPortSerialAtUnsolicitedMsgFn)dtmf_handler, + self, + NULL); } }