From 345922caa10fc86dad181ccd83239af1f43fd30e Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 15 Oct 2019 10:40:11 +0200 Subject: simtech: handle non-standard '+CRING' URCs The SIM7600E ends up emitting these URCs with too many s, and the generic +CRING handler doesn't catch them, interfering with other actions, e.g.: $ sudo mmcli --call 1 --accept error: couldn't accept the call: 'GDBus.Error:org.freedesktop.ModemManager1.Error.Core.Failed: Couldn't accept the call: Unhandled response '+CRING: VOICE +CRING: VOICE'' --- plugins/simtech/mm-shared-simtech.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'plugins/simtech/mm-shared-simtech.c') diff --git a/plugins/simtech/mm-shared-simtech.c b/plugins/simtech/mm-shared-simtech.c index 5a54ba44..45869c31 100644 --- a/plugins/simtech/mm-shared-simtech.c +++ b/plugins/simtech/mm-shared-simtech.c @@ -53,11 +53,13 @@ typedef struct { FeatureSupport clcc_urc_support; GRegex *clcc_urc_regex; GRegex *voice_call_regex; + GRegex *cring_regex; } Private; static void private_free (Private *ctx) { + g_regex_unref (ctx->cring_regex); g_regex_unref (ctx->voice_call_regex); g_regex_unref (ctx->clcc_urc_regex); g_slice_free (Private, ctx); @@ -80,6 +82,7 @@ get_private (MMSharedSimtech *self) priv->clcc_urc_support = FEATURE_SUPPORT_UNKNOWN; priv->clcc_urc_regex = mm_simtech_get_clcc_urc_regex (); priv->voice_call_regex = mm_simtech_get_voice_call_urc_regex (); + priv->cring_regex = mm_simtech_get_cring_urc_regex (); /* Setup parent class' MMIfaceModemLocation and MMIfaceModemVoice */ @@ -829,6 +832,27 @@ voice_call_urc_received (MMPortSerialAt *port, mm_dbg ("voice call finished"); } +static void +cring_urc_received (MMPortSerialAt *port, + GMatchInfo *info, + MMSharedSimtech *self) +{ + MMCallInfo call_info; + gchar *str; + + /* We could have "VOICE" or "DATA". Now consider only "VOICE" */ + str = mm_get_string_unquoted_from_match_info (info, 1); + mm_dbg ("Ringing (%s)", str); + g_free (str); + + call_info.index = 0; + call_info.direction = MM_CALL_DIRECTION_INCOMING; + call_info.state = MM_CALL_STATE_RINGING_IN; + call_info.number = NULL; + + mm_iface_modem_voice_report_call (MM_IFACE_MODEM_VOICE (self), &call_info); +} + static void common_voice_setup_cleanup_unsolicited_events (MMSharedSimtech *self, gboolean enable) @@ -858,6 +882,12 @@ common_voice_setup_cleanup_unsolicited_events (MMSharedSimtech *self, enable ? (MMPortSerialAtUnsolicitedMsgFn)voice_call_urc_received : NULL, enable ? self : NULL, NULL); + + mm_port_serial_at_add_unsolicited_msg_handler (ports[i], + priv->cring_regex, + enable ? (MMPortSerialAtUnsolicitedMsgFn)cring_urc_received : NULL, + enable ? self : NULL, + NULL); } } -- cgit v1.2.3-70-g09d2