User Tools

Site Tools


doc:recipes:ltedongle

How To use LTE modem in QMI mode for WAN connection

Some new 3G/4G dongles use qmi and mbim protocol to establish connection to ISP. For your information, qmi protocol is proprietary protocol by Qualcomm. In contrast to qmi, mbim is more standardized protocol for 3G/4G dongles.

This recipe explains how to setup and configure OpenWrt for using a USB LTE/3g/UMTS-modem for WAN connection, using QMI interface. You may want to checkout the Multiwan package to use this simultaneously with other connections to the internet.

:!: All recent information is valid for Barrier Breaker release and later. Not tested on AA or elder.

About

Many modern USB dongles could perform in different ways. If your modem provides only AT command interface - please refer to How to use 3g/UMTS USB Dongle for WAN connection. For more information about different protocols used:

If it is possible to switch your modem to provide NDIS interface - then this article if for YOU.

FIXME Add Speed and Performance test results on Modem mode and QMI mode.

:!: 8-) Subjective, solution based on NDIS (QMI mode) works much stable. Faster reconnect. Easy to control and monitor.

Modem Preparation

You need to switch modem to provide native NDIS interface instead of Modem interface.

:!: Please read about AT commands for your modem.

Once you've done - you can disconnect modem from the PC and connect it to the router.

Router Preparation

1. Install OpenWRT

2. Complete Steps OpenWrt Configuration

Router should be turned on and connected to the Internet to get the needed packages. Please refer to: Internet Connection.

Required Packages

To make use of qmi protocol, package kmod-usb-net-qmi-wwan and uqmi are needed. uqmi is available on both barrier breaker and bleeding edge repository.

  • usb-modeswitch - It will automatically issue a "special" command to the modem for switching it into the "Working" state
  • kmod-mii - Mii driver
  • kmod-usb-net - USB to Ethernet
  • kmod-usb-wdm
  • kmod-usb-net-qmi-wwan
  • uqmi - Control utility

opkg update
opkg install usb-modeswitch kmod-mii kmod-usb-net kmod-usb-wdm kmod-usb-net-qmi-wwan uqmi

Optional Packages

1. Add support for MBIM devices

  • kmod-usb-net-cdc-mbim Kernel module for MBIM Devices
  • umbim MBIM modem utility

opkg update
opkg install kmod-usb-net-cdc-mbim umbim

2. Add support for PC Interface (ttyUSB0)

  • kmod-usb-serial-option
  • kmod-usb-serial
  • kmod-usb-serial-wwan

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

3. Add support for FlashCard of your dongle - refer to: USB Storage

Installation

1. Install all the needed packages

opkg update
opkg install usb-modeswitch kmod-mii kmod-usb-net kmod-usb-wdm kmod-usb-net-qmi-wwan uqmi

:!: If your have not enough space on your device - think of installing Rootfs on External Storage (extroot)

:!: Another option is Hardware memory upgrade. Refer to your router Forum thread for possibility and instructions.

2. Reboot the router

reboot

3. Check that everything is OK and You got new device:

ls -l /dev/cdc-wdm0

crw-r--r--    1 root     root      180, 176 Oct  1 12:03 /dev/cdc-wdm0

If you have no such device - try to find out what went wrong:

try dmesg to read kernel logs on USB init

dmesg
or look info about USB devices and interfaces present in the system:
cat /sys/kernel/debug/usb/devices

T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  3 Spd=480  MxCh= 0
D:  Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
P:  Vendor=12d1 ProdID=1506 Rev= 0.00
S:  Manufacturer=Huawei Technologies
S:  Product=HUAWEI Mobile
C:* #Ifs= 3 Cfg#= 1 Atr=c0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=02 Driver=option
E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
I:* If#= 1 Alt= 0 #EPs= 1 Cls=ff(vend.) Sub=01 Prot=09 Driver=qmi_wwan
E:  Ad=82(I) Atr=03(Int.) MxPS=  64 Ivl=2ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=01 Prot=08 Driver=qmi_wwan
E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms

See Troubleshooting Section of this page for more information.

Configuration

Easiest way to configure your modem (if you are using the trunk version of OpenWRT)

Install the package luci-proto-qmi using Luci (System → Software) and configure the modem using Luci too (Network → Interfaces).

QMI Protocol Configuration

UCI is supporting qmi network protocol configuration. The detailed explanation about qmi network configuration is explained here.

You can configure UCI manually using uci command line or text editor or with Luci package luci-proto-qmi.

Here is a brief help about uqmi command line usage.

No device given
Usage: uqmi <options|actions>
Options:
  --single, -s:                     Print output as a single line (for scripts)
  --device=NAME, -d NAME:           Set device name to NAME (required)
  --keep-client-id <name>:          Keep Client ID for service <name>
  --release-client-id <name>:       Release Client ID after exiting
 
Services:                           dms, nas, pds, wds, wms
 
Actions:
  --get-versions:                   Get service versions
  --set-client-id <name>,<id>:      Set Client ID for service <name> to <id>
                                    (implies --keep-client-id)
  --get-client-id <name>:           Connect and get Client ID for service <name>
                                    (implies --keep-client-id)
  --start-network <apn>:            Start network connection (use with options below)
    --auth-type pap|chap|both|none: Use network authentication type
    --username <name>:              Use network username
    --password <password>:          Use network password
    --autoconnect:                  Enable automatic connect/reconnect
  --stop-network <pdh>:             Stop network connection (PDH should be 4294967295), (use with option below)
    --autoconnect:                  Disable automatic connect/reconnect
  --get-data-status:                Get current data access status
  --set-autoconnect <val>:          Get current data access status (disabled, enabled, paused)
  --get-pin-status:                 Get PIN verification status
  --verify-pin1 <pin>:              Verify PIN1
  --verify-pin2 <pin>:              Verify PIN2
  --get-imsi:                       Get International Mobile Subscriber ID
  --reset-dms:                      Reset the DMS service
  --set-device-operating-mode <m>   Set the device operating mode
                                    (modes: online, low_power, factory_test, offline
                                     reset, shutting_down, persistent_low_power,
                                     mode_only_low_power)
  --set-network-modes <modes>:      Set usable network modes (Syntax: <mode1>[,<mode2>,...])
                                    Available modes: all, lte, umts, gsm, cdma, td-scdma
  --set-network-preference <mode>:  Set preferred network mode to <mode>
                                    Available modes: auto, gsm, wcdma
  --set-network-roaming <mode>:     Set roaming preference:
                                    Available modes: any, off, only
  --network-scan:                   Initiate network scan
  --network-register:               Initiate network register
  --get-signal-info:                Get signal strength info
  --get-serving-system:             Get serving system info
  --list-messages:                  List SMS messages
  --get-message <id>:               Get SMS message at index <id>
  --get-raw-message <id>:           Get SMS raw message contents at index <id>
  --send-message <data>:            Send SMS message (use options below)
    --send-message-smsc <nr>:       SMSC number (required)
    --send-message-target <nr>:     Destination number (required)
    --send-message-flash:           Send as Flash SMS

MBIM Protocol configuration

Currently, there is not enough information about mbim protocol as it's being actively developed. If you are curious about setting up mbim protocol, you may ask OpenWrt users/devel mailing lists or OpenWrt forum

Here is a brief help about umbim command line.

umbim help
Usage: mbim <caps|pinstate|unlock|connect|disconnect> [options]
Options:
    -d <device>         the device (/dev/cdc-wdmX)
    -t <transaction>    the transaction id
    -n                  no close
    -v                  verbose

Interface configuration

First check that everything works correctly:

root@OpenWrt:~# uqmi -d /dev/cdc-wdm0 --get-data-status
"disconnected"
and
root@OpenWrt:~# uqmi -d /dev/cdc-wdm0 --get-signal-info
{
        "type": "lte",
        "rssi": -71,
        "rsrq": -9,
        "rsrp": -94,
        "snr": 70
}
To start the internet connection - issue a command:
uqmi -d /dev/cdc-wdm0 --start-network internet --autoconnect
Where "internet" is the APN of your provider.

:!: Many providers allow to use "any" APN, so-called "no-settings" connection. So, in many cases "internet" would be just fine

Check the status:

uqmi -d /dev/cdc-wdm0 --get-data-status
"connected"

–autoconnect key says that you want always be connected, once dongle is inserted to the router and Cellular Network is in range. :!: It will be kept after reboot.

In case you need additional authentication, please look at the possible arguments for the uqmi utility:

  --start-network <apn>:            Start network connection (use with options below)
    --auth-type pap|chap|both|none: Use network authentication type
    --username <name>:              Use network username
    --password <password>:          Use network password
    --autoconnect:                  Enable automatic connect/reconnect
  --stop-network <pdh>:             Stop network connection (use with option below)
    --autoconnect:                  Disable automatic connect/reconnect

Network configuration

Now you should add new Interface to /etc/config/network

config interface 'wwan'
        option ifname 'wwan0'
        option proto 'dhcp'
You can do this using the vi text editor, but if you're not comfortable with that, point your browser to 192.168.1.1 again, choose Network → Interfaces and click Add new interface.

Write wwan as the name of the interface and make it cover the wwan0 interface. Choose DHCP client as the protocol.

FIXME Insert a screenshot of LUCI add Interface. I have not enought rights.

Firewall configuration

The only thing that is left - Add wwan interface to WAN zone

Using LUCI:

  • go to Network → Firewall, scroll down to wan and click the Edit button
  • add a checkmark to the wwan box under Covered networks heading, click Save & Apply

:-D That's It! 8-)

FIXME Insert a Screen Shot from LUCI.

Additional Info

Some providers of the cellular internet use redirection to their pages for access activation, when you are connected first time. I.e. YOTA in Russia.

Normally this would be blocked by dnsmasq:

Jan 18 14:36:49 OpenWrt daemon.warn dnsmasq[1325]: possible DNS-rebind attack detected: my.yota.ru

You have 2 options:

  • Allow rebind responses RFC1918 (In LUCI goto NetworkDHCP and DNS and uncheck Rebind protection checkmark)
  • Add Yota.ru domain to Whitelist (In LUCI goto NetworkDHCP and DNS and type in "yota.ru" without quotes to the Domain whitelist field.

Save & apply

Notes

Based on: This Article

Troubleshooting

Everything is okay but modem doesn't establish connection. What can I try?

You may want to try adding the argument –get-client-id wds when running uqmi like:

uqmi -d /dev/cdc-wdm0 --get-client-id wds --start-network your_apn

My router is not detecting the dongle. What should I do?

Try the following commands:

usbmode -l
It should respond with a message about your USB device is detected. If it does, issue the next command. If it doesn't, you might want to get help from the forum.
usbmode -s
Then wait for the dongle to get issued an IP from your ISP.

I have to issue usbmode -l and usbmode -s every time I reboot my router to detect my USB device. How can I automate it?

Include the following codes into /etc/rc.local just before exit 0:

/sbin/usbmode -l
/bin/sleep 2
/sbin/usbmode -s

doc/recipes/ltedongle.txt · Last modified: 2017/05/26 15:58 by Jalakas