diff options
author | SunXinzhao <king.sun@fibocom.com> | 2022-11-02 17:18:19 +0800 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2022-11-15 19:43:55 +0000 |
commit | b758c5703077adc37c77bd8cc6bdeb5ce913235d (patch) | |
tree | e8a96ddb687c001ef05a2bd1664dcda9a8654968 /src | |
parent | be6392c7453d729917291aa346510e172419f235 (diff) |
broadband-modem-mbim: add AT based fallback to load model name
Modify the load_model function to use the AT command to get the
model name and display the module name in the model instead of
[vid:pid].
Test on L860 Linux Device, use `mmcli -L`, it can show: "/org/free
desktop/ModemManager1/Modem/0 [Intel] L860-GL-16 LTE Module"
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-broadband-modem-mbim.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/mm-broadband-modem-mbim.c b/src/mm-broadband-modem-mbim.c index c4358101..2af2f2eb 100644 --- a/src/mm-broadband-modem-mbim.c +++ b/src/mm-broadband-modem-mbim.c @@ -65,6 +65,7 @@ static void shared_qmi_init (MMSharedQmi static MMIfaceModemLocation *iface_modem_location_parent; #endif static MMIfaceModemSignal *iface_modem_signal_parent; +static MMIfaceModem *iface_modem_parent; G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbim, mm_broadband_modem_mbim, MM_TYPE_BROADBAND_MODEM, 0, G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init) @@ -817,12 +818,31 @@ qmi_load_model_ready (MMIfaceModem *self, #endif static void +at_load_model_ready (MMIfaceModem *self, + GAsyncResult *res, + GTask *task) +{ + gchar *model = NULL; + GError *error = NULL; + + model = iface_modem_parent->load_model_finish (self, res, &error); + if (!model) { + mm_obj_dbg (self, "couldn't load model using AT: %s", error->message); + model = modem_load_model_default (self); + g_clear_error (&error); + } + + g_task_return_pointer (task, model, g_free); + g_object_unref (task); +} + +static void modem_load_model (MMIfaceModem *self, GAsyncReadyCallback callback, gpointer user_data) { - gchar *model = NULL; - GTask *task; + gchar *model = NULL; + GTask *task; MMPortMbim *port; task = g_task_new (self, NULL, callback, user_data); @@ -831,6 +851,11 @@ modem_load_model (MMIfaceModem *self, if (port) { model = g_strdup (mm_kernel_device_get_physdev_product ( mm_port_peek_kernel_device (MM_PORT (port)))); + if (model) { + g_task_return_pointer (task, model, g_free); + g_object_unref (task); + return; + } } #if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED @@ -840,11 +865,7 @@ modem_load_model (MMIfaceModem *self, } #endif - if (!model) - model = modem_load_model_default (self); - - g_task_return_pointer (task, model, g_free); - g_object_unref (task); + iface_modem_parent->load_model (self, (GAsyncReadyCallback)at_load_model_ready, task); } /*****************************************************************************/ @@ -9238,6 +9259,7 @@ finalize (GObject *object) static void iface_modem_init (MMIfaceModem *iface) { + iface_modem_parent = g_type_interface_peek_parent (iface); /* Initialization steps */ iface->load_supported_capabilities = modem_load_supported_capabilities; iface->load_supported_capabilities_finish = modem_load_supported_capabilities_finish; |