gsm: correctly parse Samsung S8500 Wave CREG response
(testcases by dcbw)
This commit is contained in:

committed by
Dan Williams

parent
7a2031613a
commit
f4d4569cdd
@@ -242,10 +242,14 @@ mm_gsm_destroy_scan_data (gpointer data)
|
|||||||
/* +CREG: <n>,<stat>,<lac>,<ci>,<AcT> (ETSI 27.007 solicited and some CREG=2 unsolicited) */
|
/* +CREG: <n>,<stat>,<lac>,<ci>,<AcT> (ETSI 27.007 solicited and some CREG=2 unsolicited) */
|
||||||
#define CREG6 "\\+(CREG|CGREG):\\s*(\\d{1}),\\s*(\\d{1})\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(\\d{1,2})"
|
#define CREG6 "\\+(CREG|CGREG):\\s*(\\d{1}),\\s*(\\d{1})\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*(\\d{1,2})"
|
||||||
|
|
||||||
|
/* +CREG: <n>,<stat>,<lac>,<ci>,<AcT?>,<something> (Samsung Wave S8500) */
|
||||||
|
/* '<CR><LF>+CREG: 2,1,000B,2816, B, C2816<CR><LF><CR><LF>OK<CR><LF>' */
|
||||||
|
#define CREG7 "\\+(CREG|CGREG):\\s*(\\d{1}),\\s*(\\d{1})\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)\\s*,\\s*[^,\\s]*"
|
||||||
|
|
||||||
GPtrArray *
|
GPtrArray *
|
||||||
mm_gsm_creg_regex_get (gboolean solicited)
|
mm_gsm_creg_regex_get (gboolean solicited)
|
||||||
{
|
{
|
||||||
GPtrArray *array = g_ptr_array_sized_new (6);
|
GPtrArray *array = g_ptr_array_sized_new (7);
|
||||||
GRegex *regex;
|
GRegex *regex;
|
||||||
|
|
||||||
/* #1 */
|
/* #1 */
|
||||||
@@ -296,6 +300,14 @@ mm_gsm_creg_regex_get (gboolean solicited)
|
|||||||
g_assert (regex);
|
g_assert (regex);
|
||||||
g_ptr_array_add (array, regex);
|
g_ptr_array_add (array, regex);
|
||||||
|
|
||||||
|
/* #7 */
|
||||||
|
if (solicited)
|
||||||
|
regex = g_regex_new (CREG7 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||||
|
else
|
||||||
|
regex = g_regex_new ("\\r\\n" CREG7 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
|
||||||
|
g_assert (regex);
|
||||||
|
g_ptr_array_add (array, regex);
|
||||||
|
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -721,6 +721,16 @@ test_cgreg2_x220_unsolicited (void *f, gpointer d)
|
|||||||
test_creg_match ("Alcatel One-Touch X220D CGREG=2", FALSE, reply, data, &result);
|
test_creg_match ("Alcatel One-Touch X220D CGREG=2", FALSE, reply, data, &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_creg2_s8500_wave_unsolicited (void *f, gpointer d)
|
||||||
|
{
|
||||||
|
TestData *data = (TestData *) d;
|
||||||
|
const char *reply = "\r\n+CREG: 2,1,000B,2816, B, C2816\r\n";
|
||||||
|
const CregResult result = { 1, 0x000B, 0x2816, 0, 7, FALSE};
|
||||||
|
|
||||||
|
test_creg_match ("Samsung Wave S8500 CREG=2", FALSE, reply, data, &result);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_cscs_icon225_support_response (void *f, gpointer d)
|
test_cscs_icon225_support_response (void *f, gpointer d)
|
||||||
{
|
{
|
||||||
@@ -1231,6 +1241,7 @@ int main (int argc, char **argv)
|
|||||||
g_test_suite_add (suite, TESTCASE (test_creg2_tm506_solicited, data));
|
g_test_suite_add (suite, TESTCASE (test_creg2_tm506_solicited, data));
|
||||||
g_test_suite_add (suite, TESTCASE (test_creg2_xu870_unsolicited_unregistered, data));
|
g_test_suite_add (suite, TESTCASE (test_creg2_xu870_unsolicited_unregistered, data));
|
||||||
g_test_suite_add (suite, TESTCASE (test_creg2_md400_unsolicited, data));
|
g_test_suite_add (suite, TESTCASE (test_creg2_md400_unsolicited, data));
|
||||||
|
g_test_suite_add (suite, TESTCASE (test_creg2_s8500_wave_unsolicited, data));
|
||||||
|
|
||||||
g_test_suite_add (suite, TESTCASE (test_cgreg1_solicited, data));
|
g_test_suite_add (suite, TESTCASE (test_cgreg1_solicited, data));
|
||||||
g_test_suite_add (suite, TESTCASE (test_cgreg1_unsolicited, data));
|
g_test_suite_add (suite, TESTCASE (test_cgreg1_unsolicited, data));
|
||||||
|
Reference in New Issue
Block a user