diff options
author | Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com> | 2025-01-31 15:50:14 +0100 |
---|---|---|
committer | Kévin L'hôpital <kevin.lhopital@savoirfairelinux.com> | 2025-02-19 09:47:28 +0100 |
commit | b1e58e0f6e5acb46af83fb2b15b28337d0e447c0 (patch) | |
tree | c44a3204359a150ae37839975a4f941dce1c41e1 /src | |
parent | ab59eaee501b9a167022aa83972af5455de86bfd (diff) |
src: plugins: quectel: add DTMF dbus notification support
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 <kevin.lhopital@savoirfairelinux.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/quectel/mm-shared-quectel.c | 28 |
1 files changed, 28 insertions, 0 deletions
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); @@ -158,6 +163,21 @@ rdy_handler (MMPortSerialAt *port, } /*****************************************************************************/ + +/* 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) */ void @@ -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); } } |