gsm: fix CREG/CGREG parsing with multiple responses

When a modem sends both CREG and CGREG in the same response packet,
the parser was failing to correctly distinguish which response
was being parsed, since the string passed to g_regex_match() is
the whole response including both CREG + CGREG.
This commit is contained in:
Dan Williams
2010-03-09 23:34:19 -08:00
parent 658d3d572d
commit 46ec3bdb47
3 changed files with 57 additions and 34 deletions
+22
View File
@@ -670,6 +670,25 @@ test_cgreg2_f3607gw_unsolicited (void *f, gpointer d)
test_creg_match ("Ericsson F3607gw CGREG=2", FALSE, reply, data, &result);
}
static void
test_creg_cgreg_multi_unsolicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "\r\n+CREG: 5\r\n\r\n+CGREG: 0\r\n";
const CregResult result = { 5, 0, 0, -1, 1, FALSE};
test_creg_match ("Multi CREG/CGREG", FALSE, reply, data, &result);
}
static void
test_creg_cgreg_multi2_unsolicited (void *f, gpointer d)
{
TestData *data = (TestData *) d;
const char *reply = "\r\n+CGREG: 0\r\n\r\n+CREG: 5\r\n";
const CregResult result = { 0, 0, 0, -1, 1, TRUE};
test_creg_match ("Multi CREG/CGREG #2", FALSE, reply, data, &result);
}
static TestData *
test_data_new (void)
@@ -753,6 +772,9 @@ int main (int argc, char **argv)
g_test_suite_add (suite, TESTCASE (test_cgreg2_f3607gw_solicited, data));
g_test_suite_add (suite, TESTCASE (test_cgreg2_f3607gw_unsolicited, data));
g_test_suite_add (suite, TESTCASE (test_creg_cgreg_multi_unsolicited, data));
g_test_suite_add (suite, TESTCASE (test_creg_cgreg_multi2_unsolicited, data));
result = g_test_run ();
test_data_free (data);