From 3c8595a4e75510f58fa231b145d5506768dcafc9 Mon Sep 17 00:00:00 2001 From: Henrik Ginstmark Date: Mon, 7 Feb 2022 22:30:40 +0100 Subject: [PATCH] usbmode: add config #0 and delay before actual config MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit I have a Huawei ME909s-120. When I switch directly from configuration to go via configuration #0, and a short delay, and then to configuration well. So in order to fix it, add config #0 and a 100milliseconds delay before switching to actual config, like in USB_ModeSwitch. References: https://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=4&t=2710&sid=505ed44b4064fef7009f0c26aac085e2&start=15 Signed-off-by: Henrik Ginstmark Signed-off-by: Petr Å tetiar [rebased, commit description facelift] --- switch.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/switch.c b/switch.c index cc04237..6285c7c 100644 --- a/switch.c +++ b/switch.c @@ -520,8 +520,11 @@ void handle_switch(struct usbdev_data *data) config_new = blobmsg_get_u32(tb[DATA_CONFIG]); if (libusb_get_configuration(data->devh, &config) || - config != config_new) + config != config_new) { + libusb_set_configuration(data->devh, 0); + usleep(100000); libusb_set_configuration(data->devh, config_new); + } } if (tb[DATA_ALT]) { -- 2.30.2