mPCiE Modem QMI Interface Internet Connection Setup #1

The new generation of LTE mPCIE modems provide both HSDPA/3G and LTE/4G wireless connectivity, these modems by default use the newer QMI interface as the primary connection method, as opposed to PPP over serial or Direct IP as with earlier modems in the range, and are currently best supported by Raspbian Jessie OS or above as this has support for the libqmi interface tools.

In this example we'll use a Sierra Wireless MC7304 modem and start by installing the udev rule (20-modem-7304.rules) in /etc/udev/rules.d from the modem rule pack. This sets up shortcut references to allow us to consistently identify which of the ttyUSBx ports do which functions

Whilst some LTE modems still provide a legacy serial port for PPP style connection modem control is optimally done through the /dev/cdc-wdm0 QMI interface so we need to install the software support packages via the command below:

apt-get install libqmi-utils

This installs two main utilities (qmi-cli tool and qmi-network helper script) these are used for interaction with the modem (see man qmi-cli for more details)

The APN setting is set by creating and then adding a line to /etc/qmi-network.conf - Consult your carrier for the correct APN name and insert it into the configuration file as shown below :

echo "APN=internet" >/etc/qmi-network.conf

I found the the next step provided easier control over the modem and routing by first removing the extra unused network ports, but this is optional. :

MyPi Industrial Raspberry Pi Sierra Wireless MC7304 3G Modem QMI Internet Connection Configuration Step 1

at!entercnd="A710"

AT!UDUSBCOMP=6

at!reset 

Next we have to check/reconfigure the modems data link format method to 802-3

MyPi Industrial Raspberry Pi Sierra Wireless MC7304 3G Modem QMI Internet Connection Configuration Step 2

qmicli -d /dev/cdc-wdm0 --wda-get-data-format
qmicli -d /dev/cdc-wdm0 --wda-set-data-format=802-3

Note : The modem will not DHCP an address using the stock DHCP client 'dhclient ' without this setting being in 802-3 mode, if your modem does not support/will not change to 802-3 mode see QMI help note #2

Having checked we've registered on the network and have good signal let's push on and connect to the network

MyPi Industrial Raspberry Pi Sierra Wireless MC7304 3G Modem QMI Internet Connection Configuration Step 3

There are essentially 3 steps here:

1. Start the network interface

2. Connect to the cellular network

3. Run the DHCP client to configure the network interface and routing/DNS

So let's step through a sample connection here:

MyPi Industrial Raspberry Pi Sierra Wireless MC7304 3G Modem QMI Internet Connection Configuration Step 4

qmi-network /dev/cdc-wdm0 start
dhclient -v wwan0

You'll see that once the network connection is made the network interface just needs to be configured via dhclient, this has the bonus of automatically configuring routing and DNS.

MyPi Industrial Raspberry Pi Sierra Wireless MC7304 3G Modem QMI Internet Connection Configuration Step 5

To manually disconnect the cellular link use the command

 qmi-network /dev/cdc-wdm0 stop

Note that though as once the network connection is stopped the interface will need to be brought down (by ifconfig wwan0 down for example) to correct the routing/DNS.

The modemAT serial interface can be used as normal

These sequence of steps can be automated by creating the configuration file /etc/network/interfaces.d/wwan0 with lines below:

 
  iface wwan0 inet dhcp
     pre-up for _ in $(seq 1 10); do /usr/bin/test -c /dev/cdc-wdm0 && break; /bin/sleep 1; done
     pre-up for _ in $(seq 1 10); do /usr/bin/qmicli -d /dev/cdc-wdm0 --nas-get-signal-strength && break; /bin/sleep 1; done    
     pre-up /usr/bin/qmicli -d /dev/cdc-wdm0 --wda-set-data-format=802-3
     pre-up /usr/bin/qmi-network /dev/cdc-wdm0 start    
     post-down /usr/bin/qmi-network /dev/cdc-wdm0 stop

With this in place wwan0 will attempt to make a cellular connection at each 'ifup wwan0' event, depending on how long the DHCP process takes you the interface may take a while to get a usable IP address for network useage.

Note at startup that the wwan0 interface is enabled but is in a disconnected state (usually with a 169.254.x.x. address)

A network status script to keep a check on the connection could be automated using the output from qmi-cli and modemstat script -- see later

See below example

Sierra Wireless Modem QMI Dialout demo 1

QMI Dialout Demo 2

Other commands of interest are shown below, for more information see man qmicli

	
 qmicli -d /dev/cdc-wdm0 --nas-get-signal-info
 qmicli -d /dev/cdc-wdm0 --nas-get-signal-strength
 qmicli -d /dev/cdc-wdm0 --nas-get-home-network

 qmicli -d /dev/cdc-wdm0 --nas-get-serving-system

 qmicli -d /dev/cdc-wdm0 --dms-uim-verify-pin=PIN,0000

 qmi-network /dev/cdc-wdm0 status
 qmicli -d /dev/cdc-wdm0  --wds-get-packet-service-status

To help the process of getting and maintaining a connection we have create an example script set that can be run as part of the boot process to automate and supervise the modem connection, download these using the link below

 

Modem QMI Supervisor Script Set

[ wget --no-check-certificate 'https://drive.google.com/uc?export=download&id=1XykpbQP5Hf-o9JmoT1lbGgDPeA8KGjMi' -O modemcomms-scripts.tar.gz ]

Automatic Modem Connection Info

MC73x4 AT Command Reference

 

MC73x4 Product Technical Guide

Contact us now to discuss your project

Ready to order, contact us today for pricing or samples

Contact Us