novatel-lte: fallback to parent scan method

There is no need to run +COPS=? in the same way as the parent does it,
just fallback to the parent implementation.
This commit is contained in:
Aleksander Morgado
2019-12-18 10:51:59 +01:00
committed by Dan Williams
parent baa68f5a4a
commit a23040756b

View File

@@ -38,6 +38,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 MMIfaceModem3gpp *iface_modem_3gpp_parent;
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemNovatelLte, mm_broadband_modem_novatel_lte, MM_TYPE_BROADBAND_MODEM, 0, G_DEFINE_TYPE_EXTENDED (MMBroadbandModemNovatelLte, mm_broadband_modem_novatel_lte, 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));
@@ -571,31 +573,20 @@ scan_networks_finish (MMIfaceModem3gpp *self,
} }
static void static void
cops_query_ready (MMBroadbandModemNovatelLte *self, parent_scan_networks_ready (MMIfaceModem3gpp *self,
GAsyncResult *res, GAsyncResult *res,
GTask *task) GTask *task)
{ {
const gchar *response;
GError *error = NULL; GError *error = NULL;
GList *scan_result; GList *scan_result;
response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); scan_result = iface_modem_3gpp_parent->scan_networks_finish (self, res, &error);
if (error) { if (!scan_result)
g_task_return_error (task, error); g_task_return_error (task, error);
g_object_unref (task); else
return; g_task_return_pointer (task,
} scan_result,
(GDestroyNotify)mm_3gpp_network_info_list_free);
scan_result = mm_3gpp_parse_cops_test_response (response, &error);
if (error) {
g_task_return_error (task, error);
g_object_unref (task);
return;
}
g_task_return_pointer (task,
scan_result,
(GDestroyNotify)mm_3gpp_network_info_list_free);
g_object_unref (task); g_object_unref (task);
} }
@@ -611,11 +602,11 @@ scan_networks (MMIfaceModem3gpp *self,
task = g_task_new (self, NULL, callback, user_data); task = g_task_new (self, NULL, callback, user_data);
access_tech = mm_iface_modem_get_access_technologies (MM_IFACE_MODEM (self));
/* The Novatel LTE modem does not properly support AT+COPS=? in LTE mode. /* The Novatel LTE modem does not properly support AT+COPS=? in LTE mode.
* Thus, do not try to scan networks when the current access technologies * Thus, do not try to scan networks when the current access technologies
* include LTE. * include LTE.
*/ */
access_tech = mm_iface_modem_get_access_technologies (MM_IFACE_MODEM (self));
if (access_tech & MM_MODEM_ACCESS_TECHNOLOGY_LTE) { if (access_tech & MM_MODEM_ACCESS_TECHNOLOGY_LTE) {
gchar *access_tech_string; gchar *access_tech_string;
@@ -631,12 +622,10 @@ scan_networks (MMIfaceModem3gpp *self,
return; return;
} }
mm_base_modem_at_command (MM_BASE_MODEM (self), /* Otherwise, just fallback to the generic scan method */
"+COPS=?", iface_modem_3gpp_parent->scan_networks (self,
300, (GAsyncReadyCallback)parent_scan_networks_ready,
FALSE, task);
(GAsyncReadyCallback)cops_query_ready,
task);
} }
/*****************************************************************************/ /*****************************************************************************/
@@ -691,6 +680,8 @@ iface_modem_init (MMIfaceModem *iface)
static void static void
iface_modem_3gpp_init (MMIfaceModem3gpp *iface) iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
{ {
iface_modem_3gpp_parent = g_type_interface_peek_parent (iface);
iface->scan_networks = scan_networks; iface->scan_networks = scan_networks;
iface->scan_networks_finish = scan_networks_finish; iface->scan_networks_finish = scan_networks_finish;
} }