summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2022-06-30 00:58:26 +0200
committerAleksander Morgado <aleksander@aleksander.es>2022-06-30 11:15:04 +0200
commit1f2bea91849dffe424c4f779dd85b7fdf06af16c (patch)
treed1a7b1377b503dc5e9c5454f79780550ad14b5a9
parent7a3cbfec64808c6700f4354703a54a09e3e52c10 (diff)
downloadModemManager-1f2bea91849dffe424c4f779dd85b7fdf06af16c.tar.gz
port-mbim: monitor consecutive timeouts
-rw-r--r--configure.ac2
-rw-r--r--meson.build2
-rw-r--r--src/mm-port-mbim.c42
3 files changed, 44 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 2352f0b21..4027696a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -398,7 +398,7 @@ dnl-----------------------------------------------------------------------------
dnl MBIM support (enabled by default)
dnl
-LIBMBIM_VERSION=1.27.6
+LIBMBIM_VERSION=1.27.7
AC_ARG_WITH(mbim, AS_HELP_STRING([--without-mbim], [Build without MBIM support]), [], [with_mbim=yes])
AM_CONDITIONAL(WITH_MBIM, test "x$with_mbim" = "xyes")
diff --git a/meson.build b/meson.build
index 5ceebe454..c71b18c02 100644
--- a/meson.build
+++ b/meson.build
@@ -240,7 +240,7 @@ config_h.set('WITH_AT_COMMAND_VIA_DBUS', enable_at_command_via_dbus)
# MBIM support (enabled by default)
enable_mbim = get_option('mbim')
if enable_mbim
- mbim_glib_dep = dependency('mbim-glib', version: '>= 1.27.6')
+ mbim_glib_dep = dependency('mbim-glib', version: '>= 1.27.7')
endif
config_h.set('WITH_MBIM', enable_mbim)
diff --git a/src/mm-port-mbim.c b/src/mm-port-mbim.c
index d5aeddf04..5748c15c7 100644
--- a/src/mm-port-mbim.c
+++ b/src/mm-port-mbim.c
@@ -34,6 +34,10 @@ G_DEFINE_TYPE (MMPortMbim, mm_port_mbim, MM_TYPE_PORT)
struct _MMPortMbimPrivate {
gboolean in_progress;
MbimDevice *mbim_device;
+
+ /* timeout monitoring */
+ gulong timeout_monitoring_id;
+
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
gboolean qmi_supported;
QmiDevice *qmi_device;
@@ -387,6 +391,41 @@ mm_port_mbim_reset (MMPortMbim *self,
/*****************************************************************************/
+static void
+reset_timeout_monitoring (MMPortMbim *self,
+ MbimDevice *mbim_device)
+{
+ if (self->priv->timeout_monitoring_id && mbim_device) {
+ g_signal_handler_disconnect (mbim_device, self->priv->timeout_monitoring_id);
+ self->priv->timeout_monitoring_id = 0;
+ }
+}
+
+static void
+consecutive_timeouts_updated_cb (MMPortMbim *self,
+ GParamSpec *pspec,
+ MbimDevice *mbim_device)
+{
+ g_signal_emit_by_name (self, MM_PORT_SIGNAL_TIMED_OUT, mbim_device_get_consecutive_timeouts (mbim_device));
+}
+
+static void
+setup_timeout_monitoring (MMPortMbim *self,
+ MbimDevice *mbim_device)
+{
+ g_assert (mbim_device);
+
+ reset_timeout_monitoring (self, mbim_device);
+
+ g_assert (!self->priv->timeout_monitoring_id);
+ self->priv->timeout_monitoring_id = g_signal_connect_swapped (mbim_device,
+ "notify::" MBIM_DEVICE_CONSECUTIVE_TIMEOUTS,
+ G_CALLBACK (consecutive_timeouts_updated_cb),
+ self);
+}
+
+/*****************************************************************************/
+
gboolean
mm_port_mbim_open_finish (MMPortMbim *self,
GAsyncResult *res,
@@ -561,6 +600,7 @@ mbim_device_open_ready (MbimDevice *mbim_device,
}
mm_obj_dbg (self, "MBIM device is now open");
+ setup_timeout_monitoring (self, mbim_device);
#if defined WITH_QMI && QMI_MBIM_QMUX_SUPPORTED
if (self->priv->qmi_supported) {
@@ -699,6 +739,7 @@ mbim_device_close_ready (MbimDevice *mbim_device,
g_assert (!self->priv->mbim_device);
self->priv->in_progress = FALSE;
+ reset_timeout_monitoring (self, mbim_device);
if (!mbim_device_close_finish (mbim_device, res, &error))
g_task_return_error (task, error);
@@ -855,6 +896,7 @@ dispose (GObject *object)
#endif
/* Clear device object */
+ reset_timeout_monitoring (self, self->priv->mbim_device);
g_clear_object (&self->priv->mbim_device);
G_OBJECT_CLASS (mm_port_mbim_parent_class)->dispose (object);