[PATCH] umbim: Add mbim message timeout option, -T

Eric evil.function at proton.me
Wed Jul 5 08:03:23 PDT 2023


On Wednesday, July 5th, 2023 at 06:08, Daniel Danzberger <daniel at dd-wrt.com> wrote:
> Some modems, depending on their state and connection quality can take
> longer than 15 seconds to answer mbim message requests.
> 
> This commit adds the -T option, allowing the user to specifiy a custom
> message timeout in seconds.
> 
> Default is still 15.
> 
> Signed-off-by: Daniel Danzberger daniel at dd-wrt.com
> 
> ---
> cli.c | 9 +++++++--
> mbim-dev.c | 2 +-
> mbim.h | 1 +
> 3 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/cli.c b/cli.c
> index 3a845d4..b23fc6d 100644
> --- a/cli.c
> +++ b/cli.c
> @@ -35,6 +35,7 @@
> 
> int return_code = -1;
> int verbose;
> +int msg_timeout_ms = 15 * 1000;
> 
> struct mbim_handler *current_handler;
> static uint8_t uuid_context_type_internet[16] = { 0x7E, 0x5E, 0x2A, 0x7E, 0x4E, 0x6F, 0x72, 0x72, 0x73, 0x6B, 0x65, 0x6E, 0x7E, 0x5E, 0x2A, 0x7E };
> @@ -533,7 +534,8 @@ usage(void)
> #endif
> " -d <device> the device (/dev/cdc-wdmX)\n"
> 
> " -t <transaction> the transaction id\n"
> 
> - " -n no close\n\n"
> + " -n no close\n"
> + " -T MBIM message timeout in seconds [15]\n\n"

Shouldn't the usage indicate explicitly that it takes a parameter, as do -d and -t?

   " -T <seconds>    MBIM message timeout...

> " -v verbose\n\n");
> return 1;
> }
> @@ -548,7 +550,7 @@ main(int argc, char **argv)
> int proxy = 0;
> #endif
> 
> - while ((ch = getopt(argc, argv, "pnvd:t:")) != -1) {
> + while ((ch = getopt(argc, argv, "pnvd:t:T:")) != -1) {
> switch (ch) {
> case 'v':
> verbose = 1;
> @@ -563,6 +565,9 @@ main(int argc, char **argv)
> no_open = 1;
> transaction_id = atoi(optarg);
> break;
> + case 'T':
> + msg_timeout_ms = atoi(optarg) * 1000;
> + break;
> #ifdef LIBQMI_MBIM_PROXY
> case 'p':
> proxy = 1;
> diff --git a/mbim-dev.c b/mbim-dev.c
> index 2a94d49..12d1189 100644
> --- a/mbim-dev.c
> +++ b/mbim-dev.c
> @@ -78,7 +78,7 @@ mbim_send(void)
> perror("writing data failed: ");
> } else {
> expected = le32toh(hdr->type) | 0x80000000;
> 
> - uloop_timeout_set(&tout, 15000);
> + uloop_timeout_set(&tout, msg_timeout_ms);
> }
> return ret;
> }
> diff --git a/mbim.h b/mbim.h
> index 746257e..28999b5 100644
> --- a/mbim.h
> +++ b/mbim.h
> @@ -20,6 +20,7 @@
> 
> extern int return_code;
> extern int verbose;
> +extern int msg_timeout_ms;
> 
> #include "mbim-type.h"
> #include "mbim-enum.h"
> --
> 2.40.1




More information about the openwrt-devel mailing list