[PATCH 1/2] allow optional quotes in +CREG: <stat>, "<lac>", "<ci>" (GSM 07.07 CREG=2 unsolicited) pattern; add testcase for Thuraya XT

Aleksander Morgado aleksander at aleksander.es
Sat Feb 13 13:35:22 UTC 2016


On 13/02/16 14:19, Thomas Sailer wrote:
> From: Thomas Sailer <t.sailer at alumni.ethz.ch>
> 
> Signed-off-by: Thomas Sailer <t.sailer at alumni.ethz.ch>
> ---
>  src/mm-modem-helpers.c         | 11 ++++++++++-
>  src/tests/test-modem-helpers.c | 26 ++++++++++++++++++++++++--
>  2 files changed, 34 insertions(+), 3 deletions(-)
> 

I rewrote the commit message to make the first line below the usual 80
chars limit, and then pushed to git master.

Thanks!

> diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
> index 0331aa7..dec53c3 100644
> --- a/src/mm-modem-helpers.c
> +++ b/src/mm-modem-helpers.c
> @@ -434,6 +434,7 @@ mm_voice_clip_regex_get (void)
>  
>  /* +CREG: <stat>,<lac>,<ci>           (GSM 07.07 CREG=2 unsolicited) */
>  #define CREG3 "\\+(CREG|CGREG|CEREG):\\s*0*([0-9]),\\s*([^,\\s]*)\\s*,\\s*([^,\\s]*)"
> +#define CREG11 "\\+(CREG|CGREG|CEREG):\\s*0*([0-9]),\\s*(\"[^\"\\s]*\")\\s*,\\s*(\"[^\"\\s]*\")"
>  
>  /* +CREG: <n>,<stat>,<lac>,<ci>       (GSM 07.07 solicited and some CREG=2 unsolicited) */
>  #define CREG4 "\\+(CREG|CGREG|CEREG):\\s*([0-9]),\\s*([0-9])\\s*,\\s*([^,]*)\\s*,\\s*([^,\\s]*)"
> @@ -462,7 +463,7 @@ mm_voice_clip_regex_get (void)
>  GPtrArray *
>  mm_3gpp_creg_regex_get (gboolean solicited)
>  {
> -    GPtrArray *array = g_ptr_array_sized_new (12);
> +    GPtrArray *array = g_ptr_array_sized_new (13);
>      GRegex *regex;
>  
>      /* #1 */
> @@ -545,6 +546,14 @@ mm_3gpp_creg_regex_get (gboolean solicited)
>      g_assert (regex);
>      g_ptr_array_add (array, regex);
>  
> +    /* #11 */
> +    if (solicited)
> +        regex = g_regex_new (CREG11 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
> +    else
> +        regex = g_regex_new ("\\r\\n" CREG11 "\\r\\n", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
> +    g_assert (regex);
> +    g_ptr_array_add (array, regex);
> +
>      /* CEREG #1 */
>      if (solicited)
>          regex = g_regex_new (CEREG1 "$", G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
> diff --git a/src/tests/test-modem-helpers.c b/src/tests/test-modem-helpers.c
> index 82479ac..d1833e5 100644
> --- a/src/tests/test-modem-helpers.c
> +++ b/src/tests/test-modem-helpers.c
> @@ -1135,7 +1135,7 @@ test_cereg2_novatel_lte_solicited (void *f, gpointer d)
>  {
>      RegTestData *data = (RegTestData *) d;
>      const char *reply = "\r\n+CEREG: 2,1, 1F00, 20 ,79D903 ,7\r\n";
> -    const CregResult result = { 1, 0x1F00, 0x79D903, MM_MODEM_ACCESS_TECHNOLOGY_LTE, 12, FALSE, TRUE };
> +    const CregResult result = { 1, 0x1F00, 0x79D903, MM_MODEM_ACCESS_TECHNOLOGY_LTE, 13, FALSE, TRUE };
>  
>      test_creg_match ("Novatel LTE E362 CEREG=2", TRUE, reply, data, &result);
>  }
> @@ -1145,11 +1145,31 @@ test_cereg2_novatel_lte_unsolicited (void *f, gpointer d)
>  {
>      RegTestData *data = (RegTestData *) d;
>      const char *reply = "\r\n+CEREG: 1, 1F00, 20 ,79D903 ,7\r\n";
> -    const CregResult result = { 1, 0x1F00, 0x79D903, MM_MODEM_ACCESS_TECHNOLOGY_LTE, 11, FALSE, TRUE };
> +    const CregResult result = { 1, 0x1F00, 0x79D903, MM_MODEM_ACCESS_TECHNOLOGY_LTE, 12, FALSE, TRUE };
>  
>      test_creg_match ("Novatel LTE E362 CEREG=2", FALSE, reply, data, &result);
>  }
>  
> +static void
> +test_cgreg2_thuraya_solicited (void *f, gpointer d)
> +{
> +    RegTestData *data = (RegTestData *) d;
> +    const char *reply = "+CGREG: 1, \"0426\", \"F0,0F\"";
> +    const CregResult result = { 1, 0x0426, 0x00F0, MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN, 11, TRUE, FALSE };
> +
> +    test_creg_match ("Thuraya solicited CREG=2", TRUE, reply, data, &result);
> +}
> +
> +static void
> +test_cgreg2_thuraya_unsolicited (void *f, gpointer d)
> +{
> +    RegTestData *data = (RegTestData *) d;
> +    const char *reply = "\r\n+CGREG: 1, \"0426\", \"F0,0F\"\r\n";
> +    const CregResult result = { 1, 0x0426, 0x00F0, MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN, 11, TRUE, FALSE };
> +
> +    test_creg_match ("Thuraya unsolicited CREG=2", FALSE, reply, data, &result);
> +}
> +
>  /*****************************************************************************/
>  /* Test CSCS responses */
>  
> @@ -2706,6 +2726,8 @@ int main (int argc, char **argv)
>      g_test_suite_add (suite, TESTCASE (test_cgreg2_md400_unsolicited, reg_data));
>      g_test_suite_add (suite, TESTCASE (test_cgreg2_x220_unsolicited, reg_data));
>      g_test_suite_add (suite, TESTCASE (test_cgreg2_unsolicited_with_rac, reg_data));
> +    g_test_suite_add (suite, TESTCASE (test_cgreg2_thuraya_solicited, reg_data));
> +    g_test_suite_add (suite, TESTCASE (test_cgreg2_thuraya_unsolicited, reg_data));
>  
>      g_test_suite_add (suite, TESTCASE (test_cereg1_solicited, reg_data));
>      g_test_suite_add (suite, TESTCASE (test_cereg1_unsolicited, reg_data));
> 


-- 
Aleksander
https://aleksander.es


More information about the ModemManager-devel mailing list