[OpenWrt-Devel] umbim: add registration set support

Message ID 20190110145800.63138-2-feinerer@logic.at
State New
Headers show
Series
  • [OpenWrt-Devel] umbim: add registration set support
Related show

Commit Message

Ingo Feinerer Jan. 10, 2019, 2:58 p.m.
This implements the MBIM automatic registration mode to let the function
select the best provider network.

Signed-off-by: Ingo Feinerer <feinerer@logic.at>
---
 cli.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Bjørn Mork Feb. 14, 2019, 9:36 a.m. | #1
Ingo Feinerer <feinerer@logic.at> writes:

> anyone willing to review/commit this diff?
>
> http://lists.infradead.org/pipermail/openwrt-devel/2019-January/015445.html
> http://lists.infradead.org/pipermail/openwrt-devel/2019-January/015444.html


I assume John is very busy based on currently observed activity.  So you
may have to be patient...

The patch is registered in patchwork, so it's safely queued and will not
be lost: http://patchwork.ozlabs.org/patch/1022983/

FWIW, your patch looks good to me.  It could probably be improved with
actual argument parsing, maybe allowing setting MBIM_REGISTER_ACTION_MANUAL too.
But I see no reason why that can't be added in a later followup if/when
someone actually needs it.

My test modem (EM7455) defaults to auto, so there isn't much difference
in the result with and without your patch.  But just to display the SET
vs QUERY:


bjorn@miraculix:~$ umbim -v -d /dev/cdc-wdm0 -n -t 42 registration auto
sending (64): 03 00 00 00 40 00 00 00 2a 00 00 00 01 00 00 00 00 00 00 00 a2 89 cc 33 bc bb 8b 4f b6 b0 13 3e c2 aa e6 df 09 00 00 00 01 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  header_type: 0003
  header_length: 0040
  header_transaction: 002A
reading (124): 03 00 00 80 7c 00 00 00 2a 00 00 00 01 00 00 00 00 00 00 00 a2 89 cc 33 bc bb 8b 4f b6 b0 13 3e c2 aa e6 df 09 00 00 00 00 00 00 00 4c 00 00 00 00 00 00 00 03 00 00 00 01 00 00 00 20 00 00 00 01 00 00 00 30 00 00 00 0a 00 00 00 3c 00 00 00 0e 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 32 00 34 00 32 00 30 00 31 00 00 00 54 00 45 00 4c 00 45 00 4e 00 4f 00 52 00 00 00 
  header_type: 80000003
  header_length: 007C
  header_transaction: 002A
  command_id: 0009
  status_code: 0000
  nwerror: 0000 - unknown
  registerstate: 0003 - home
  registermode: 0001 - automatic
  availabledataclasses: 0020 - lte
  currentcellularclass: 0001 - gsm
  provider_id: 24201
  provider_name: TELENOR
  roamingtext: (null)

bjorn@miraculix:~$ umbim -v -d /dev/cdc-wdm0 -n -t 42 registration
sending (48): 03 00 00 00 30 00 00 00 2a 00 00 00 01 00 00 00 00 00 00 00 a2 89 cc 33 bc bb 8b 4f b6 b0 13 3e c2 aa e6 df 09 00 00 00 00 00 00 00 00 00 00 00 
  header_type: 0003
  header_length: 0030
  header_transaction: 002A
reading (124): 03 00 00 80 7c 00 00 00 2a 00 00 00 01 00 00 00 00 00 00 00 a2 89 cc 33 bc bb 8b 4f b6 b0 13 3e c2 aa e6 df 09 00 00 00 00 00 00 00 4c 00 00 00 00 00 00 00 03 00 00 00 01 00 00 00 20 00 00 00 01 00 00 00 30 00 00 00 0a 00 00 00 3c 00 00 00 0e 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 32 00 34 00 32 00 30 00 31 00 00 00 54 00 45 00 4c 00 45 00 4e 00 4f 00 52 00 00 00 
  header_type: 80000003
  header_length: 007C
  header_transaction: 002A
  command_id: 0009
  status_code: 0000
  nwerror: 0000 - unknown
  registerstate: 0003 - home
  registermode: 0001 - automatic
  availabledataclasses: 0020 - lte
  currentcellularclass: 0001 - gsm
  provider_id: 24201
  provider_name: TELENOR
  roamingtext: (null)


Don't know if the OpenWrt patchworks collects these, but in case it does:

Reviewed-by: Bjørn Mork <bjorn@mork.no>



Bjørn

Patch

diff --git a/cli.c b/cli.c
index 1dd6330..e00b6d4 100644
--- a/cli.c
+++ b/cli.c
@@ -297,7 +297,16 @@  mbim_pin_state_request(void)
 static int
 mbim_registration_request(void)
 {
-	mbim_setup_command_msg(basic_connect, MBIM_MESSAGE_COMMAND_TYPE_QUERY, MBIM_CMD_BASIC_CONNECT_REGISTER_STATE, 0);
+	if (_argc > 0) {
+		struct mbim_basic_connect_register_state_s *rs =
+			(struct mbim_basic_connect_register_state_s *) mbim_setup_command_msg(basic_connect,
+					MBIM_MESSAGE_COMMAND_TYPE_SET, MBIM_CMD_BASIC_CONNECT_REGISTER_STATE,
+					sizeof(struct mbim_basic_connect_register_state_s));
+
+		rs->registeraction = htole32(MBIM_REGISTER_ACTION_AUTOMATIC);
+	} else {
+		mbim_setup_command_msg(basic_connect, MBIM_MESSAGE_COMMAND_TYPE_QUERY, MBIM_CMD_BASIC_CONNECT_REGISTER_STATE, 0);
+	}
 
 	return mbim_send_command_msg();
 }