Huawei E3533 USB modem dongle usbmode switch

Hi,

Just to document how to switch the Huawei E3533 modem from the default NCM mode (which is running NAT) to direct mode, since it took quite a while to get it working correctly.
https://openwrt.org/docs/guide-user/network/wan/wwan/3gdongle

First the packages required are...
For modem mode (direct mode)

opkg update
opkg install comgt kmod-usb-serial kmod-usb-serial-option kmod-usb-serial-wwan usb-modeswitch

For RNDIS/NCM mode (with NAT)

opkg update
opkg install comgt-ncm kmod-usb-net-huawei-cdc-ncm usb-modeswitch

The modem bootup with the VID:PID of 12d1:157d. The default usbmode switch configuration will switch the modem to NCM mode 12d1:14db with the following usbmode switch configuration file.

/etc/usb-mode.json

		"12d1:157d": {
			"*": {
				"t_vendor": 4817,
				"t_product": [ 5339, 5340 ],
				"mode": "HuaweiNew",
				"msg": [ ]
			}
		},

USB diagnostics (from usbutils) should show the following in RNDIS/NCM (NAT mode).

root@gateway:~# lsusb
Bus 001 Device 004: ID 12d1:14db Huawei Technologies Co., Ltd. E353/E3131
Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@gateway:~# lsusb -tv
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 2: Dev 4, If 0, Class=Communications, Driver=cdc_ether, 480M
        |__ Port 2: Dev 4, If 1, Class=CDC Data, Driver=cdc_ether, 480M

To switch it to modem mode (direct mode), we must change to use the modeswitch message (by adding a new one to the end of the list, and directing the usbmode to refer to the new message (array index of 59) in the following example. The modem will be switched to VID:PID of 12d1:1001.

{
	"messages" : [
		...
		"55534243123456780000000000000011063000000100010000000000000000"
	],

	"devices" : {
		...
		"12d1:157d": {
			"*": {
				"t_vendor": 4817,
				"t_product": [ 5339, 5340 ],
				"msg": [ 59 ]
			}
		},
		...

USB diagnostics (from usbutils) should show the following.

root@gateway:~# lsusb
Bus 001 Device 004: ID 12d1:1001 Huawei Technologies Co., Ltd. E161/E169/E620/E800 HSDPA Modem
Bus 001 Device 002: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@gateway:~# lsusb -tv
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-platform/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 2: Dev 4, If 0, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 2: Dev 4, If 1, Class=Vendor Specific Class, Driver=option, 480M
        |__ Port 2: Dev 4, If 2, Class=Vendor Specific Class, Driver=option, 480M