plugin: telit: add supported modes loading
This patch add supported modes loading in Telit plugin.
This commit is contained in:

committed by
Dan Williams

parent
aeb6362172
commit
85e6c5b915
@@ -36,6 +36,8 @@
|
|||||||
static void iface_modem_init (MMIfaceModem *iface);
|
static void iface_modem_init (MMIfaceModem *iface);
|
||||||
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
|
static void iface_modem_3gpp_init (MMIfaceModem3gpp *iface);
|
||||||
|
|
||||||
|
static MMIfaceModem *iface_modem_parent;
|
||||||
|
|
||||||
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemTelit, mm_broadband_modem_telit, MM_TYPE_BROADBAND_MODEM, 0,
|
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemTelit, mm_broadband_modem_telit, MM_TYPE_BROADBAND_MODEM, 0,
|
||||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
|
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
|
||||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init));
|
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_3GPP, iface_modem_3gpp_init));
|
||||||
@@ -535,6 +537,104 @@ setup_flow_control (MMIfaceModem *self,
|
|||||||
g_free (cmd);
|
g_free (cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Load supported modes (Modem interface) */
|
||||||
|
|
||||||
|
static GArray *
|
||||||
|
load_supported_modes_finish (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return g_array_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
parent_load_supported_modes_ready (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GSimpleAsyncResult *simple)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
GArray *all;
|
||||||
|
GArray *combinations;
|
||||||
|
GArray *filtered;
|
||||||
|
MMModemModeCombination mode;
|
||||||
|
|
||||||
|
all = iface_modem_parent->load_supported_modes_finish (self, res, &error);
|
||||||
|
if (!all) {
|
||||||
|
g_simple_async_result_take_error (simple, error);
|
||||||
|
g_simple_async_result_complete (simple);
|
||||||
|
g_object_unref (simple);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* CDMA-only modems don't support changing modes, default to parent's */
|
||||||
|
if (!mm_iface_modem_is_3gpp (self)) {
|
||||||
|
g_simple_async_result_set_op_res_gpointer (simple, all, (GDestroyNotify) g_array_unref);
|
||||||
|
g_simple_async_result_complete_in_idle (simple);
|
||||||
|
g_object_unref (simple);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Build list of combinations for 3GPP devices */
|
||||||
|
combinations = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), 7);
|
||||||
|
|
||||||
|
/* 2G only */
|
||||||
|
mode.allowed = MM_MODEM_MODE_2G;
|
||||||
|
mode.preferred = MM_MODEM_MODE_NONE;
|
||||||
|
g_array_append_val (combinations, mode);
|
||||||
|
/* 3G only */
|
||||||
|
mode.allowed = MM_MODEM_MODE_3G;
|
||||||
|
mode.preferred = MM_MODEM_MODE_NONE;
|
||||||
|
g_array_append_val (combinations, mode);
|
||||||
|
/* 2G and 3G */
|
||||||
|
mode.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G);
|
||||||
|
mode.preferred = MM_MODEM_MODE_NONE;
|
||||||
|
g_array_append_val (combinations, mode);
|
||||||
|
/* 4G only */
|
||||||
|
mode.allowed = MM_MODEM_MODE_4G;
|
||||||
|
mode.preferred = MM_MODEM_MODE_NONE;
|
||||||
|
g_array_append_val (combinations, mode);
|
||||||
|
/* 2G and 4G */
|
||||||
|
mode.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_4G);
|
||||||
|
mode.preferred = MM_MODEM_MODE_NONE;
|
||||||
|
g_array_append_val (combinations, mode);
|
||||||
|
/* 3G and 4G */
|
||||||
|
mode.allowed = (MM_MODEM_MODE_3G | MM_MODEM_MODE_4G);
|
||||||
|
mode.preferred = MM_MODEM_MODE_NONE;
|
||||||
|
g_array_append_val (combinations, mode);
|
||||||
|
/* 2G, 3G and 4G */
|
||||||
|
mode.allowed = (MM_MODEM_MODE_2G | MM_MODEM_MODE_3G | MM_MODEM_MODE_4G);
|
||||||
|
mode.preferred = MM_MODEM_MODE_NONE;
|
||||||
|
g_array_append_val (combinations, mode);
|
||||||
|
|
||||||
|
/* Filter out those unsupported modes */
|
||||||
|
filtered = mm_filter_supported_modes (all, combinations);
|
||||||
|
g_array_unref (all);
|
||||||
|
g_array_unref (combinations);
|
||||||
|
|
||||||
|
g_simple_async_result_set_op_res_gpointer (simple, filtered, (GDestroyNotify) g_array_unref);
|
||||||
|
g_simple_async_result_complete (simple);
|
||||||
|
g_object_unref (simple);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
load_supported_modes (MMIfaceModem *self,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
/* Run parent's loading */
|
||||||
|
iface_modem_parent->load_supported_modes (
|
||||||
|
MM_IFACE_MODEM (self),
|
||||||
|
(GAsyncReadyCallback)parent_load_supported_modes_ready,
|
||||||
|
g_simple_async_result_new (G_OBJECT (self),
|
||||||
|
callback,
|
||||||
|
user_data,
|
||||||
|
load_supported_modes));
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Enabling unsolicited events (3GPP interface) */
|
/* Enabling unsolicited events (3GPP interface) */
|
||||||
|
|
||||||
@@ -601,6 +701,8 @@ mm_broadband_modem_telit_init (MMBroadbandModemTelit *self)
|
|||||||
static void
|
static void
|
||||||
iface_modem_init (MMIfaceModem *iface)
|
iface_modem_init (MMIfaceModem *iface)
|
||||||
{
|
{
|
||||||
|
iface_modem_parent = g_type_interface_peek_parent (iface);
|
||||||
|
|
||||||
iface->load_supported_bands = modem_load_supported_bands;
|
iface->load_supported_bands = modem_load_supported_bands;
|
||||||
iface->load_supported_bands_finish = modem_load_supported_bands_finish;
|
iface->load_supported_bands_finish = modem_load_supported_bands_finish;
|
||||||
iface->load_unlock_retries_finish = modem_load_unlock_retries_finish;
|
iface->load_unlock_retries_finish = modem_load_unlock_retries_finish;
|
||||||
@@ -613,6 +715,8 @@ iface_modem_init (MMIfaceModem *iface)
|
|||||||
iface->load_access_technologies_finish = load_access_technologies_finish;
|
iface->load_access_technologies_finish = load_access_technologies_finish;
|
||||||
iface->setup_flow_control = setup_flow_control;
|
iface->setup_flow_control = setup_flow_control;
|
||||||
iface->setup_flow_control_finish = setup_flow_control_finish;
|
iface->setup_flow_control_finish = setup_flow_control_finish;
|
||||||
|
iface->load_supported_modes = load_supported_modes;
|
||||||
|
iface->load_supported_modes_finish = load_supported_modes_finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user