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/tests/test-modem-helpers-simtech.c | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'plugins/simtech/tests/test-modem-helpers-simtech.c') diff --git a/plugins/simtech/tests/test-modem-helpers-simtech.c b/plugins/simtech/tests/test-modem-helpers-simtech.c index 3092e936..0274ae92 100644 --- a/plugins/simtech/tests/test-modem-helpers-simtech.c +++ b/plugins/simtech/tests/test-modem-helpers-simtech.c @@ -193,6 +193,47 @@ test_voice_call_end_duration_urc (void) /*****************************************************************************/ +static void +common_test_cring_urc (const gchar *urc, + const gchar *expected_type) +{ + GError *error = NULL; + GRegex *cring_regex = NULL; + GMatchInfo *match_info = NULL; + gchar *type; + gboolean result; + + cring_regex = mm_simtech_get_cring_urc_regex (); + + /* Same matching logic as done in MMSerialPortAt when processing URCs! */ + result = g_regex_match_full (cring_regex, urc, -1, 0, 0, &match_info, &error); + g_assert_no_error (error); + g_assert (result); + + type = g_match_info_fetch (match_info, 1); + g_assert (type); + + g_assert_cmpstr (type, ==, expected_type); + + g_match_info_free (match_info); + g_regex_unref (cring_regex); + g_free (type); +} + +static void +test_cring_urc_two_crs (void) +{ + common_test_cring_urc ("\r\r\n+CRING: VOICE\r\r\n", "VOICE"); +} + +static void +test_cring_urc_one_cr (void) +{ + common_test_cring_urc ("\r\n+CRING: VOICE\r\n", "VOICE"); +} + +/*****************************************************************************/ + void _mm_log (const char *loc, const char *func, @@ -227,5 +268,8 @@ int main (int argc, char **argv) g_test_add_func ("/MM/simtech/voicecall/urc/end", test_voice_call_end_urc); g_test_add_func ("/MM/simtech/voicecall/urc/end-duration", test_voice_call_end_duration_urc); + g_test_add_func ("/MM/simtech/cring/urc/two-crs", test_cring_urc_two_crs); + g_test_add_func ("/MM/simtech/cring/urc/one-cr", test_cring_urc_one_cr); + return g_test_run (); } -- cgit v1.2.3-70-g09d2