broadband-modem: implement +CCWA URC handling
This commit is contained in:
@@ -7249,13 +7249,26 @@ modem_voice_setup_cleanup_unsolicited_events_finish (MMIfaceModemVoice *self,
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
ccwa_received (MMPortSerialAt *port,
|
||||
GMatchInfo *info,
|
||||
MMBroadbandModem *self)
|
||||
{
|
||||
gchar *str;
|
||||
|
||||
str = mm_get_string_unquoted_from_match_info (info, 1);
|
||||
mm_dbg ("Call waiting (%s)", str);
|
||||
mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), str, MM_CALL_STATE_WAITING);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
static void
|
||||
ring_received (MMPortSerialAt *port,
|
||||
GMatchInfo *info,
|
||||
MMBroadbandModem *self)
|
||||
{
|
||||
mm_dbg ("Ringing");
|
||||
mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), NULL);
|
||||
mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), NULL, MM_CALL_STATE_RINGING_IN);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -7271,7 +7284,7 @@ cring_received (MMPortSerialAt *port,
|
||||
mm_dbg ("Ringing (%s)", str);
|
||||
g_free (str);
|
||||
|
||||
mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), NULL);
|
||||
mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), NULL, MM_CALL_STATE_RINGING_IN);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -7282,7 +7295,7 @@ clip_received (MMPortSerialAt *port,
|
||||
gchar *str;
|
||||
|
||||
str = mm_get_string_unquoted_from_match_info (info, 1);
|
||||
mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), str);
|
||||
mm_iface_modem_voice_report_incoming_call (MM_IFACE_MODEM_VOICE (self), str, MM_CALL_STATE_RINGING_IN);
|
||||
g_free (str);
|
||||
}
|
||||
|
||||
@@ -7296,12 +7309,14 @@ set_voice_unsolicited_events_handlers (MMIfaceModemVoice *self,
|
||||
GRegex *cring_regex;
|
||||
GRegex *ring_regex;
|
||||
GRegex *clip_regex;
|
||||
GRegex *ccwa_regex;
|
||||
guint i;
|
||||
GTask *task;
|
||||
|
||||
cring_regex = mm_voice_cring_regex_get ();
|
||||
ring_regex = mm_voice_ring_regex_get ();
|
||||
clip_regex = mm_voice_clip_regex_get ();
|
||||
ccwa_regex = mm_voice_ccwa_regex_get ();
|
||||
ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
|
||||
ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
|
||||
|
||||
@@ -7332,8 +7347,15 @@ set_voice_unsolicited_events_handlers (MMIfaceModemVoice *self,
|
||||
enable ? (MMPortSerialAtUnsolicitedMsgFn) clip_received : NULL,
|
||||
enable ? self : NULL,
|
||||
NULL);
|
||||
mm_port_serial_at_add_unsolicited_msg_handler (
|
||||
ports[i],
|
||||
ccwa_regex,
|
||||
enable ? (MMPortSerialAtUnsolicitedMsgFn) ccwa_received : NULL,
|
||||
enable ? self : NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
g_regex_unref (ccwa_regex);
|
||||
g_regex_unref (clip_regex);
|
||||
g_regex_unref (cring_regex);
|
||||
g_regex_unref (ring_regex);
|
||||
|
||||
@@ -558,6 +558,23 @@ mm_voice_clip_regex_get (void)
|
||||
NULL);
|
||||
}
|
||||
|
||||
GRegex *
|
||||
mm_voice_ccwa_regex_get (void)
|
||||
{
|
||||
/*
|
||||
* Only first 3 fields are mandatory, but we read only the first one
|
||||
* +CCWA: <number>,<type>,<class>,[<alpha>][,<CLI_validity>[,<subaddr>,<satype>[,<priority>]]]
|
||||
*
|
||||
* Example:
|
||||
* <CR><LF>+CCWA: "+393351391306",145,1
|
||||
* \_ Number \_ Type
|
||||
*/
|
||||
return g_regex_new ("\\r\\n\\+CCWA:\\s*([^,\\s]*)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,?(.*)\\r\\n",
|
||||
G_REGEX_RAW | G_REGEX_OPTIMIZE,
|
||||
0,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
static MMFlowControl
|
||||
|
||||
@@ -93,9 +93,11 @@ gchar *mm_bcd_to_string (const guint8 *bcd, gsize bcd_len);
|
||||
/*****************************************************************************/
|
||||
/* VOICE specific helpers and utilities */
|
||||
/*****************************************************************************/
|
||||
|
||||
GRegex *mm_voice_ring_regex_get (void);
|
||||
GRegex *mm_voice_cring_regex_get (void);
|
||||
GRegex *mm_voice_clip_regex_get (void);
|
||||
GRegex *mm_voice_ccwa_regex_get (void);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* SERIAL specific helpers and utilities */
|
||||
|
||||
@@ -3969,6 +3969,55 @@ test_clip_indication (void)
|
||||
g_regex_unref (r);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* +CCWA URC */
|
||||
|
||||
typedef struct {
|
||||
const gchar *str;
|
||||
const gchar *number;
|
||||
guint type;
|
||||
guint class;
|
||||
} CcwaUrcTest;
|
||||
|
||||
static const CcwaUrcTest ccwa_urc_tests[] = {
|
||||
{ "\r\n+CCWA: \"123456789\",129,1\r\n", "123456789", 129, 1 },
|
||||
{ "\r\n+CCWA: \"123456789\",129,1,,0\r\n", "123456789", 129, 1 },
|
||||
{ "\r\n+CCWA: \"123456789\",129,1,,0,,,\r\n", "123456789", 129, 1 },
|
||||
};
|
||||
|
||||
static void
|
||||
test_ccwa_indication (void)
|
||||
{
|
||||
GRegex *r;
|
||||
guint i;
|
||||
|
||||
r = mm_voice_ccwa_regex_get ();
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (ccwa_urc_tests); i++) {
|
||||
GMatchInfo *match_info = NULL;
|
||||
gchar *number;
|
||||
guint type;
|
||||
guint class;
|
||||
|
||||
g_assert (g_regex_match (r, ccwa_urc_tests[i].str, 0, &match_info));
|
||||
g_assert (g_match_info_matches (match_info));
|
||||
|
||||
number = mm_get_string_unquoted_from_match_info (match_info, 1);
|
||||
g_assert_cmpstr (number, ==, ccwa_urc_tests[i].number);
|
||||
|
||||
g_assert (mm_get_uint_from_match_info (match_info, 2, &type));
|
||||
g_assert_cmpuint (type, ==, ccwa_urc_tests[i].type);
|
||||
|
||||
g_assert (mm_get_uint_from_match_info (match_info, 3, &class));
|
||||
g_assert_cmpuint (class, ==, ccwa_urc_tests[i].class);
|
||||
|
||||
g_free (number);
|
||||
g_match_info_free (match_info);
|
||||
}
|
||||
|
||||
g_regex_unref (r);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
@@ -4281,6 +4330,7 @@ int main (int argc, char **argv)
|
||||
g_test_suite_add (suite, TESTCASE (test_cesq_response_to_signal, NULL));
|
||||
|
||||
g_test_suite_add (suite, TESTCASE (test_clip_indication, NULL));
|
||||
g_test_suite_add (suite, TESTCASE (test_ccwa_indication, NULL));
|
||||
|
||||
g_test_suite_add (suite, TESTCASE (test_parse_uint_list, NULL));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user