<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Oh, really sorry for that, I didn't realize it. Fixing it and re-submitting</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Carlo</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 10 March 2016 at 14:19, Aleksander Morgado <span dir="ltr"><<a href="mailto:aleksander@aleksander.es" target="_blank">aleksander@aleksander.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Mar 10, 2016 at 12:41 PM, Carlo Lobrano <<a href="mailto:c.lobrano@gmail.com">c.lobrano@gmail.com</a>> wrote:<br>
> ---<br>
><br>
> Hello,<br>
><br>
> I fixed the usage of mm_base_at_command_finish and the other changes<br>
> required in the previous code review. Hope everything is fine now.<br>
><br>
<br>
</span>Looks like this version of the patch is introducing quite some<br>
unrelated reindentations?<br>
<br>
Also, ExecStart modified in <a href="http://ModemManager.service.in" rel="noreferrer" target="_blank">ModemManager.service.in</a>? :)<br>
<div><div class="h5"><br>
<br>
> Thanks,<br>
> Carlo<br>
><br>
> ---<br>
> data/<a href="http://ModemManager.service.in" rel="noreferrer" target="_blank">ModemManager.service.in</a> | 2 +-<br>
> plugins/telit/mm-broadband-modem-telit.c | 294 +++++++++++++++-------<br>
> plugins/telit/mm-modem-helpers-telit.c | 85 +++++++<br>
> plugins/telit/mm-modem-helpers-telit.h | 1 +<br>
> plugins/telit/tests/test-mm-modem-helpers-telit.c | 191 ++++++++++++++<br>
> 5 files changed, 484 insertions(+), 89 deletions(-)<br>
><br>
> diff --git a/data/<a href="http://ModemManager.service.in" rel="noreferrer" target="_blank">ModemManager.service.in</a> b/data/<a href="http://ModemManager.service.in" rel="noreferrer" target="_blank">ModemManager.service.in</a><br>
> index 9fe3a3b..81923e8 100644<br>
> --- a/data/<a href="http://ModemManager.service.in" rel="noreferrer" target="_blank">ModemManager.service.in</a><br>
> +++ b/data/<a href="http://ModemManager.service.in" rel="noreferrer" target="_blank">ModemManager.service.in</a><br>
> @@ -5,7 +5,7 @@ After=syslog.target<br>
> [Service]<br>
> Type=dbus<br>
> BusName=org.freedesktop.ModemManager1<br>
> -ExecStart=@sbindir@/ModemManager<br>
> +ExecStart=@sbindir@/ModemManager --debug --log-level=DEBUG --log-file=/tmp/modemmanager.log<br>
> StandardError=null<br>
> Restart=on-abort<br>
><br>
> diff --git a/plugins/telit/mm-broadband-modem-telit.c b/plugins/telit/mm-broadband-modem-telit.c<br>
> index 0127314..47a4d7b 100644<br>
> --- a/plugins/telit/mm-broadband-modem-telit.c<br>
> +++ b/plugins/telit/mm-broadband-modem-telit.c<br>
> @@ -30,6 +30,7 @@<br>
> #include "mm-base-modem-at.h"<br>
> #include "mm-iface-modem.h"<br>
> #include "mm-iface-modem-3gpp.h"<br>
> +#include "mm-common-helpers.h"<br>
> #include "mm-broadband-modem-telit.h"<br>
> #include "mm-modem-helpers-telit.h"<br>
><br>
> @@ -43,6 +44,121 @@ G_DEFINE_TYPE_EXTENDED (MMBroadbandModemTelit, mm_broadband_modem_telit, MM_TYPE<br>
> G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init));<br>
><br>
> /*****************************************************************************/<br>
> +/* Set current bands (Modem interface) */<br>
> +<br>
> +static gboolean<br>
> +modem_set_current_bands_finish (MMIfaceModem *self,<br>
> + GAsyncResult *res,<br>
> + GError **error)<br>
> +{<br>
> + return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);<br>
> +}<br>
> +<br>
> +static void<br>
> +modem_set_current_bands_ready (MMIfaceModem *self,<br>
> + GAsyncResult *res,<br>
> + GSimpleAsyncResult *simple)<br>
> +{<br>
> + GError *error = NULL;<br>
> +<br>
> + mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);<br>
> + if (error) {<br>
> + g_simple_async_result_take_error (simple, error);<br>
> + } else {<br>
> + g_simple_async_result_set_op_res_gboolean (simple, TRUE);<br>
> + }<br>
> +<br>
> + g_simple_async_result_complete (simple);<br>
> + g_object_unref (simple);<br>
> +}<br>
> +<br>
> +static void<br>
> +modem_set_current_bands (MMIfaceModem *self,<br>
> + GArray *bands_array,<br>
> + GAsyncReadyCallback callback,<br>
> + gpointer user_data)<br>
> +{<br>
> + gchar *cmd;<br>
> + gint flag2g;<br>
> + gint flag3g;<br>
> + gint flag4g;<br>
> + gboolean is_2g;<br>
> + gboolean is_3g;<br>
> + gboolean is_4g;<br>
> + GSimpleAsyncResult *res;<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, &flag2g, &flag3g, &flag4g);<br>
> +<br>
> + is_2g = mm_iface_modem_is_2g (self);<br>
> + is_3g = mm_iface_modem_is_3g (self);<br>
> + is_4g = mm_iface_modem_is_4g (self);<br>
> +<br>
> + if (is_2g && flag2g == -1) {<br>
> + g_simple_async_report_error_in_idle (G_OBJECT (self),<br>
> + callback,<br>
> + user_data,<br>
> + MM_CORE_ERROR,<br>
> + MM_CORE_ERROR_NOT_FOUND,<br>
> + "None or invalid 2G bands combination in the provided list");<br>
> + return;<br>
> + }<br>
> +<br>
> + if (is_3g && flag3g == -1) {<br>
> + g_simple_async_report_error_in_idle (G_OBJECT (self),<br>
> + callback,<br>
> + user_data,<br>
> + MM_CORE_ERROR,<br>
> + MM_CORE_ERROR_NOT_FOUND,<br>
> + "None or invalid 3G bands combination in the provided list");<br>
> + return;<br>
> + }<br>
> +<br>
> + if (is_4g && flag4g == -1) {<br>
> + g_simple_async_report_error_in_idle (G_OBJECT (self),<br>
> + callback,<br>
> + user_data,<br>
> + MM_CORE_ERROR,<br>
> + MM_CORE_ERROR_NOT_FOUND,<br>
> + "None or invalid 4G bands combination in the provided list");<br>
> + return;<br>
> + }<br>
> +<br>
> + cmd = NULL;<br>
> + if (is_2g && !is_3g && !is_4g)<br>
> + cmd = g_strdup_printf ("AT#BND=%d", flag2g);<br>
> + else if (is_2g && is_3g && !is_4g)<br>
> + cmd = g_strdup_printf ("AT#BND=%d,%d", flag2g, flag3g);<br>
> + else if (is_2g && is_3g && is_4g)<br>
> + cmd = g_strdup_printf ("AT#BND=%d,%d,%d", flag2g, flag3g, flag4g);<br>
> + else if (!is_2g && !is_3g && is_4g)<br>
> + cmd = g_strdup_printf ("AT#BND=0,0,%d", flag4g);<br>
> + else if (!is_2g && is_3g && is_4g)<br>
> + cmd = g_strdup_printf ("AT#BND=0,%d,%d", flag3g, flag4g);<br>
> + else if (is_2g && !is_3g && is_4g)<br>
> + cmd = g_strdup_printf ("AT#BND=%d,0,%d", flag2g, flag4g);<br>
> + else {<br>
> + g_simple_async_report_error_in_idle (G_OBJECT (self),<br>
> + callback,<br>
> + user_data,<br>
> + MM_CORE_ERROR,<br>
> + MM_CORE_ERROR_FAILED,<br>
> + "Unexpectd error: could not compose AT#BND command");<br>
> + return;<br>
> + }<br>
> + res = g_simple_async_result_new (G_OBJECT (self),<br>
> + callback,<br>
> + user_data,<br>
> + modem_set_current_bands);<br>
> + mm_base_modem_at_command (MM_BASE_MODEM (self),<br>
> + cmd,<br>
> + 20,<br>
> + FALSE,<br>
> + (GAsyncReadyCallback)modem_set_current_bands_ready,<br>
> + res);<br>
> + g_free (cmd);<br>
> +}<br>
> +<br>
> +/*****************************************************************************/<br>
> /* Load current bands (Modem interface) */<br>
><br>
> typedef struct {<br>
> @@ -72,7 +188,7 @@ modem_load_bands_finish (MMIfaceModem *self,<br>
> return NULL;<br>
><br>
> return (GArray *) g_array_ref (g_simple_async_result_get_op_res_gpointer (<br>
> - G_SIMPLE_ASYNC_RESULT (res)));<br>
> + G_SIMPLE_ASYNC_RESULT (res)));<br>
> }<br>
><br>
> static void<br>
> @@ -209,7 +325,7 @@ modem_load_unlock_retries_finish (MMIfaceModem *self,<br>
> return NULL;<br>
><br>
> return (MMUnlockRetries*) g_object_ref (g_simple_async_result_get_op_res_gpointer (<br>
> - G_SIMPLE_ASYNC_RESULT (res)));<br>
> + G_SIMPLE_ASYNC_RESULT (res)));<br>
> }<br>
><br>
> static void<br>
> @@ -436,20 +552,20 @@ response_processor_psnt_ignore_at_errors (MMBaseModem *self,<br>
> mode = strchr (psnt, ',');<br>
> if (mode) {<br>
> switch (atoi (++mode)) {<br>
> - case 0:<br>
> - *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_GPRS);<br>
> - return TRUE;<br>
> - case 1:<br>
> - *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_EDGE);<br>
> - return TRUE;<br>
> - case 2:<br>
> - *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_UMTS);<br>
> - return TRUE;<br>
> - case 3:<br>
> - *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_HSDPA);<br>
> - return TRUE;<br>
> - default:<br>
> - break;<br>
> + case 0:<br>
> + *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_GPRS);<br>
> + return TRUE;<br>
> + case 1:<br>
> + *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_EDGE);<br>
> + return TRUE;<br>
> + case 2:<br>
> + *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_UMTS);<br>
> + return TRUE;<br>
> + case 3:<br>
> + *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_HSDPA);<br>
> + return TRUE;<br>
> + default:<br>
> + break;<br>
> }<br>
> }<br>
><br>
> @@ -484,17 +600,17 @@ response_processor_service_ignore_at_errors (MMBaseModem *self,<br>
> mode = strchr (service, ',');<br>
> if (mode) {<br>
> switch (atoi (++mode)) {<br>
> - case 1:<br>
> - *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_1XRTT);<br>
> - return TRUE;<br>
> - case 2:<br>
> - *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_EVDO0);<br>
> - return TRUE;<br>
> - case 3:<br>
> - *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_EVDOA);<br>
> - return TRUE;<br>
> - default:<br>
> - break;<br>
> + case 1:<br>
> + *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_1XRTT);<br>
> + return TRUE;<br>
> + case 2:<br>
> + *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_EVDO0);<br>
> + return TRUE;<br>
> + case 3:<br>
> + *result = g_variant_new_uint32 (MM_MODEM_ACCESS_TECHNOLOGY_EVDOA);<br>
> + return TRUE;<br>
> + default:<br>
> + break;<br>
> }<br>
> }<br>
><br>
> @@ -519,12 +635,12 @@ load_access_technologies (MMIfaceModem *self,<br>
> {<br>
> mm_dbg ("loading access technology (Telit)...");<br>
> mm_base_modem_at_sequence (<br>
> - MM_BASE_MODEM (self),<br>
> - access_tech_commands,<br>
> - NULL, /* response_processor_context */<br>
> - NULL, /* response_processor_context_free */<br>
> - callback,<br>
> - user_data);<br>
> + MM_BASE_MODEM (self),<br>
> + access_tech_commands,<br>
> + NULL, /* response_processor_context */<br>
> + NULL, /* response_processor_context_free */<br>
> + callback,<br>
> + user_data);<br>
> }<br>
><br>
> /*****************************************************************************/<br>
> @@ -549,11 +665,11 @@ setup_flow_control (MMIfaceModem *self,<br>
> guint flow_control = 1; /* Default flow control: XON/XOFF */<br>
><br>
> switch (mm_base_modem_get_product_id (MM_BASE_MODEM (self)) & 0xFFFF) {<br>
> - case 0x0021:<br>
> - flow_control = 2; /* Telit IMC modems support only RTS/CTS mode */<br>
> - break;<br>
> - default:<br>
> - break;<br>
> + case 0x0021:<br>
> + flow_control = 2; /* Telit IMC modems support only RTS/CTS mode */<br>
> + break;<br>
> + default:<br>
> + break;<br>
> }<br>
><br>
> cmd = g_strdup_printf ("+IFC=%u,%u", flow_control, flow_control);<br>
> @@ -604,32 +720,32 @@ load_current_modes_finish (MMIfaceModem *self,<br>
><br>
> *preferred = MM_MODEM_MODE_NONE;<br>
> switch (a) {<br>
> - case 12:<br>
> - *allowed = MM_MODEM_MODE_2G;<br>
> - return TRUE;<br>
> - case 22:<br>
> - *allowed = MM_MODEM_MODE_3G;<br>
> - return TRUE;<br>
> - case 25:<br>
> - if (mm_iface_modem_is_3gpp_lte (self))<br>
> - *allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G | MM_MODEM_MODE_4G);<br>
> - else<br>
> + case 12:<br>
> + *allowed = MM_MODEM_MODE_2G;<br>
> + return TRUE;<br>
> + case 22:<br>
> + *allowed = MM_MODEM_MODE_3G;<br>
> + return TRUE;<br>
> + case 25:<br>
> + if (mm_iface_modem_is_3gpp_lte (self))<br>
> + *allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G | MM_MODEM_MODE_4G);<br>
> + else<br>
> + *allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);<br>
> + return TRUE;<br>
> + case 28:<br>
> + *allowed = MM_MODEM_MODE_4G;<br>
> + return TRUE;<br>
> + case 29:<br>
> *allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);<br>
> - return TRUE;<br>
> - case 28:<br>
> - *allowed = MM_MODEM_MODE_4G;<br>
> - return TRUE;<br>
> - case 29:<br>
> - *allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);<br>
> - return TRUE;<br>
> - case 30:<br>
> - *allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_4G);<br>
> - return TRUE;<br>
> - case 31:<br>
> - *allowed = (MM_MODEM_MODE_3G | MM_MODEM_MODE_4G);<br>
> - return TRUE;<br>
> - default:<br>
> - break;<br>
> + return TRUE;<br>
> + case 30:<br>
> + *allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_4G);<br>
> + return TRUE;<br>
> + case 31:<br>
> + *allowed = (MM_MODEM_MODE_3G | MM_MODEM_MODE_4G);<br>
> + return TRUE;<br>
> + default:<br>
> + break;<br>
> }<br>
><br>
> g_set_error (error,<br>
> @@ -740,12 +856,12 @@ set_current_modes (MMIfaceModem *self,<br>
><br>
> command = g_strdup_printf ("AT+WS46=%d", ws46_mode);<br>
> mm_base_modem_at_command (<br>
> - MM_BASE_MODEM (self),<br>
> - command,<br>
> - 10,<br>
> - FALSE,<br>
> - (GAsyncReadyCallback)ws46_set_ready,<br>
> - result);<br>
> + MM_BASE_MODEM (self),<br>
> + command,<br>
> + 10,<br>
> + FALSE,<br>
> + (GAsyncReadyCallback)ws46_set_ready,<br>
> + result);<br>
> g_free (command);<br>
> }<br>
><br>
> @@ -839,12 +955,12 @@ load_supported_modes (MMIfaceModem *self,<br>
> {<br>
> /* Run parent's loading */<br>
> iface_modem_parent->load_supported_modes (<br>
> - MM_IFACE_MODEM (self),<br>
> - (GAsyncReadyCallback)parent_load_supported_modes_ready,<br>
> - g_simple_async_result_new (G_OBJECT (self),<br>
> - callback,<br>
> - user_data,<br>
> - load_supported_modes));<br>
> + MM_IFACE_MODEM (self),<br>
> + (GAsyncReadyCallback)parent_load_supported_modes_ready,<br>
> + g_simple_async_result_new (G_OBJECT (self),<br>
> + callback,<br>
> + user_data,<br>
> + load_supported_modes));<br>
> }<br>
><br>
> /*****************************************************************************/<br>
> @@ -855,7 +971,7 @@ modem_3gpp_enable_unsolicited_events_finish (MMIfaceModem3gpp *self,<br>
> GAsyncResult *res,<br>
> GError **error)<br>
> {<br>
> - /* Ignore errors */<br>
> + /* Ignore errors */<br>
> mm_base_modem_at_sequence_full_finish (MM_BASE_MODEM (self),<br>
> res,<br>
> NULL,<br>
> @@ -877,24 +993,24 @@ modem_3gpp_enable_unsolicited_events (MMIfaceModem3gpp *self,<br>
> gpointer user_data)<br>
> {<br>
> mm_base_modem_at_sequence_full (<br>
> - MM_BASE_MODEM (self),<br>
> - mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self)),<br>
> - unsolicited_enable_sequence,<br>
> - NULL, /* response_processor_context */<br>
> - NULL, /* response_processor_context_free */<br>
> - NULL, /* cancellable */<br>
> - callback,<br>
> - user_data);<br>
> + MM_BASE_MODEM (self),<br>
> + mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self)),<br>
> + unsolicited_enable_sequence,<br>
> + NULL, /* response_processor_context */<br>
> + NULL, /* response_processor_context_free */<br>
> + NULL, /* cancellable */<br>
> + callback,<br>
> + user_data);<br>
> }<br>
><br>
> /*****************************************************************************/<br>
><br>
> MMBroadbandModemTelit *<br>
> mm_broadband_modem_telit_new (const gchar *device,<br>
> - const gchar **drivers,<br>
> - const gchar *plugin,<br>
> - guint16 vendor_id,<br>
> - guint16 product_id)<br>
> + const gchar **drivers,<br>
> + const gchar *plugin,<br>
> + guint16 vendor_id,<br>
> + guint16 product_id)<br>
> {<br>
> return g_object_new (MM_TYPE_BROADBAND_MODEM_TELIT,<br>
> MM_BASE_MODEM_DEVICE, device,<br>
> @@ -915,6 +1031,8 @@ iface_modem_init (MMIfaceModem *iface)<br>
> {<br>
> iface_modem_parent = g_type_interface_peek_parent (iface);<br>
><br>
> + iface->set_current_bands = modem_set_current_bands;<br>
> + iface->set_current_bands_finish = modem_set_current_bands_finish;<br>
> iface->load_current_bands = modem_load_current_bands;<br>
> iface->load_current_bands_finish = modem_load_bands_finish;<br>
> iface->load_supported_bands = modem_load_supported_bands;<br>
> diff --git a/plugins/telit/mm-modem-helpers-telit.c b/plugins/telit/mm-modem-helpers-telit.c<br>
> index ae7f8e7..80065fb 100644<br>
> --- a/plugins/telit/mm-modem-helpers-telit.c<br>
> +++ b/plugins/telit/mm-modem-helpers-telit.c<br>
> @@ -26,6 +26,91 @@<br>
> #include "mm-modem-helpers.h"<br>
> #include "mm-modem-helpers-telit.h"<br>
><br>
> +<br>
> +/*****************************************************************************/<br>
> +/* Set current bands helpers */<br>
> +<br>
> +void<br>
> +mm_telit_get_band_flag (GArray *bands_array,<br>
> + gint *flag2g,<br>
> + gint *flag3g,<br>
> + gint *flag4g)<br>
> +{<br>
> + guint mask_2g = 0;<br>
> + guint mask3g = 0;<br>
> + guint mask4g = 0;<br>
> + guint found4g = FALSE;<br>
> + guint i;<br>
> +<br>
> + for (i = 0; i < bands_array->len; i++) {<br>
> + MMModemBand band = g_array_index(bands_array, MMModemBand, i);<br>
> +<br>
> + if (flag2g != NULL &&<br>
> + band > MM_MODEM_BAND_UNKNOWN && band <= MM_MODEM_BAND_G850) {<br>
> + mask_2g += 1 << band;<br>
> + }<br>
> +<br>
> + if (flag3g != NULL &&<br>
> + band >= MM_MODEM_BAND_U2100 && band <= MM_MODEM_BAND_U2600) {<br>
> + mask3g += 1 << band;<br>
> + }<br>
> +<br>
> + if (flag4g != NULL &&<br>
> + band >= MM_MODEM_BAND_EUTRAN_I && band <= MM_MODEM_BAND_EUTRAN_XLIV) {<br>
> + mask4g += 1 << (band - MM_MODEM_BAND_EUTRAN_I);<br>
> + found4g = TRUE;<br>
> + }<br>
> + }<br>
> +<br>
> + /* Get 2G flag */<br>
> + if (flag2g != NULL) {<br>
> + if (mask_2g == ((1 << MM_MODEM_BAND_EGSM) + (1 << MM_MODEM_BAND_DCS)))<br>
> + *flag2g = 0;<br>
> + else if (mask_2g == ((1 << MM_MODEM_BAND_EGSM) + (1 << MM_MODEM_BAND_PCS)))<br>
> + *flag2g = 1;<br>
> + else if (mask_2g == ((1 << MM_MODEM_BAND_G850) + (1 << MM_MODEM_BAND_DCS)))<br>
> + *flag2g = 2;<br>
> + else if (mask_2g == ((1 << MM_MODEM_BAND_G850) + (1 << MM_MODEM_BAND_PCS)))<br>
> + *flag2g = 3;<br>
> + else<br>
> + *flag2g = -1;<br>
> + }<br>
> +<br>
> + /* Get 3G flag */<br>
> + if (flag3g != NULL) {<br>
> + if (mask3g == (1 << MM_MODEM_BAND_U2100))<br>
> + *flag3g = 0;<br>
> + else if (mask3g == (1 << MM_MODEM_BAND_U1900))<br>
> + *flag3g = 1;<br>
> + else if (mask3g == (1 << MM_MODEM_BAND_U850))<br>
> + *flag3g = 2;<br>
> + else if (mask3g == ((1 << MM_MODEM_BAND_U2100) +<br>
> + (1 << MM_MODEM_BAND_U1900) +<br>
> + (1 << MM_MODEM_BAND_U850)))<br>
> + *flag3g = 3;<br>
> + else if (mask3g == ((1 << MM_MODEM_BAND_U1900) +<br>
> + (1 << MM_MODEM_BAND_U850)))<br>
> + *flag3g = 4;<br>
> + else if (mask3g == (1 << MM_MODEM_BAND_U900))<br>
> + *flag3g = 5;<br>
> + else if (mask3g == ((1 << MM_MODEM_BAND_U2100) +<br>
> + (1 << MM_MODEM_BAND_U900)))<br>
> + *flag3g = 6;<br>
> + else if (mask3g == (1 << MM_MODEM_BAND_U17IV))<br>
> + *flag3g = 7;<br>
> + else<br>
> + *flag3g = -1;<br>
> + }<br>
> +<br>
> + /* 4G flag correspond to the mask */<br>
> + if (flag4g != NULL) {<br>
> + if (found4g)<br>
> + *flag4g = mask4g;<br>
> + else<br>
> + *flag4g = -1;<br>
> + }<br>
> +}<br>
> +<br>
> /*****************************************************************************/<br>
> /* +CSIM response parser */<br>
><br>
> diff --git a/plugins/telit/mm-modem-helpers-telit.h b/plugins/telit/mm-modem-helpers-telit.h<br>
> index a7e250e..75bd6ad 100644<br>
> --- a/plugins/telit/mm-modem-helpers-telit.h<br>
> +++ b/plugins/telit/mm-modem-helpers-telit.h<br>
> @@ -97,4 +97,5 @@ gboolean mm_telit_update_2g_bands(gchar *band_list, GMatchInfo **match_info, GAr<br>
> gboolean mm_telit_update_3g_bands(gchar *band_list, GMatchInfo **match_info, GArray **bands, GError **error);<br>
> gboolean mm_telit_update_4g_bands(GArray** bands, GMatchInfo *match_info, GError **error);<br>
><br>
> +void mm_telit_get_band_flag (GArray *bands_array, gint *flag_2g, gint *flag_3g, gint *flag_4g);<br>
> #endif /* MM_MODEM_HELPERS_TELIT_H */<br>
> diff --git a/plugins/telit/tests/test-mm-modem-helpers-telit.c b/plugins/telit/tests/test-mm-modem-helpers-telit.c<br>
> index cac10fb..bfdde89 100644<br>
> --- a/plugins/telit/tests/test-mm-modem-helpers-telit.c<br>
> +++ b/plugins/telit/tests/test-mm-modem-helpers-telit.c<br>
> @@ -313,8 +313,196 @@ test_parse_current_bands_response (void) {<br>
> }<br>
> }<br>
><br>
> +static void<br>
> +test_telit_get_2g_bnd_flag (void)<br>
> +{<br>
> + GArray *bands_array;<br>
> + gint flag2g;<br>
> + MMModemBand egsm = MM_MODEM_BAND_EGSM;<br>
> + MMModemBand dcs = MM_MODEM_BAND_DCS;<br>
> + MMModemBand pcs = MM_MODEM_BAND_PCS;<br>
> + MMModemBand g850 = MM_MODEM_BAND_G850;<br>
> +<br>
> + /* Test Flag 0 */<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 2);<br>
> + g_array_append_val (bands_array, egsm);<br>
> + g_array_append_val (bands_array, dcs);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, &flag2g, NULL, NULL);<br>
> + g_assert_cmpuint (flag2g, ==, 0);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 1 */<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 2);<br>
> + g_array_append_val (bands_array, egsm);<br>
> + g_array_append_val (bands_array, pcs);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, &flag2g, NULL, NULL);<br>
> + g_assert_cmpuint (flag2g, ==, 1);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 2 */<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 2);<br>
> + g_array_append_val (bands_array, g850);<br>
> + g_array_append_val (bands_array, dcs);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, &flag2g, NULL, NULL);<br>
> + g_assert_cmpuint (flag2g, ==, 2);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 3 */<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 2);<br>
> + g_array_append_val (bands_array, g850);<br>
> + g_array_append_val (bands_array, pcs);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, &flag2g, NULL, NULL);<br>
> + g_assert_cmpuint (flag2g, ==, 3);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test invalid band array */<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 2);<br>
> + g_array_append_val (bands_array, g850);<br>
> + g_array_append_val (bands_array, egsm);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, &flag2g, NULL, NULL);<br>
> + g_assert_cmpuint (flag2g, ==, -1);<br>
> + g_array_free (bands_array, TRUE);<br>
> +}<br>
><br>
><br>
> +static void<br>
> +test_telit_get_3g_bnd_flag (void)<br>
> +{<br>
> + GArray *bands_array;<br>
> + MMModemBand u2100 = MM_MODEM_BAND_U2100;<br>
> + MMModemBand u1900 = MM_MODEM_BAND_U1900;<br>
> + MMModemBand u850 = MM_MODEM_BAND_U850;<br>
> + MMModemBand u900 = MM_MODEM_BAND_U900;<br>
> + MMModemBand u17iv = MM_MODEM_BAND_U17IV;<br>
> + MMModemBand u17ix = MM_MODEM_BAND_U17IX;<br>
> + gint flag;<br>
> +<br>
> + /* Test flag 0 */<br>
> + flag = -1;<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1);<br>
> + g_array_append_val (bands_array, u2100);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, &flag, NULL);<br>
> + g_assert_cmpint (flag, ==, 0);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 1 */<br>
> + flag = -1;<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1);<br>
> + g_array_append_val (bands_array, u1900);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, &flag, NULL);<br>
> + g_assert_cmpint (flag, ==, 1);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 2 */<br>
> + flag = -1;<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1);<br>
> + g_array_append_val (bands_array, u850);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, &flag, NULL);<br>
> + g_assert_cmpint (flag, ==, 2);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 3 */<br>
> + flag = -1;<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 3);<br>
> + g_array_append_val (bands_array, u2100);<br>
> + g_array_append_val (bands_array, u1900);<br>
> + g_array_append_val (bands_array, u850);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, &flag, NULL);<br>
> + g_assert_cmpint (flag, ==, 3);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 4 */<br>
> + flag = -1;<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 2);<br>
> + g_array_append_val (bands_array, u1900);<br>
> + g_array_append_val (bands_array, u850);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, &flag, NULL);<br>
> + g_assert_cmpint (flag, ==, 4);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 5 */<br>
> + flag = -1;<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1);<br>
> + g_array_append_val (bands_array, u900);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, &flag, NULL);<br>
> + g_assert_cmpint (flag, ==, 5);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 6 */<br>
> + flag = -1;<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 2);<br>
> + g_array_append_val (bands_array, u2100);<br>
> + g_array_append_val (bands_array, u900);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, &flag, NULL);<br>
> + g_assert_cmpint (flag, ==, 6);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 7 */<br>
> + flag = -1;<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1);<br>
> + g_array_append_val (bands_array, u17iv);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, &flag, NULL);<br>
> + g_assert_cmpint (flag, ==, 7);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test invalid band array */<br>
> + flag = -1;<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1);<br>
> + g_array_append_val (bands_array, u17ix);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, &flag, NULL);<br>
> + g_assert_cmpint (flag, ==, -1);<br>
> + g_array_free (bands_array, TRUE);<br>
> +}<br>
> +<br>
> +static void<br>
> +test_telit_get_4g_bnd_flag (void)<br>
> +{<br>
> + GArray *bands_array;<br>
> + MMModemBand eutran_i = MM_MODEM_BAND_EUTRAN_I;<br>
> + MMModemBand eutran_ii = MM_MODEM_BAND_EUTRAN_II;<br>
> + MMModemBand egsm = MM_MODEM_BAND_EGSM;<br>
> + gint flag = -1;<br>
> +<br>
> + /* Test flag 1 */<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1);<br>
> + g_array_append_val (bands_array, eutran_i);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, NULL, &flag);<br>
> + g_assert_cmpint (flag, ==, 1);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test flag 3 */<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 2);<br>
> + g_array_append_val (bands_array, eutran_i);<br>
> + g_array_append_val (bands_array, eutran_ii);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, NULL, &flag);<br>
> + g_assert_cmpint (flag, ==, 3);<br>
> + g_array_free (bands_array, TRUE);<br>
> +<br>
> + /* Test invalid bands array */<br>
> + bands_array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1);<br>
> + g_array_append_val (bands_array, egsm);<br>
> +<br>
> + mm_telit_get_band_flag (bands_array, NULL, NULL, &flag);<br>
> + g_assert_cmpint (flag, ==, -1);<br>
> + g_array_free (bands_array, TRUE);<br>
> +}<br>
> +<br>
> int main (int argc, char **argv)<br>
> {<br>
> setlocale (LC_ALL, "");<br>
> @@ -327,5 +515,8 @@ int main (int argc, char **argv)<br>
> g_test_add_func ("/MM/telit/bands/supported/parse_band_flag", test_parse_band_flag_str);<br>
> g_test_add_func ("/MM/telit/bands/supported/parse_bands_response", test_parse_supported_bands_response);<br>
> g_test_add_func ("/MM/telit/bands/current/parse_bands_response", test_parse_current_bands_response);<br>
> + g_test_add_func ("/MM/telit/bands/current/set_bands/2g", test_telit_get_2g_bnd_flag);<br>
> + g_test_add_func ("/MM/telit/bands/current/set_bands/3g", test_telit_get_3g_bnd_flag);<br>
> + g_test_add_func ("/MM/telit/bands/current/set_bands/4g", test_telit_get_4g_bnd_flag);<br>
> return g_test_run ();<br>
> }<br>
> --<br>
> 2.1.4<br>
><br>
</div></div>> _______________________________________________<br>
> ModemManager-devel mailing list<br>
> <a href="mailto:ModemManager-devel@lists.freedesktop.org">ModemManager-devel@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/modemmanager-devel</a><br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
--<br>
Aleksander<br>
<a href="https://aleksander.es" rel="noreferrer" target="_blank">https://aleksander.es</a><br>
</font></span></blockquote></div><br></div>