The new version of MBIM-Proxy has problems after receiving NotOpened
The problem occurs in the following scenarios: When ubuntu goes to sleep, the 4g module is powered off. Ubuntu resume from sleep, 4g module is powered on. the 4g module receives the COMMAND MSG and replies NOT OPEND. Mbim-proxy does not continue sending OPEN_MSG after receiving NOT_OPEND. The older version is fine.
Dubug log:
<<<<<< RAW:
<<<<<< length = 48
<<<<<< data = 03:00:00:00:30:00:00:00:3F:00:00:00...
[16 Aug 2023, 21:42:47] [Debug] [/dev/cdc-wdm0] sent message (translated)...
<<<<<< Header:
<<<<<< length = 48
<<<<<< type = command (0x00000003)
<<<<<< transaction = 63
<<<<<< Fragment header:
<<<<<< total = 1
<<<<<< current = 0
<<<<<< Contents:
<<<<<< service = 'basic-connect' (a289cc33-bcbb-8b4f-b6b0-133ec2aae6df)
<<<<<< cid = 'device-caps' (0x00000001)
<<<<<< type = 'query' (0x00000000)
[16 Aug 2023, 21:42:48] [Debug] [/dev/cdc-wdm0] received message... RAW: length = 16 data = 04:00:00:80:10:00:00:00:3F:00:00:00...
[16 Aug 2023, 21:42:48] [Debug] [/dev/cdc-wdm0] received message (translated)...
Header:
length = 16
type = function-error (0x80000004)
transaction = 63
Contents:
error = 'NotOpened' (0x00000005)
[16 Aug 2023, 21:42:48] [Debug] [/dev/cdc-wdm0] device not-opened error reported, reopening
[16 Aug 2023, 21:42:48] [Debug] [/dev/cdc-wdm0] reseting client service subscribe lists...
[16 Aug 2023, 21:42:48] [Debug] [/dev/cdc-wdm0] channel destroyed
[16 Aug 2023, 21:42:48] [Debug] [/dev/cdc-wdm0] reports as being closed...
[16 Aug 2023, 21:42:48] [Debug] [/dev/cdc-wdm0] reseting client service subscribe lists...
[16 Aug 2023, 21:42:48] -Warning ** [client 28,0x00000001] cannot configure proxy: couldn't open MBIM device: Already open
[16 Aug 2023, 21:42:48] [Debug] [client 28] connection closed
[16 Aug 2023, 21:42:48] [Debug] [/dev/cdc-wdm0] untracking device...
I took a quick look at the libmim source code. And find the problem caused by modification point
0a119a7a. I made the following changes in the latest libmibm to solve the problem.
libmbim\src\libmbim-glibMbim-device.c
static void process_message (MbimDevice *self, const MbimMessage *message)
/* Signals are emitted regardless of whether the transaction matched or not;
-
and emitted after the task completion, because the listeners of this
-
signal may decide to force-close the device, which in turn clears the
-
internal buffer and the MbimMessage. */
--- g_signal_emit (self, signals[SIGNAL_ERROR], 0, error_indication);
return;
}
gboolean mbim_device_close_force (MbimDevice *self, GError **error) {
g_return_val_if_fail (MBIM_IS_DEVICE (self), FALSE);
+++ self->priv->open_status = OPEN_STATUS_CLOSED;
return destroy_iochannel (self, error);
}