telit: Detect 4G BND format from BND test reply

Telit modems that require hexadecimal number when specifying 4G bands
also reply to #BND=? command with a 4th parameter <LTE_band_ext>
(e.g. LM940, LM960, LN920, FN980).
On the other hand, modems that require decimal number when specifying 4G
bands only return 3 parameters to the same command.

It is then possible replace the detection of ext_4g_bands via UDEV tags
with an inspection of BND=? reply.
This commit is contained in:
Carlo Lobrano
2021-10-15 11:39:33 +00:00
committed by Aleksander Morgado
parent 650cdc5a32
commit 3522a11578
5 changed files with 20 additions and 28 deletions
@@ -107,10 +107,6 @@ ATTRS{idVendor}=="1bc7", ATTRS{idProduct}=="1051", ENV{ID_MM_TELIT_BND_ALTERNATE
ATTRS{idVendor}=="1bc7", ATTRS{idProduct}=="1060", ENV{ID_MM_TELIT_BND_ALTERNATE}="1"
ATTRS{idVendor}=="1bc7", ATTRS{idProduct}=="1061", ENV{ID_MM_TELIT_BND_ALTERNATE}="1"
# LN920 use extended 4G bands and 4G bands configured as hex mask
ATTRS{idVendor}=="1bc7", ATTRS{idProduct}=="1060", ENV{ID_MM_TELIT_BND_EXT}="1"
ATTRS{idVendor}=="1bc7", ATTRS{idProduct}=="1061", ENV{ID_MM_TELIT_BND_EXT}="1"
# LM940/960 initial port delay
ATTRS{idVendor}=="1bc7", ATTRS{idProduct}=="1040", ENV{ID_MM_TELIT_PORT_DELAY}="1"
ATTRS{idVendor}=="1bc7", ATTRS{idProduct}=="1041", ENV{ID_MM_TELIT_PORT_DELAY}="1"
+12 -2
View File
@@ -658,6 +658,15 @@ typedef enum {
LOAD_BANDS_TYPE_CURRENT,
} LoadBandsType;
static gboolean
bnd_response_has_ext_4g_bands (const gchar *response)
{
g_auto(GStrv) tokens = NULL;
tokens = mm_split_string_groups (response);
return g_strv_length (tokens) == 4;
}
static GArray *
common_parse_bnd_response (const gchar *response,
gboolean modem_is_2g,
@@ -756,14 +765,15 @@ mm_telit_parse_bnd_test_response (const gchar *response,
gboolean modem_is_3g,
gboolean modem_is_4g,
gboolean modem_alternate_3g_bands,
gboolean modem_ext_4g_bands,
gboolean *modem_ext_4g_bands,
gpointer log_object,
GError **error)
{
*modem_ext_4g_bands = bnd_response_has_ext_4g_bands (response);
return common_parse_bnd_response (response,
modem_is_2g, modem_is_3g, modem_is_4g,
modem_alternate_3g_bands,
modem_ext_4g_bands,
*modem_ext_4g_bands,
LOAD_BANDS_TYPE_SUPPORTED,
log_object,
error);
+1 -1
View File
@@ -33,7 +33,7 @@ GArray *mm_telit_parse_bnd_test_response (const gchar *response,
gboolean modem_is_3g,
gboolean modem_is_4g,
gboolean modem_alternate_3g_bands,
gboolean modem_ext_4g_bands,
gboolean *modem_ext_4g_bands,
gpointer log_object,
GError **error);
gchar *mm_telit_build_bnd_request (GArray *bands_array,
+4 -20
View File
@@ -69,24 +69,6 @@ initialize_alternate_3g_band (MMSharedTelit *self,
}
}
static void
initialize_ext_4g_band (MMSharedTelit *self,
Private *priv)
{
MMPort *primary;
MMKernelDevice *port;
primary = MM_PORT (mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)));
if (primary) {
port = mm_port_peek_kernel_device (primary);
/* Lookup for the tag specifying that we're using the ext 4G band mapping */
priv->ext_4g_bands = mm_kernel_device_get_global_property_as_boolean (port, "ID_MM_TELIT_BND_EXT");
if (priv->ext_4g_bands)
mm_obj_dbg (self, "telit modem using extended 4G band setup");
}
}
static Private *
get_private (MMSharedTelit *self)
{
@@ -99,7 +81,7 @@ get_private (MMSharedTelit *self)
if (!priv) {
priv = g_slice_new0 (Private);
initialize_alternate_3g_band (self, priv);
initialize_ext_4g_band (self, priv);
/* ext_4g_bands field is initialized inside #BND=? response handler */
g_object_set_qdata_full (G_OBJECT (self), private_quark, priv, (GDestroyNotify)private_free);
}
@@ -219,7 +201,7 @@ mm_shared_telit_load_supported_bands_ready (MMBaseModem *self,
mm_iface_modem_is_3g (MM_IFACE_MODEM (self)),
mm_iface_modem_is_4g (MM_IFACE_MODEM (self)),
priv->alternate_3g_bands,
priv->ext_4g_bands,
&priv->ext_4g_bands,
self,
&error);
if (!bands)
@@ -227,6 +209,8 @@ mm_shared_telit_load_supported_bands_ready (MMBaseModem *self,
else {
/* Store supported bands to be able to build ANY when setting */
priv->supported_bands = g_array_ref (bands);
if (priv->ext_4g_bands)
mm_obj_dbg (self, "telit modem using extended 4G band setup");
g_task_return_pointer (task, bands, (GDestroyNotify)g_array_unref);
}
}
@@ -182,17 +182,19 @@ test_parse_supported_bands_response (void)
for (i = 0; i < G_N_ELEMENTS (supported_band_mapping_tests); i++) {
GError *error = NULL;
GArray *bands = NULL;
gboolean modem_ext_4g_bands;
bands = mm_telit_parse_bnd_test_response (supported_band_mapping_tests[i].response,
supported_band_mapping_tests[i].modem_is_2g,
supported_band_mapping_tests[i].modem_is_3g,
supported_band_mapping_tests[i].modem_is_4g,
supported_band_mapping_tests[i].modem_alternate_3g_bands,
supported_band_mapping_tests[i].modem_ext_4g_bands,
&modem_ext_4g_bands,
NULL,
&error);
g_assert_no_error (error);
g_assert (bands);
g_assert (supported_band_mapping_tests[i].modem_ext_4g_bands == modem_ext_4g_bands);
mm_test_helpers_compare_bands (bands,
supported_band_mapping_tests[i].mm_bands,