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
This commit is contained in:

committed by
Aleksander Morgado

parent
0bd3ca202b
commit
7078587f58
@@ -161,11 +161,8 @@ mm_telit_parse_csim_response (const guint step,
|
|||||||
|
|
||||||
return retries;
|
return retries;
|
||||||
}
|
}
|
||||||
|
#define SUPP_BAND_RESPONSE_REGEX "#BND:\\s*\\((?P<Bands2G>[0-9\\-,]*)\\)(,\\s*\\((?P<Bands3G>[0-9\\-,]*)\\))?(,\\s*\\((?P<Bands4G>[0-9\\-,]*)\\))?"
|
||||||
#define SUPP_BAND_RESPONSE_REGEX "#BND:\\s*\\((?P<Bands2G>[0-9\\-,]*)\\)(,\\s*\\((?P<Bands3G>.*)\\))?"
|
#define CURR_BAND_RESPONSE_REGEX "#BND:\\s*(?P<Bands2G>\\d+)(,\\s*(?P<Bands3G>\\d+))?(,\\s*(?P<Bands4G>\\d+))?"
|
||||||
#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+)"
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* #BND response parser
|
/* #BND response parser
|
||||||
@@ -235,18 +232,11 @@ mm_telit_parse_bnd_response (const gchar *response,
|
|||||||
switch (band_type) {
|
switch (band_type) {
|
||||||
case LOAD_SUPPORTED_BANDS:
|
case LOAD_SUPPORTED_BANDS:
|
||||||
/* Parse #BND=? response */
|
/* 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;
|
break;
|
||||||
case LOAD_CURRENT_BANDS:
|
case LOAD_CURRENT_BANDS:
|
||||||
/* Parse #BND? response */
|
/* 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);
|
r = g_regex_new (CURR_BAND_RESPONSE_REGEX, G_REGEX_RAW, 0, NULL);
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -117,7 +117,7 @@ typedef struct {
|
|||||||
static BNDFlagsTest band_flag_test[] = {
|
static BNDFlagsTest band_flag_test[] = {
|
||||||
{"0-3", 4, {0, 1, 2, 3} },
|
{"0-3", 4, {0, 1, 2, 3} },
|
||||||
{"0,3", 2, {0, 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, {}},
|
{ NULL, 0, {}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user