telit: fix band setting function to properly support multi-tech modems
The assumption that if a modem supports a given access tech, the band settings for that specific tech should be always given is wrong for 4g, since the 4g bands can be disabled setting the value to 0 in multi-tech modems like ME310M1. For example, a 3g + 4g modem could have a setting in which all the 4g bands are unset and only 3g bands are there: this scenario is not supported by the current code, but it's legitimate. Remove this limitation and adapt the code to support bands setting for multi-tech modems. Signed-off-by: Daniele Palmas <dnlplm@gmail.com>
This commit is contained in:
committed by
Dan Williams
parent
069212e43e
commit
846048caa5
@@ -292,8 +292,6 @@ mm_telit_build_bnd_request (GArray *bands_array,
|
||||
/* Get 4G-specific telit band bitmask */
|
||||
flag4g = (mask4g != 0) ? ((gint64)mask4g) : -1;
|
||||
|
||||
/* If the modem supports a given access tech, we must always give band settings
|
||||
* for the specific tech */
|
||||
if (modem_is_2g && flag2g == -1) {
|
||||
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND,
|
||||
"None or invalid 2G bands combination in the provided list");
|
||||
@@ -304,12 +302,17 @@ mm_telit_build_bnd_request (GArray *bands_array,
|
||||
"None or invalid 3G bands combination in the provided list");
|
||||
return NULL;
|
||||
}
|
||||
if (modem_is_4g && mask4g == 0 && mask4gext == 0) {
|
||||
/* At least one technology must have valid bands */
|
||||
if (flag2g == -1 && flag3g == -1 && flag4g == -1) {
|
||||
g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND,
|
||||
"None or invalid 4G bands combination in the provided list");
|
||||
"No valid bands combination in the provided list");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* 4g bands could be disabled */
|
||||
if (modem_is_4g && flag4g == -1)
|
||||
flag4g = 0;
|
||||
|
||||
if (modem_is_2g && !modem_is_3g && !modem_is_4g)
|
||||
cmd = g_strdup_printf ("#BND=%d", flag2g);
|
||||
else if (!modem_is_2g && modem_is_3g && !modem_is_4g)
|
||||
|
||||
@@ -579,6 +579,78 @@ test_telit_get_4g_bnd_flag (void)
|
||||
g_array_unref (bands_array);
|
||||
}
|
||||
|
||||
static void test_telit_bnd_cmd_multitech(void)
|
||||
{
|
||||
GArray *bands_array;
|
||||
gchar *cmd;
|
||||
GError *error = NULL;
|
||||
MMTelitBNDParseConfig config = { TRUE, TRUE, TRUE, FALSE, FALSE, FALSE };
|
||||
MMModemBand egsm = MM_MODEM_BAND_EGSM;
|
||||
MMModemBand dcs = MM_MODEM_BAND_DCS;
|
||||
MMModemBand u2100 = MM_MODEM_BAND_UTRAN_1;
|
||||
MMModemBand eutran1 = MM_MODEM_BAND_EUTRAN_1;
|
||||
MMModemBand pcs = MM_MODEM_BAND_PCS;
|
||||
|
||||
/* No bands specified */
|
||||
bands_array = g_array_new(FALSE, FALSE, sizeof(MMModemBand));
|
||||
cmd = mm_telit_build_bnd_request(bands_array, &config, &error);
|
||||
g_assert_error(error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND);
|
||||
g_assert(cmd == NULL);
|
||||
g_clear_error(&error);
|
||||
g_array_unref(bands_array);
|
||||
|
||||
/* Only 2G bands for a 2G, 3G, 4G modem */
|
||||
bands_array = g_array_new(FALSE, FALSE, sizeof(MMModemBand));
|
||||
g_array_append_val(bands_array, egsm);
|
||||
g_array_append_val(bands_array, dcs);
|
||||
cmd = mm_telit_build_bnd_request(bands_array, &config, &error);
|
||||
g_assert_error(error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND);
|
||||
g_assert(cmd == NULL);
|
||||
g_clear_error(&error);
|
||||
g_array_unref(bands_array);
|
||||
|
||||
/* Only 3G bands for a 2G, 3G, 4G modem */
|
||||
bands_array = g_array_new(FALSE, FALSE, sizeof(MMModemBand));
|
||||
g_array_append_val(bands_array, u2100);
|
||||
cmd = mm_telit_build_bnd_request(bands_array, &config, &error);
|
||||
g_assert_error(error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND);
|
||||
g_assert(cmd == NULL);
|
||||
g_clear_error(&error);
|
||||
g_array_unref(bands_array);
|
||||
|
||||
/* Only 4G bands for a 2G, 3G, 4G modem */
|
||||
bands_array = g_array_new(FALSE, FALSE, sizeof(MMModemBand));
|
||||
g_array_append_val(bands_array, eutran1);
|
||||
cmd = mm_telit_build_bnd_request(bands_array, &config, &error);
|
||||
g_assert_error(error, MM_CORE_ERROR, MM_CORE_ERROR_NOT_FOUND);
|
||||
g_assert(cmd == NULL);
|
||||
g_clear_error(&error);
|
||||
g_array_unref(bands_array);
|
||||
|
||||
/* 2G+3G+4G bands for a 2G, 3G, 4G modem */
|
||||
bands_array = g_array_new(FALSE, FALSE, sizeof(MMModemBand));
|
||||
g_array_append_val(bands_array, egsm);
|
||||
g_array_append_val(bands_array, dcs);
|
||||
g_array_append_val(bands_array, u2100);
|
||||
g_array_append_val(bands_array, eutran1);
|
||||
cmd = mm_telit_build_bnd_request(bands_array, &config, &error);
|
||||
g_assert_no_error(error);
|
||||
g_assert_cmpstr(cmd, ==, "#BND=0,0,1");
|
||||
g_free(cmd);
|
||||
g_array_unref(bands_array);
|
||||
|
||||
/* 2G+3G bands for a 2G, 3G, 4G modem */
|
||||
bands_array = g_array_new(FALSE, FALSE, sizeof(MMModemBand));
|
||||
g_array_append_val(bands_array, egsm);
|
||||
g_array_append_val(bands_array, pcs);
|
||||
g_array_append_val(bands_array, u2100);
|
||||
cmd = mm_telit_build_bnd_request(bands_array, &config, &error);
|
||||
g_assert_no_error(error);
|
||||
g_assert_cmpstr(cmd, ==, "#BND=1,0,0");
|
||||
g_free(cmd);
|
||||
g_array_unref(bands_array);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
@@ -678,8 +750,7 @@ test_telit_compare_software_revision_string (void)
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int main (int argc, char **argv){
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
@@ -689,6 +760,7 @@ int main (int argc, char **argv)
|
||||
g_test_add_func ("/MM/telit/bands/current/set_bands/2g", test_telit_get_2g_bnd_flag);
|
||||
g_test_add_func ("/MM/telit/bands/current/set_bands/3g", test_telit_get_3g_bnd_flag);
|
||||
g_test_add_func ("/MM/telit/bands/current/set_bands/4g", test_telit_get_4g_bnd_flag);
|
||||
g_test_add_func ("/MM/telit/bands/current/set_bands/multitech", test_telit_bnd_cmd_multitech);
|
||||
g_test_add_func ("/MM/telit/qss/query", test_telit_parse_qss_query);
|
||||
g_test_add_func ("/MM/telit/swpkv/parse_response", test_telit_parse_swpkgv_response);
|
||||
g_test_add_func ("/MM/telit/revision/compare", test_telit_compare_software_revision_string);
|
||||
|
||||
Reference in New Issue
Block a user