aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mm-broadband-modem-qmi.c143
-rw-r--r--src/mm-modem-helpers-qmi.c71
-rw-r--r--src/mm-modem-helpers-qmi.h16
-rw-r--r--src/tests/Makefile.am43
-rw-r--r--src/tests/test-modem-helpers-qmi.c383
5 files changed, 548 insertions, 108 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
index 46f81ae9..50fa85a7 100644
--- a/src/mm-broadband-modem-qmi.c
+++ b/src/mm-broadband-modem-qmi.c
@@ -318,8 +318,8 @@ typedef struct {
GSimpleAsyncResult *result;
gboolean run_get_system_selection_preference;
gboolean run_get_technology_preference;
- gboolean run_get_capabilities;
- MMModemCapability capabilities;
+
+ MMQmiCapabilitiesContext capabilities_context;
} LoadCurrentCapabilitiesContext;
static MMModemCapability
@@ -327,19 +327,12 @@ modem_load_current_capabilities_finish (MMIfaceModem *self,
GAsyncResult *res,
GError **error)
{
- MMModemCapability caps;
- gchar *caps_str;
-
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return MM_MODEM_CAPABILITY_NONE;
- caps = ((MMModemCapability) GPOINTER_TO_UINT (
+ return ((MMModemCapability) GPOINTER_TO_UINT (
g_simple_async_result_get_op_res_gpointer (
G_SIMPLE_ASYNC_RESULT (res))));
- caps_str = mm_modem_capability_build_string_from_mask (caps);
- mm_dbg ("loaded current capabilities: %s", caps_str);
- g_free (caps_str);
- return caps;
}
static void
@@ -350,7 +343,7 @@ load_current_capabilities_context_complete_and_free (LoadCurrentCapabilitiesCont
g_object_unref (ctx->nas_client);
g_object_unref (ctx->dms_client);
g_object_unref (ctx->self);
- g_free (ctx);
+ g_slice_free (LoadCurrentCapabilitiesContext, ctx);
}
static void load_current_capabilities_context_step (LoadCurrentCapabilitiesContext *ctx);
@@ -372,7 +365,6 @@ load_current_capabilities_get_capabilities_ready (QmiClientDms *client,
g_simple_async_result_take_error (ctx->result, error);
} else {
guint i;
- guint mask = MM_MODEM_CAPABILITY_NONE;
GArray *radio_interface_list;
qmi_message_dms_get_capabilities_output_get_info (
@@ -385,26 +377,20 @@ load_current_capabilities_get_capabilities_ready (QmiClientDms *client,
NULL);
for (i = 0; i < radio_interface_list->len; i++) {
- mask |= mm_modem_capability_from_qmi_radio_interface (g_array_index (radio_interface_list,
- QmiDmsRadioInterface,
- i));
+ ctx->capabilities_context.dms_capabilities |=
+ mm_modem_capability_from_qmi_radio_interface (g_array_index (radio_interface_list,
+ QmiDmsRadioInterface,
+ i));
}
-
- /* Final capabilities are the intersection between the Technology
- * Preference (ie, allowed modes) or SSP and the device's capabilities.
- * If the Technology Preference was "auto" or unknown we just fall back
- * to the Get Capabilities response.
- */
- if (ctx->capabilities == MM_MODEM_CAPABILITY_NONE)
- ctx->capabilities = mask;
- else
- ctx->capabilities &= mask;
}
if (output)
qmi_message_dms_get_capabilities_output_unref (output);
- g_simple_async_result_set_op_res_gpointer (ctx->result, GUINT_TO_POINTER (ctx->capabilities), NULL);
+ g_simple_async_result_set_op_res_gpointer (
+ ctx->result,
+ GUINT_TO_POINTER (mm_modem_capability_from_qmi_capabilities_context (&ctx->capabilities_context)),
+ NULL);
load_current_capabilities_context_complete_and_free (ctx);
}
@@ -424,23 +410,11 @@ load_current_capabilities_get_technology_preference_ready (QmiClientNas *client,
mm_dbg ("Couldn't get technology preference: %s", error->message);
g_error_free (error);
} else {
- QmiNasRadioTechnologyPreference preference_mask;
-
qmi_message_nas_get_technology_preference_output_get_active (
output,
- &preference_mask,
+ &ctx->capabilities_context.nas_tp_mask,
NULL, /* duration */
NULL);
- if (preference_mask != QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO) {
- gchar *str;
-
- str = qmi_nas_radio_technology_preference_build_string_from_mask (preference_mask);
- ctx->capabilities = mm_modem_capability_from_qmi_radio_technology_preference (preference_mask);
- mm_dbg ("%s modes reported in technology preference: '%s'",
- ctx->capabilities == MM_MODEM_CAPABILITY_NONE ? "Unsupported" : "Valid",
- str);
- g_free (str);
- }
}
if (output)
@@ -448,8 +422,6 @@ load_current_capabilities_get_technology_preference_ready (QmiClientNas *client,
/* Mark as TP already run */
ctx->run_get_technology_preference = FALSE;
-
- /* Get DMS Capabilities too */
load_current_capabilities_context_step (ctx);
}
@@ -460,7 +432,6 @@ load_current_capabilities_get_system_selection_preference_ready (QmiClientNas *c
{
QmiMessageNasGetSystemSelectionPreferenceOutput *output = NULL;
GError *error = NULL;
- QmiNasRatModePreference mode_preference_mask = 0;
output = qmi_client_nas_get_system_selection_preference_finish (client, res, &error);
if (!output) {
@@ -469,46 +440,22 @@ load_current_capabilities_get_system_selection_preference_ready (QmiClientNas *c
} else if (!qmi_message_nas_get_system_selection_preference_output_get_result (output, &error)) {
mm_dbg ("Couldn't get system selection preference: %s", error->message);
g_error_free (error);
- } else if (!qmi_message_nas_get_system_selection_preference_output_get_mode_preference (
- output,
- &mode_preference_mask,
- NULL)) {
- QmiNasBandPreference band_preference_mask;
-
- mm_dbg ("Mode preference not reported in system selection preference");
-
- if (qmi_message_nas_get_system_selection_preference_output_get_band_preference (
- output,
- &band_preference_mask,
- NULL)) {
- gchar *str;
-
- str = qmi_nas_band_preference_build_string_from_mask (band_preference_mask);
- ctx->capabilities = mm_modem_capability_from_qmi_band_preference (band_preference_mask);
- mm_dbg ("%s bands reported in system selection preference: '%s'",
- ctx->capabilities == MM_MODEM_CAPABILITY_NONE ? "Unsupported" : "Valid",
- str);
- g_free (str);
-
- /* Just the presence of the LTE band preference tells us it's LTE */
- if (qmi_message_nas_get_system_selection_preference_output_get_lte_band_preference (
- output,
- NULL,
- NULL)) {
- mm_dbg ("LTE band preference found");
- ctx->capabilities |= MM_MODEM_CAPABILITY_LTE;
- }
- } else
- mm_dbg ("Band preference not reported in system selection preference");
} else {
- gchar *str;
-
- str = qmi_nas_rat_mode_preference_build_string_from_mask (mode_preference_mask);
- ctx->capabilities = mm_modem_capability_from_qmi_rat_mode_preference (mode_preference_mask);
- mm_dbg ("%s capabilities reported in system selection preference: '%s'",
- ctx->capabilities == MM_MODEM_CAPABILITY_NONE ? "Unsupported" : "Valid",
- str);
- g_free (str);
+ /* Get Mode Preference */
+ qmi_message_nas_get_system_selection_preference_output_get_mode_preference (
+ output,
+ &ctx->capabilities_context.nas_ssp_mode_preference_mask,
+ NULL);
+ /* Get Band Preference */
+ qmi_message_nas_get_system_selection_preference_output_get_band_preference (
+ output,
+ &ctx->capabilities_context.nas_ssp_band_preference_mask,
+ NULL);
+ /* Get LTE Band Preference */
+ qmi_message_nas_get_system_selection_preference_output_get_lte_band_preference (
+ output,
+ &ctx->capabilities_context.nas_ssp_lte_band_preference_mask,
+ NULL);
}
if (output)
@@ -516,11 +463,6 @@ load_current_capabilities_get_system_selection_preference_ready (QmiClientNas *c
/* Mark as SSP already run */
ctx->run_get_system_selection_preference = FALSE;
-
- /* If we got some value, cache it and go on to DMS Get Capabilities */
- if (ctx->capabilities != MM_MODEM_CAPABILITY_NONE)
- ctx->run_get_technology_preference = FALSE;
-
load_current_capabilities_context_step (ctx);
}
@@ -549,23 +491,13 @@ load_current_capabilities_context_step (LoadCurrentCapabilitiesContext *ctx)
return;
}
- if (ctx->run_get_capabilities) {
- qmi_client_dms_get_capabilities (
- ctx->dms_client,
- NULL, /* no input */
- 5,
- NULL, /* cancellable */
- (GAsyncReadyCallback)load_current_capabilities_get_capabilities_ready,
- ctx);
- return;
- }
-
- g_simple_async_result_set_error (
- ctx->result,
- MM_CORE_ERROR,
- MM_CORE_ERROR_UNSUPPORTED,
- "Loading current capabilities is not supported by this device");
- load_current_capabilities_context_complete_and_free (ctx);
+ qmi_client_dms_get_capabilities (
+ ctx->dms_client,
+ NULL, /* no input */
+ 5,
+ NULL, /* cancellable */
+ (GAsyncReadyCallback)load_current_capabilities_get_capabilities_ready,
+ ctx);
}
static void
@@ -603,7 +535,7 @@ modem_load_current_capabilities (MMIfaceModem *self,
callback, user_data))
return;
- ctx = g_new0 (LoadCurrentCapabilitiesContext, 1);
+ ctx = g_slice_new0 (LoadCurrentCapabilitiesContext);
ctx->self = g_object_ref (self);
ctx->nas_client = g_object_ref (nas_client);
ctx->dms_client = g_object_ref (dms_client);
@@ -611,13 +543,10 @@ modem_load_current_capabilities (MMIfaceModem *self,
callback,
user_data,
modem_load_current_capabilities);
- ctx->capabilities = MM_MODEM_CAPABILITY_NONE;
/* System selection preference introduced in NAS 1.1 */
ctx->run_get_system_selection_preference = qmi_client_check_version (nas_client, 1, 1);
-
ctx->run_get_technology_preference = TRUE;
- ctx->run_get_capabilities = TRUE;
load_current_capabilities_context_step (ctx);
}
diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c
index 7de04347..3331de6a 100644
--- a/src/mm-modem-helpers-qmi.c
+++ b/src/mm-modem-helpers-qmi.c
@@ -1145,3 +1145,74 @@ mm_bearer_allowed_auth_to_qmi_authentication (MMBearerAllowedAuth auth)
return out;
}
+
+/*****************************************************************************/
+
+MMModemCapability
+mm_modem_capability_from_qmi_capabilities_context (MMQmiCapabilitiesContext *ctx)
+{
+ MMModemCapability tmp = MM_MODEM_CAPABILITY_NONE;
+ gchar *nas_ssp_mode_preference_str;
+ gchar *nas_ssp_band_preference_str;
+ gchar *nas_ssp_lte_band_preference_str;
+ gchar *nas_tp_str;
+ gchar *dms_capabilities_str;
+ gchar *tmp_str;
+
+ /* SSP logic to gather capabilities uses the Mode Preference TLV if available,
+ * and if not available it falls back to using Band Preference TLVs */
+ if (ctx->nas_ssp_mode_preference_mask)
+ tmp = mm_modem_capability_from_qmi_rat_mode_preference (ctx->nas_ssp_mode_preference_mask);
+ else if (ctx->nas_ssp_band_preference_mask) {
+ tmp = mm_modem_capability_from_qmi_band_preference (ctx->nas_ssp_band_preference_mask);
+ /* Just the presence of the LTE band preference tells us it's LTE */
+ if (ctx->nas_ssp_lte_band_preference_mask)
+ tmp |= MM_MODEM_CAPABILITY_LTE;
+ }
+
+ /* If no value retrieved from SSP, check TP. We only process TP
+ * values if not 'auto'. */
+ if ( tmp == MM_MODEM_CAPABILITY_NONE
+ && ctx->nas_tp_mask
+ && ctx->nas_tp_mask != QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO)
+ tmp = mm_modem_capability_from_qmi_radio_technology_preference (ctx->nas_tp_mask);
+
+ /* Final capabilities are the intersection between the Technology
+ * Preference or SSP and the device's capabilities.
+ * If the Technology Preference was "auto" or unknown we just fall back
+ * to the Get Capabilities response.
+ */
+ if (tmp == MM_MODEM_CAPABILITY_NONE)
+ tmp = ctx->dms_capabilities;
+ else
+ tmp &= ctx->dms_capabilities;
+
+
+ /* Log about the logic applied */
+ nas_ssp_mode_preference_str = qmi_nas_rat_mode_preference_build_string_from_mask (ctx->nas_ssp_mode_preference_mask);
+ nas_ssp_band_preference_str = qmi_nas_band_preference_build_string_from_mask (ctx->nas_ssp_band_preference_mask);
+ nas_ssp_lte_band_preference_str = qmi_nas_lte_band_preference_build_string_from_mask (ctx->nas_ssp_band_preference_mask);
+ nas_tp_str = qmi_nas_radio_technology_preference_build_string_from_mask (ctx->nas_tp_mask);
+ dms_capabilities_str = mm_modem_capability_build_string_from_mask (ctx->dms_capabilities);
+ tmp_str = mm_modem_capability_build_string_from_mask (tmp);
+ mm_dbg ("Current capabilities built: '%s'\n"
+ " SSP mode preference: '%s'\n"
+ " SSP band preference: '%s'\n"
+ " SSP LTE band preference: '%s'\n"
+ " TP: '%s'\n"
+ " DMS Capabilities: '%s'",
+ tmp_str,
+ nas_ssp_mode_preference_str ? nas_ssp_mode_preference_str : "unknown",
+ nas_ssp_band_preference_str ? nas_ssp_band_preference_str : "unknown",
+ nas_ssp_lte_band_preference_str ? nas_ssp_lte_band_preference_str : "unknown",
+ nas_tp_str ? nas_tp_str : "unknown",
+ dms_capabilities_str);
+ g_free (nas_ssp_mode_preference_str);
+ g_free (nas_ssp_band_preference_str);
+ g_free (nas_ssp_lte_band_preference_str);
+ g_free (nas_tp_str);
+ g_free (dms_capabilities_str);
+ g_free (tmp_str);
+
+ return tmp;
+}
diff --git a/src/mm-modem-helpers-qmi.h b/src/mm-modem-helpers-qmi.h
index 711d655b..8da0fdd7 100644
--- a/src/mm-modem-helpers-qmi.h
+++ b/src/mm-modem-helpers-qmi.h
@@ -90,4 +90,20 @@ MMSmsState mm_sms_state_from_qmi_message_tag (QmiWmsMessageTagType tag);
QmiWdsAuthentication mm_bearer_allowed_auth_to_qmi_authentication (MMBearerAllowedAuth auth);
+/*****************************************************************************/
+/* Utility to gather current capabilities from various sources */
+
+typedef struct {
+ /* NAS System Selection Preference */
+ QmiNasRatModePreference nas_ssp_mode_preference_mask;
+ QmiNasBandPreference nas_ssp_band_preference_mask;
+ QmiNasLteBandPreference nas_ssp_lte_band_preference_mask;
+ /* NAS Technology Preference */
+ QmiNasRadioTechnologyPreference nas_tp_mask;
+ /* DMS Capabilities */
+ MMModemCapability dms_capabilities;
+} MMQmiCapabilitiesContext;
+
+MMModemCapability mm_modem_capability_from_qmi_capabilities_context (MMQmiCapabilitiesContext *ctx);
+
#endif /* MM_MODEM_HELPERS_QMI_H */
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 9d366053..38c4627c 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -6,6 +6,12 @@ noinst_PROGRAMS = \
test-at-serial-port \
test-sms-part
+if WITH_QMI
+noinst_PROGRAMS += test-modem-helpers-qmi
+endif
+
+################
+
test_modem_helpers_SOURCES = \
test-modem-helpers.c
@@ -28,6 +34,30 @@ test_modem_helpers_CPPFLAGS += $(QMI_CFLAGS)
test_modem_helpers_LDADD += $(QMI_LIBS)
endif
+################
+
+if WITH_QMI
+test_modem_helpers_qmi_SOURCES = \
+ test-modem-helpers-qmi.c
+
+test_modem_helpers_qmi_CPPFLAGS = \
+ $(MM_CFLAGS) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src \
+ -I$(top_srcdir)/include \
+ -I$(top_builddir)/include \
+ -I$(top_srcdir)/libmm-glib \
+ -I$(top_srcdir)/libmm-glib/generated \
+ -I$(top_builddir)/libmm-glib/generated \
+ $(QMI_CFLAGS)
+
+test_modem_helpers_qmi_LDADD = \
+ $(top_builddir)/src/libmodem-helpers.la \
+ $(MM_LIBS) \
+ $(QMI_LIBS)
+endif
+
+################
test_charsets_SOURCES = \
test-charsets.c
@@ -51,6 +81,8 @@ test_charsets_CPPFLAGS += $(QMI_CFLAGS)
test_charsets_LDADD += $(QMI_LIBS)
endif
+################
+
test_qcdm_serial_port_SOURCES = \
test-qcdm-serial-port.c
@@ -76,6 +108,8 @@ test_qcdm_serial_port_CPPFLAGS += $(QMI_CFLAGS)
test_qcdm_serial_port_LDADD += $(QMI_LIBS)
endif
+################
+
test_at_serial_port_SOURCES = \
test-at-serial-port.c
@@ -100,6 +134,8 @@ test_at_serial_port_CPPFLAGS += $(QMI_CFLAGS)
test_at_serial_port_LDADD += $(QMI_LIBS)
endif
+################
+
test_sms_part_SOURCES = \
test-sms-part.c
@@ -122,12 +158,17 @@ test_sms_part_CPPFLAGS += $(QMI_CFLAGS)
test_sms_part_LDADD += $(QMI_LIBS)
endif
+################
+
if WITH_TESTS
-check-local: test-modem-helpers test-charsets test-qcdm-serial-port test-sms-part
+check-local: $(noinst_PROGRAMS)
$(abs_builddir)/test-modem-helpers
$(abs_builddir)/test-charsets
$(abs_builddir)/test-qcdm-serial-port
$(abs_builddir)/test-sms-part
+if WITH_QMI
+ $(abs_builddir)/test-modem-helpers-qmi
+endif
endif
diff --git a/src/tests/test-modem-helpers-qmi.c b/src/tests/test-modem-helpers-qmi.c
new file mode 100644
index 00000000..19e41882
--- /dev/null
+++ b/src/tests/test-modem-helpers-qmi.c
@@ -0,0 +1,383 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2012 Lanedo GmbH.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <string.h>
+#include <stdlib.h>
+#include <locale.h>
+
+#include "mm-enums-types.h"
+#include "mm-modem-helpers-qmi.h"
+#include "mm-log.h"
+
+static void
+test_capabilities_expected (MMQmiCapabilitiesContext *ctx,
+ MMModemCapability expected)
+{
+ MMModemCapability built;
+ gchar *expected_str;
+ gchar *built_str;
+
+ built = mm_modem_capability_from_qmi_capabilities_context (ctx);
+
+ expected_str = mm_modem_capability_build_string_from_mask (expected);
+ built_str = mm_modem_capability_build_string_from_mask (built);
+
+ /* compare strings, so that the error shows the string values as well */
+ g_assert_cmpstr (built_str, ==, expected_str);
+
+ g_free (expected_str);
+ g_free (built_str);
+}
+
+/*****************************************************************************/
+/* UML290:
+ * ∘ +GCAP: +CIS707-A, CIS-856, CIS-856-A, +CGSM, +CLTE2
+ * ∘ +WS46: (12,22,25)
+ * ∘ DMS GetCapa: Networks: 'cdma20001x, evdo, gsm, umts, lte' (always)
+ * ∘ NAS TP: unsupported
+ * ∘ NAS SSP: Band pref & LTE band pref always given
+ * ∘ QCDM -> CDMA/EVDO = NAS SSP: Mode preference: 'cdma-1x, cdma-1xevdo'
+ * ∘ QCDM -> GSM/UMTS = NAS SSP: Mode preference: 'gsm, umts'
+ * ∘ QCDM -> Automatic = NAS SSP: no mode pref TLV given
+ * ∘ QCDM -> LTE-only = NAS SSP: Mode preference: 'lte'
+*/
+
+static void
+test_uml290 (void)
+{
+ MMQmiCapabilitiesContext ctx;
+
+ /* QCDM -> CDMA/EVDO */
+ ctx.nas_ssp_mode_preference_mask = (QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1X |
+ QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1XEVDO);
+ ctx.nas_ssp_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_tp_mask = 0; /* Unsupported */
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS |
+ MM_MODEM_CAPABILITY_CDMA_EVDO |
+ MM_MODEM_CAPABILITY_LTE);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_CDMA_EVDO);
+
+ /* QCDM -> GSM/UMTS */
+ ctx.nas_ssp_mode_preference_mask = (QMI_NAS_RAT_MODE_PREFERENCE_GSM |
+ QMI_NAS_RAT_MODE_PREFERENCE_UMTS);
+ ctx.nas_ssp_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_tp_mask = 0; /* Unsupported */
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS |
+ MM_MODEM_CAPABILITY_CDMA_EVDO |
+ MM_MODEM_CAPABILITY_LTE);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_GSM_UMTS);
+
+ /* QCDM -> Automatic */
+ ctx.nas_ssp_mode_preference_mask = 0;
+ ctx.nas_ssp_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_tp_mask = 0; /* Unsupported */
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS |
+ MM_MODEM_CAPABILITY_CDMA_EVDO |
+ MM_MODEM_CAPABILITY_LTE);
+ test_capabilities_expected (&ctx,
+ (MM_MODEM_CAPABILITY_GSM_UMTS |
+ MM_MODEM_CAPABILITY_CDMA_EVDO |
+ MM_MODEM_CAPABILITY_LTE));
+}
+
+/*****************************************************************************/
+/* ADU960S:
+ * ∘ +GCAP: +CGSM,+DS,+ES
+ * ∘ +WS46: ERROR
+ * ∘ NAS TP: unsupported
+ * ∘ DMS GetCapa: Networks: 'cdma20001x, evdo, gsm, umts, lte'
+ * ∘ NAS SSP: LTE band preference: '(null)'
+ * ∘ (no QCDM port)
+ */
+
+static void
+test_adu960s (void)
+{
+ MMQmiCapabilitiesContext ctx;
+
+ ctx.nas_ssp_mode_preference_mask = 0;
+ ctx.nas_ssp_band_preference_mask = 0;
+ ctx.nas_ssp_lte_band_preference_mask = 0;
+ ctx.nas_tp_mask = 0; /* Unsupported */
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS |
+ MM_MODEM_CAPABILITY_CDMA_EVDO |
+ MM_MODEM_CAPABILITY_LTE);
+ test_capabilities_expected (&ctx,
+ (MM_MODEM_CAPABILITY_GSM_UMTS |
+ MM_MODEM_CAPABILITY_CDMA_EVDO |
+ MM_MODEM_CAPABILITY_LTE));
+}
+
+/*****************************************************************************/
+/* Gobi 1K with GSM firmware:
+ * ∘ +GCAP: didn't respond to AT commands
+ * ∘ NAS TP: Active: 'auto', duration: 'permanent'
+ * ∘ DMS GetCapa: Networks: 'gsm, umts'
+ * ∘ NAS SSP: unsupported
+ * ∘ (no QCDM port)
+ */
+
+static void
+test_gobi1k_gsm (void)
+{
+ MMQmiCapabilitiesContext ctx;
+
+ ctx.nas_ssp_mode_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_tp_mask = QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO;
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_GSM_UMTS);
+}
+
+/*****************************************************************************/
+/* Gobi 1K with EVDO firmware:
+ * ∘ +GCAP: didn't respond to AT commands
+ * ∘ NAS TP: Active: 'auto', duration: 'permanent'
+ * ∘ DMS GetCapa: Networks: 'cdma20001x, evdo'
+ * ∘ NAS SSP: unsupported
+ * ∘ (no QCDM port)
+ */
+
+static void
+test_gobi1k_cdma (void)
+{
+ MMQmiCapabilitiesContext ctx;
+
+ ctx.nas_ssp_mode_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_tp_mask = QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO;
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_CDMA_EVDO);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_CDMA_EVDO);
+}
+
+/*****************************************************************************/
+/* Gobi 2K with GSM firmware:
+ * ∘ +GCAP: +CGSM,+DS
+ * ∘ +WS46: ERROR
+ * ∘ DMS GetCapa: Networks: 'gsm, umts'
+ * ∘ NAS SSP: unsupported
+ * ∘ QCDM -> Automatic = NAS TP: Active: 'auto', duration: 'permanent'
+ * ∘ QCDM -> UMTS only = NAS TP: Active: '3gpp, cdma-or-wcdma', duration: 'permanent'
+ * ∘ QCDM -> GPRS only = NAS TP: Active: '3gpp, amps-or-gsm', duration: 'permanent'
+ */
+
+static void
+test_gobi2k_gsm (void)
+{
+ MMQmiCapabilitiesContext ctx;
+
+ /* QCDM -> Automatic */
+ ctx.nas_ssp_mode_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_tp_mask = QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO;
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_GSM_UMTS);
+
+ /* QCDM -> UMTS only */
+ ctx.nas_ssp_mode_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_tp_mask = (QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_3GPP | QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_CDMA_OR_WCDMA);
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_GSM_UMTS);
+
+ /* QCDM -> GPRS only */
+ ctx.nas_ssp_mode_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_tp_mask = (QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_3GPP | QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AMPS_OR_GSM);
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_GSM_UMTS);
+}
+
+/*****************************************************************************/
+/* Gobi 2K with CDMA firmware:
+ * ∘ +GCAP: +CIS707-A, CIS-856, CIS-856-A, CIS707,+MS, +ES, +DS, +FCL
+ * ∘ +WS46: ERROR
+ * ∘ DMS GetCapa: Networks: 'cdma20001x, evdo'
+ * ∘ NAS SSP: unsupported
+ * ∘ QCDM -> Automatic = NAS TP: Active: 'auto', duration: 'permanent'
+ * ∘ QCDM -> CDMA only = NAS TP: Active: '3gpp2, cdma-or-wcdma', duration: 'permanent'
+ * ∘ QCDM -> EVDO only = NAS TP: Active: '3gpp2, hdr', duration: 'permanent'
+ */
+
+static void
+test_gobi2k_cdma (void)
+{
+ MMQmiCapabilitiesContext ctx;
+
+ /* QCDM -> Automatic */
+ ctx.nas_ssp_mode_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_tp_mask = QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO;
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_CDMA_EVDO);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_CDMA_EVDO);
+
+ /* QCDM -> CDMA only */
+ ctx.nas_ssp_mode_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_tp_mask = (QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_3GPP2 | QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_CDMA_OR_WCDMA);
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_CDMA_EVDO);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_CDMA_EVDO);
+
+ /* QCDM -> EVDO only */
+ ctx.nas_ssp_mode_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* Unsupported */
+ ctx.nas_tp_mask = (QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_3GPP2 | QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_HDR);
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_CDMA_EVDO);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_CDMA_EVDO);
+}
+
+/*****************************************************************************/
+/* Gobi 3K with GSM firmware:
+ * ∘ +GCAP: +CGSM,+DS,+ES
+ * ∘ +WS46: ERROR
+ * ∘ DMS GetCapa: Networks: 'gsm, umts'
+ * ∘ QCDM -> Automatic = NAS TP: Active: 'auto', duration: 'permanent'
+ * NAS SSP: Mode preference: 'cdma-1x, cdma-1xevdo, gsm, umts'
+ * ∘ QCDM -> UMTS only = NAS TP: Active: '3gpp, cdma-or-wcdma', duration: 'permanent'
+ * NAS SSP: Mode preference: 'umts'
+ * ∘ QCDM -> GPRS only = NAS TP: Active: '3gpp, amps-or-gsm', duration: 'permanent'
+ * NAS SSP: Mode preference: 'gsm'
+ */
+
+static void
+test_gobi3k_gsm (void)
+{
+ MMQmiCapabilitiesContext ctx;
+
+ /* QCDM -> Automatic */
+ ctx.nas_ssp_mode_preference_mask = (QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1X |
+ QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1XEVDO |
+ QMI_NAS_RAT_MODE_PREFERENCE_GSM |
+ QMI_NAS_RAT_MODE_PREFERENCE_UMTS);
+ ctx.nas_ssp_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_tp_mask = QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO;
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_GSM_UMTS);
+
+ /* QCDM -> GSM only */
+ ctx.nas_ssp_mode_preference_mask = (QMI_NAS_RAT_MODE_PREFERENCE_GSM);
+ ctx.nas_ssp_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_tp_mask = (QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_3GPP | QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AMPS_OR_GSM);
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_GSM_UMTS);
+
+ /* QCDM -> UMTS only */
+ ctx.nas_ssp_mode_preference_mask = (QMI_NAS_RAT_MODE_PREFERENCE_UMTS);
+ ctx.nas_ssp_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_tp_mask = (QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_3GPP | QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_CDMA_OR_WCDMA);
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_GSM_UMTS);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_GSM_UMTS);
+}
+
+/*****************************************************************************/
+/* Gobi 3K with CDMA firmware:
+ * ∘ +GCAP: +CIS707-A, CIS-856, CIS-856-A, CIS707,+MS, +ES, +DS, +FCL
+ * ∘ +WS46: ERROR
+ * ∘ DMS GetCapa: Networks: 'cdma20001x, evdo'
+ * ∘ QCDM -> Automatic = NAS TP: Active: 'auto', duration: 'permanent'
+ * NAS SSP: Mode preference: 'cdma-1x, cdma-1xevdo, gsm, umts'
+ * ∘ QCDM -> EVDO only = NAS TP: Active: '3gpp2, hdr', duration: 'permanent'
+ * NAS SSP: Mode preference: 'cdma-1xevdo'
+ * ∘ QCDM -> CDMA only = NAS TP: Active: '3gpp2, cdma-or-wcdma', duration: 'permanent'
+ * NAS SSP: Mode preference: 'cdma-1x'
+ */
+
+static void
+test_gobi3k_cdma (void)
+{
+ MMQmiCapabilitiesContext ctx;
+
+ /* QCDM -> Automatic */
+ ctx.nas_ssp_mode_preference_mask = (QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1X |
+ QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1XEVDO |
+ QMI_NAS_RAT_MODE_PREFERENCE_GSM |
+ QMI_NAS_RAT_MODE_PREFERENCE_UMTS);
+ ctx.nas_ssp_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_tp_mask = QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_AUTO;
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_CDMA_EVDO);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_CDMA_EVDO);
+
+ /* QCDM -> CDMA only */
+ ctx.nas_ssp_mode_preference_mask = (QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1X);
+ ctx.nas_ssp_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_tp_mask = (QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_3GPP2 | QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_CDMA_OR_WCDMA);
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_CDMA_EVDO);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_CDMA_EVDO);
+
+ /* QCDM -> EVDO only */
+ ctx.nas_ssp_mode_preference_mask = (QMI_NAS_RAT_MODE_PREFERENCE_CDMA_1XEVDO);
+ ctx.nas_ssp_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_ssp_lte_band_preference_mask = 0; /* TODO: Add proper value */
+ ctx.nas_tp_mask = (QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_3GPP2 | QMI_NAS_RADIO_TECHNOLOGY_PREFERENCE_HDR);
+ ctx.dms_capabilities = (MM_MODEM_CAPABILITY_CDMA_EVDO);
+ test_capabilities_expected (&ctx, MM_MODEM_CAPABILITY_CDMA_EVDO);
+}
+
+/*****************************************************************************/
+
+void
+_mm_log (const char *loc,
+ const char *func,
+ guint32 level,
+ const char *fmt,
+ ...)
+{
+ /* Dummy log function */
+ va_list args;
+ gchar *msg;
+
+ va_start (args, fmt);
+ msg = g_strdup_vprintf (fmt, args);
+ va_end (args);
+ g_print ("%s\n", msg);
+ g_free (msg);
+}
+
+int main (int argc, char **argv)
+{
+ setlocale (LC_ALL, "");
+
+ g_type_init ();
+ g_test_init (&argc, &argv, NULL);
+
+ g_test_add_func ("/MM/QMI/Current-Capabilities/UML290", test_uml290);
+ g_test_add_func ("/MM/QMI/Current-Capabilities/ADU960S", test_adu960s);
+ g_test_add_func ("/MM/QMI/Current-Capabilities/Gobi1k/GSM", test_gobi1k_gsm);
+ g_test_add_func ("/MM/QMI/Current-Capabilities/Gobi1k/CDMA", test_gobi1k_cdma);
+ g_test_add_func ("/MM/QMI/Current-Capabilities/Gobi2k/GSM", test_gobi2k_gsm);
+ g_test_add_func ("/MM/QMI/Current-Capabilities/Gobi2k/CDMA", test_gobi2k_cdma);
+ g_test_add_func ("/MM/QMI/Current-Capabilities/Gobi3k/GSM", test_gobi3k_gsm);
+ g_test_add_func ("/MM/QMI/Current-Capabilities/Gobi3k/CDMA", test_gobi3k_cdma);
+
+ return g_test_run ();
+}