diff options
author | Carlo Lobrano <c.lobrano@gmail.com> | 2016-10-20 11:33:58 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2016-10-20 12:40:04 +0200 |
commit | 7078587f58b2fbf8356931cc2425d78c8bee0136 (patch) | |
tree | 5f4e2e6bd380a93a895a88991a8079ed13343883 | |
parent | 0bd3ca202bd1df9c9a2cd70f12bde157bd14bd81 (diff) |
telit: optimized supported and current band code
In place of two slightly different regexes for 2g/3g and 2g/3g/4g modems
we now use only one regex with conditional patterns for both supported
and current Bands detection.
Adding also minor fix in test code
-rw-r--r-- | plugins/telit/mm-modem-helpers-telit.c | 18 | ||||
-rw-r--r-- | plugins/telit/tests/test-mm-modem-helpers-telit.c | 2 |
2 files changed, 5 insertions, 15 deletions
diff --git a/plugins/telit/mm-modem-helpers-telit.c b/plugins/telit/mm-modem-helpers-telit.c index 665668f5..c8c1f4bd 100644 --- a/plugins/telit/mm-modem-helpers-telit.c +++ b/plugins/telit/mm-modem-helpers-telit.c @@ -161,11 +161,8 @@ mm_telit_parse_csim_response (const guint step, return retries; } - -#define SUPP_BAND_RESPONSE_REGEX "#BND:\\s*\\((?P<Bands2G>[0-9\\-,]*)\\)(,\\s*\\((?P<Bands3G>.*)\\))?" -#define SUPP_BAND_4G_MODEM_RESPONSE_REGEX "#BND:\\s*\\((?P<Bands2G>.*)\\),\\s*\\((?P<Bands3G>.*)\\),\\s*\\((?P<Bands4G>\\d+-\\d+)\\)" -#define CURR_BAND_RESPONSE_REGEX "#BND:\\s*(?P<Bands2G>\\d+)(,\\s*(?P<Bands3G>\\d+))?" -#define CURR_BAND_4G_MODEM_RESPONSE_REGEX "#BND:\\s*(?P<Bands2G>\\d+),\\s*(?P<Bands3G>\\d+),\\s*(?P<Bands4G>\\d+)" +#define SUPP_BAND_RESPONSE_REGEX "#BND:\\s*\\((?P<Bands2G>[0-9\\-,]*)\\)(,\\s*\\((?P<Bands3G>[0-9\\-,]*)\\))?(,\\s*\\((?P<Bands4G>[0-9\\-,]*)\\))?" +#define CURR_BAND_RESPONSE_REGEX "#BND:\\s*(?P<Bands2G>\\d+)(,\\s*(?P<Bands3G>\\d+))?(,\\s*(?P<Bands4G>\\d+))?" /*****************************************************************************/ /* #BND response parser @@ -235,18 +232,11 @@ mm_telit_parse_bnd_response (const gchar *response, switch (band_type) { case LOAD_SUPPORTED_BANDS: /* Parse #BND=? response */ - if (modem_is_4g) - r = g_regex_new (SUPP_BAND_4G_MODEM_RESPONSE_REGEX, G_REGEX_RAW, 0, NULL); - else - r = g_regex_new (SUPP_BAND_RESPONSE_REGEX, G_REGEX_RAW, 0, NULL); + r = g_regex_new (SUPP_BAND_RESPONSE_REGEX, G_REGEX_RAW, 0, NULL); break; case LOAD_CURRENT_BANDS: /* Parse #BND? response */ - if (modem_is_4g) - r = g_regex_new (CURR_BAND_4G_MODEM_RESPONSE_REGEX, G_REGEX_RAW, 0, NULL); - else - r = g_regex_new (CURR_BAND_RESPONSE_REGEX, G_REGEX_RAW, 0, NULL); - break; + r = g_regex_new (CURR_BAND_RESPONSE_REGEX, G_REGEX_RAW, 0, NULL); default: break; } diff --git a/plugins/telit/tests/test-mm-modem-helpers-telit.c b/plugins/telit/tests/test-mm-modem-helpers-telit.c index 03b1bc7a..2da60c11 100644 --- a/plugins/telit/tests/test-mm-modem-helpers-telit.c +++ b/plugins/telit/tests/test-mm-modem-helpers-telit.c @@ -117,7 +117,7 @@ typedef struct { static BNDFlagsTest band_flag_test[] = { {"0-3", 4, {0, 1, 2, 3} }, {"0,3", 2, {0, 3} }, - {"0,2-3,5-7,9", 2, {0, 2, 3, 5, 6, 7, 9} }, + {"0,2-3,5-7,9", 7, {0, 2, 3, 5, 6, 7, 9} }, { NULL, 0, {}}, }; |