diff options
-rw-r--r-- | plugins/telit/mm-modem-helpers-telit.c | 46 | ||||
-rw-r--r-- | plugins/telit/mm-modem-helpers-telit.h | 11 | ||||
-rw-r--r-- | plugins/telit/mm-shared-telit.c | 7 | ||||
-rw-r--r-- | plugins/telit/tests/test-mm-modem-helpers-telit.c | 30 |
4 files changed, 93 insertions, 1 deletions
diff --git a/plugins/telit/mm-modem-helpers-telit.c b/plugins/telit/mm-modem-helpers-telit.c index 5c662edb..91f4b854 100644 --- a/plugins/telit/mm-modem-helpers-telit.c +++ b/plugins/telit/mm-modem-helpers-telit.c @@ -919,3 +919,49 @@ mm_telit_model_from_revision (const gchar *revision) return MM_TELIT_MODEL_DEFAULT; } + +static MMTelitSwRevCmp lm9x0_software_revision_cmp (const gchar *revision_a, + const gchar *revision_b) +{ + /* LM940 and LM960 share the same software revision format + * WW.XY.ABC[-ZZZZ], where WW is the chipset code and C the major version. + * If WW is the same, the other values X, Y, A and B are also the same, so + * we can limit the comparison to C only. ZZZZ is the minor version (it + * includes if version is beta, test, or alpha), but at this stage we are + * not interested in compare it. */ + guint chipset_a, chipset_b; + guint major_a, major_b; + guint x, y, a, b; + + g_return_val_if_fail ( + sscanf (revision_a, "%2u.%1u%1u.%1u%1u%1u", &chipset_a, &x, &y, &a, &b, &major_a) == 6, + MM_TELIT_SW_REV_CMP_INVALID); + g_return_val_if_fail ( + sscanf (revision_b, "%2u.%1u%1u.%1u%1u%1u", &chipset_b, &x, &y, &a, &b, &major_b) == 6, + MM_TELIT_SW_REV_CMP_INVALID); + + if (chipset_a != chipset_b) + return MM_TELIT_SW_REV_CMP_INVALID; + if (major_a > major_b) + return MM_TELIT_SW_REV_CMP_NEWER; + if (major_a < major_b) + return MM_TELIT_SW_REV_CMP_OLDER; + return MM_TELIT_SW_REV_CMP_EQUAL; +} + +MMTelitSwRevCmp mm_telit_software_revision_cmp (const gchar *revision_a, + const gchar *revision_b) +{ + MMTelitModel model_a; + MMTelitModel model_b; + + model_a = mm_telit_model_from_revision (revision_a); + model_b = mm_telit_model_from_revision (revision_b); + + if ((model_a == MM_TELIT_MODEL_LM940 || model_a == MM_TELIT_MODEL_LM960) && + (model_b == MM_TELIT_MODEL_LM940 || model_b == MM_TELIT_MODEL_LM960)) { + return lm9x0_software_revision_cmp (revision_a, revision_b); + } + + return MM_TELIT_SW_REV_CMP_UNSUPPORTED; +} diff --git a/plugins/telit/mm-modem-helpers-telit.h b/plugins/telit/mm-modem-helpers-telit.h index a1f67fe8..38449769 100644 --- a/plugins/telit/mm-modem-helpers-telit.h +++ b/plugins/telit/mm-modem-helpers-telit.h @@ -38,6 +38,14 @@ typedef struct { gboolean modem_ext_4g_bands; } MMTelitBNDParseConfig; +typedef enum { + MM_TELIT_SW_REV_CMP_INVALID, + MM_TELIT_SW_REV_CMP_UNSUPPORTED, + MM_TELIT_SW_REV_CMP_OLDER, + MM_TELIT_SW_REV_CMP_EQUAL, + MM_TELIT_SW_REV_CMP_NEWER, +} MMTelitSwRevCmp; + /* #BND response parsers and request builder */ GArray *mm_telit_parse_bnd_query_response (const gchar *response, MMTelitBNDParseConfig *config, @@ -76,4 +84,7 @@ gchar *mm_telit_parse_swpkgv_response (const gchar *response); MMTelitModel mm_telit_model_from_revision (const gchar *revision); +MMTelitSwRevCmp mm_telit_software_revision_cmp (const gchar *reference, + const gchar *revision); + #endif /* MM_MODEM_HELPERS_TELIT_H */ diff --git a/plugins/telit/mm-shared-telit.c b/plugins/telit/mm-shared-telit.c index af23e4cb..09c122bb 100644 --- a/plugins/telit/mm-shared-telit.c +++ b/plugins/telit/mm-shared-telit.c @@ -34,6 +34,8 @@ /*****************************************************************************/ /* Private data context */ +#define TELIT_LM940_EXT_LTE_BND_SW_REVISION "24.01.516" + #define PRIVATE_TAG "shared-telit-private-tag" static GQuark private_quark; @@ -73,7 +75,7 @@ has_alternate_3g_bands (const gchar *revision) static gboolean is_bnd_4g_format_hex (const gchar *revision) { - MMTelitModel model; + MMTelitModel model; model = mm_telit_model_from_revision (revision); @@ -90,6 +92,9 @@ has_extended_4g_bands (const gchar *revision) MMTelitModel model; model = mm_telit_model_from_revision (revision); + if (model == MM_TELIT_MODEL_LM940) + return mm_telit_software_revision_cmp (revision, TELIT_LM940_EXT_LTE_BND_SW_REVISION) >= MM_TELIT_SW_REV_CMP_EQUAL; + return (model == MM_TELIT_MODEL_FN980 || model == MM_TELIT_MODEL_FN990 || model == MM_TELIT_MODEL_LM960 || diff --git a/plugins/telit/tests/test-mm-modem-helpers-telit.c b/plugins/telit/tests/test-mm-modem-helpers-telit.c index 11b5e918..e14ba6ba 100644 --- a/plugins/telit/tests/test-mm-modem-helpers-telit.c +++ b/plugins/telit/tests/test-mm-modem-helpers-telit.c @@ -646,6 +646,35 @@ test_telit_parse_swpkgv_response (void) } } +static void +test_telit_compare_software_revision_string (void) +{ + struct { + const char *revision_a; + const char *revision_b; + MMTelitSwRevCmp expected; + } tt [] = { + {"24.01.514", "24.01.514", MM_TELIT_SW_REV_CMP_EQUAL}, + {"24.01.514", "24.01.513", MM_TELIT_SW_REV_CMP_NEWER}, + {"24.01.513", "24.01.514", MM_TELIT_SW_REV_CMP_OLDER}, + {"32.00.013", "24.01.514", MM_TELIT_SW_REV_CMP_INVALID}, + {"32.00.014", "32.00.014", MM_TELIT_SW_REV_CMP_EQUAL}, + {"32.00.014", "32.00.013", MM_TELIT_SW_REV_CMP_NEWER}, + {"32.00.013", "32.00.014", MM_TELIT_SW_REV_CMP_OLDER}, + {"38.00.000", "38.00.000", MM_TELIT_SW_REV_CMP_UNSUPPORTED}, + /* LM9x0 Minor version (e.g. beta, test, alpha) value is currently + * ignored because not required by any implemented feature. */ + {"24.01.516-B123", "24.01.516-B134", MM_TELIT_SW_REV_CMP_EQUAL}, + }; + guint i; + + for (i = 0; i < G_N_ELEMENTS (tt); i++) { + g_assert_cmpint (tt[i].expected, + ==, + mm_telit_software_revision_cmp (tt[i].revision_a, tt[i].revision_b)); + } +} + /******************************************************************************/ int main (int argc, char **argv) @@ -661,5 +690,6 @@ int main (int argc, char **argv) g_test_add_func ("/MM/telit/bands/current/set_bands/4g", test_telit_get_4g_bnd_flag); 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); return g_test_run (); } |