User:Mid/USB mobile modems
This is a draft page. Once it is ready I intend to move it to the main namespace.
USB mobile modems are highly diverse. From a programmer's perspective they can be categorized in multiple ways:
- Whether they have ZeroCD and how it is disabled
- How they expose you to the mobile network (through serial, MBIM, QMI, through a local web server or not at all)
- How they expose you to the Internet (through serial, USB CDC, USB RNDIS, QMI MSM or not at all)
Ideally each of these problems would be handled by a unique layer.
Handling ZeroCD
Most dongles first show themselves as a mass storage device to provide Windows drivers to the user. In the best case scenario, sending an "eject" command to the mass storage device is enough for the device to disconnect and reconnect in modem mode, but the method to turning this off varies with almost every single device.
Fortunately, the effort of putting together a database has been done in the usb_modeswitch project (/usr/share/usb_modeswitch/configPack.tar.gz
). If a file for your device exists and it contains a MessageContent
key, then it is a hex-encoded command block wrapper for the USB BBB mass storage protocol.
Using the mobile network
If your dongle is actually not a USB modem, but more of a USB router, there will be no way to communicate with the mobile network for e.g. sending SMS messages or establishing calls. Said devices usually expose themselves as an Ethernet port over USB CDC, and often contain a web server for configuration at the gateway address, akin to how a regular router works. If only an internet connection is enough for you, then you need not do anything more than a CDC Ethernet driver.
AT overview
In 1996, the GSM 07.07 specification popularized the use of the AT command set for communicating with the modem. The channel is through a serial interface, which for modern USB dongles implies a USB CDC serial port.
Beware that AT syntax makes no sense whatsoever, and one should not attempt to find a pattern within beyond what is written.
Input to the modem consists of an AT command line, which begins with the characters AT
, followed by one or more commands. Commands are delimited by semicolons only when necessary, else they are of fixed size. Extended commands are prefixed with +
and must always end with a semicolon. Every extended command can be suffixed with ?
to testing the command's existence or checking the current state. Every extended command can be suffixed with =?
to find the possible values of the corresponding command.
The command line is terminated with a carriage return (ASCII 13) marked with <CR>
. Note that the carriage return is not the line feed character (ASCII 10) marked with <LF>
.
For each command in the command line, the modem returns each response, followed by <CR><LF>OK<CR><LF>
. Responses themselves are surrounded by <CR><LF>
on both sides. Here is an example command and response:
ATCMD1CMD2=12;+CMD1;+CMD2=,,15;+CMD2?;+CMD2=?<CR>
<CR><LF>+CMD2: 3,0,15,"GSM"<CR><LF> <CR><LF>+CMD2: (0-3),(0,1),(0-12,15),("GSM","IRA")<CR><LF> <CR><LF>OK<CR><LF>
...
Certain models require you to activate the USB Ethernet port, while for others it is automatic. Try AT+XCEDATA=1,0
while ignoring the output. For Quectel models, AT+QCFG="usbnet",1
. Reset the modem with AT+CFUN=0
then AT+CFUN=1
with a delay in between.
AT+CGDCONT
TBA
ATDT*99#
TBA