telit: prefer qmi for load_supported_bands if available
This commit is contained in:
@@ -33,6 +33,8 @@
|
||||
static void iface_modem_init (MMIfaceModem *iface);
|
||||
static void shared_telit_init (MMSharedTelit *iface);
|
||||
|
||||
static MMIfaceModem *iface_modem_parent;
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimTelit, mm_broadband_modem_mbim_telit, MM_TYPE_BROADBAND_MODEM_MBIM, 0,
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_SHARED_TELIT, shared_telit_init))
|
||||
@@ -156,6 +158,8 @@ mm_broadband_modem_mbim_telit_init (MMBroadbandModemMbimTelit *self)
|
||||
static void
|
||||
iface_modem_init (MMIfaceModem *iface)
|
||||
{
|
||||
iface_modem_parent = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->set_current_bands = mm_shared_telit_modem_set_current_bands;
|
||||
iface->set_current_bands_finish = mm_shared_telit_modem_set_current_bands_finish;
|
||||
iface->load_current_bands = mm_shared_telit_modem_load_current_bands;
|
||||
@@ -170,9 +174,16 @@ iface_modem_init (MMIfaceModem *iface)
|
||||
iface->set_current_modes_finish = mm_shared_telit_set_current_modes_finish;
|
||||
}
|
||||
|
||||
static MMIfaceModem *
|
||||
peek_parent_modem_interface (MMSharedTelit *self)
|
||||
{
|
||||
return iface_modem_parent;
|
||||
}
|
||||
|
||||
static void
|
||||
shared_telit_init (MMSharedTelit *iface)
|
||||
{
|
||||
iface->peek_parent_modem_interface = peek_parent_modem_interface;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -38,9 +38,10 @@
|
||||
static GQuark private_quark;
|
||||
|
||||
typedef struct {
|
||||
gboolean alternate_3g_bands;
|
||||
gboolean ext_4g_bands;
|
||||
GArray *supported_bands;
|
||||
MMIfaceModem *iface_modem_parent;
|
||||
gboolean alternate_3g_bands;
|
||||
gboolean ext_4g_bands;
|
||||
GArray *supported_bands;
|
||||
} Private;
|
||||
|
||||
static void
|
||||
@@ -82,6 +83,10 @@ get_private (MMSharedTelit *self)
|
||||
priv = g_slice_new0 (Private);
|
||||
initialize_alternate_3g_band (self, priv);
|
||||
/* ext_4g_bands field is initialized inside #BND=? response handler */
|
||||
|
||||
if (MM_SHARED_TELIT_GET_INTERFACE (self)->peek_parent_modem_interface)
|
||||
priv->iface_modem_parent = MM_SHARED_TELIT_GET_INTERFACE (self)->peek_parent_modem_interface (self);
|
||||
|
||||
g_object_set_qdata_full (G_OBJECT (self), private_quark, priv, (GDestroyNotify)private_free);
|
||||
}
|
||||
|
||||
@@ -218,17 +223,59 @@ mm_shared_telit_load_supported_bands_ready (MMBaseModem *self,
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
void
|
||||
mm_shared_telit_modem_load_supported_bands (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
static void
|
||||
load_supported_bands_at (MMIfaceModem *self,
|
||||
GTask *task)
|
||||
{
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
"#BND=?",
|
||||
3,
|
||||
TRUE,
|
||||
(GAsyncReadyCallback) mm_shared_telit_load_supported_bands_ready,
|
||||
g_task_new (self, NULL, callback, user_data));
|
||||
task);
|
||||
}
|
||||
|
||||
static void
|
||||
mm_shared_parent_load_supported_bands_ready (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GArray *bands;
|
||||
GError *error = NULL;
|
||||
Private *priv;
|
||||
|
||||
priv = get_private (MM_SHARED_TELIT (self));
|
||||
|
||||
bands = priv->iface_modem_parent->load_supported_bands_finish (MM_IFACE_MODEM (self), res, &error);
|
||||
if (bands) {
|
||||
g_task_return_pointer (task, bands, (GDestroyNotify)g_array_unref);
|
||||
g_object_unref (task);
|
||||
} else {
|
||||
mm_obj_dbg (self, "parent load supported bands failure, falling back to AT commands");
|
||||
load_supported_bands_at (self, task);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
mm_shared_telit_modem_load_supported_bands (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
Private *priv;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
priv = get_private (MM_SHARED_TELIT (self));
|
||||
|
||||
if (priv->iface_modem_parent &&
|
||||
priv->iface_modem_parent->load_supported_bands &&
|
||||
priv->iface_modem_parent->load_supported_bands_finish) {
|
||||
priv->iface_modem_parent->load_supported_bands (self,
|
||||
(GAsyncReadyCallback) mm_shared_parent_load_supported_bands_ready,
|
||||
task);
|
||||
} else
|
||||
load_supported_bands_at (self, task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
Reference in New Issue
Block a user