plugins,telit: LM940 has LTE band ext after given version

Currently, LM940 is expected to have not LTE band extended, however they
have been introduced since version 24.01.516.

This change adds a software revision compare function for Telit modem
limited to LM9x0 modems (LM940 and LM960 share the same revision format
string) to verify if the current LM940 software revision is equal or
newer than 24.01.516 and enable/disable LTE band extended accordingly.
This commit is contained in:
Carlo Lobrano
2022-09-16 15:13:30 +02:00
parent 072c8eba9e
commit 651ddb95d1
4 changed files with 93 additions and 1 deletions

View File

@@ -919,3 +919,49 @@ mm_telit_model_from_revision (const gchar *revision)
return MM_TELIT_MODEL_DEFAULT; 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;
}

View File

@@ -38,6 +38,14 @@ typedef struct {
gboolean modem_ext_4g_bands; gboolean modem_ext_4g_bands;
} MMTelitBNDParseConfig; } 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 */ /* #BND response parsers and request builder */
GArray *mm_telit_parse_bnd_query_response (const gchar *response, GArray *mm_telit_parse_bnd_query_response (const gchar *response,
MMTelitBNDParseConfig *config, MMTelitBNDParseConfig *config,
@@ -76,4 +84,7 @@ gchar *mm_telit_parse_swpkgv_response (const gchar *response);
MMTelitModel mm_telit_model_from_revision (const gchar *revision); 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 */ #endif /* MM_MODEM_HELPERS_TELIT_H */

View File

@@ -34,6 +34,8 @@
/*****************************************************************************/ /*****************************************************************************/
/* Private data context */ /* Private data context */
#define TELIT_LM940_EXT_LTE_BND_SW_REVISION "24.01.516"
#define PRIVATE_TAG "shared-telit-private-tag" #define PRIVATE_TAG "shared-telit-private-tag"
static GQuark private_quark; static GQuark private_quark;
@@ -73,7 +75,7 @@ has_alternate_3g_bands (const gchar *revision)
static gboolean static gboolean
is_bnd_4g_format_hex (const gchar *revision) is_bnd_4g_format_hex (const gchar *revision)
{ {
MMTelitModel model; MMTelitModel model;
model = mm_telit_model_from_revision (revision); model = mm_telit_model_from_revision (revision);
@@ -90,6 +92,9 @@ has_extended_4g_bands (const gchar *revision)
MMTelitModel model; MMTelitModel model;
model = mm_telit_model_from_revision (revision); 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 || return (model == MM_TELIT_MODEL_FN980 ||
model == MM_TELIT_MODEL_FN990 || model == MM_TELIT_MODEL_FN990 ||
model == MM_TELIT_MODEL_LM960 || model == MM_TELIT_MODEL_LM960 ||

View File

@@ -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) 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/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/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/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 (); return g_test_run ();
} }