I was a bit afraid that getting an UMTS USB stick to work under Linux would be an impossible task. Turns out to be reasonably simple. These notes are for a Huawei K4505 HSPA+ USB stick, as provided by Proximus (Vodaphone group).
This stick employs the “ZeroCD technology”, also called “flip flop devices”. When plugged in, it presents itself as a mass storage device with its (Windows) installer. It then needs a switching command, which is normally send by the driver once it’s installed. Only after this switching command, the modem is presented to the OS.
So the first step is to get the USB device into the correct mode. This can be done with usb_modeswitch (called usb-modeswitch on ubuntu). The Ubuntu package automatically installs the needed udev-rules to make things work automagically. Seconds after plugging in the device, I can see (via dmesg) the switch and see /dev/ttyUSB0 added.
The modem is now visible. Next up is making the actual connection with the network. I’ve found this guide for ArchLinux, which works on Ubuntu with almost no changes. For redundancy reasons, I’ll summarize the steps below:
# cat > /etc/ppp/options-mobile <<EOTttyUSB0 # Use this device 921600 # at high speed lock # create lockfile crtscts # use hardware (CTS/RTS) flow control with the modem modem # use modem control lines passive # don't exit if no LCD reply is received novj # no TCP header compression defaultroute # use this connection as default route noipdefault # use IPCP to get IP, don't try to guess one usepeerdns # Use supplied DNS servers noauth hide-password # don't log passwords (if used) persist # reopen connection if closed holdoff 10 # but wait 10 seconds between reconnects maxfail 0 # and keep trying forever debug # tell me what's going on EOT # cat > /etc/ppp/peers/mobile-auth <<EOT file /etc/ppp/options-mobile user "your_usr" password "your_pass" connect "/usr/sbin/chat -v -t15 -f /etc/ppp/chatscripts/mobile-modem.chat" EOT # cat > /etc/ppp/peers/mobile-noauth <<EOT file /etc/ppp/options-mobile connect "/usr/sbin/chat -v -t15 -f /etc/ppp/chatscripts/mobile-modem.chat" EOT # ln -fs mobile-noauth /etc/ppp/peers/provider # mkdir /etc/ppp/chatscripts # cat > /etc/ppp/chatscripts/mobile-modem.chat <<EOT ABORT 'BUSY' ABORT 'NO CARRIER' ABORT 'VOICE' ABORT 'NO DIALTONE' ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT 'DELAYED' REPORT CONNECT TIMEOUT 6 '' 'ATQ0' 'OK-AT-OK' 'ATZ' TIMEOUT 3 'OK' @/etc/ppp/chatscripts/pin 'OK\d-AT-OK' 'ATI' 'OK' 'ATZ' 'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0' 'OK' @/etc/ppp/chatscripts/mode 'OK-AT-OK' @/etc/ppp/chatscripts/apn 'OK' 'ATDT*99***1#' TIMEOUT 30 CONNECT '' EOT # cat > /etc/ppp/chatscripts/apn.be.proximus <<EOT AT+CGDCONT=1,"IP","internet.proximus.be" EOT # ln -fs apn.be.proximus /etc/ppp/chatscripts/apn # cat > /etc/ppp/chatscripts/pin.CODE <<EOT AT+CPIN=1234 EOT # cat > /etc/ppp/chatscripts/pin.NONE <<EOT AT EOT # ln -fs pin.CODE /etc/ppp/chatscripts/pin # cat > /etc/ppp/chatscripts/mode.3G-only <<EOT AT\^SYSCFG=14,2,3fffffff,0,1 EOT # cat > /etc/ppp/chatscripts/mode.3G-pref <<EOT AT\^SYSCFG=2,2,3fffffff,0,1 EOT # cat > /etc/ppp/chatscripts/mode.GPRS-only <<EOT AT\^SYSCFG=13,1,3fffffff,0,0 EOT # cat > /etc/ppp/chatscripts/mode.GPRS-pref <<EOT AT\^SYSCFG=2,1,3fffffff,0,0 EOT # cat > /etc/ppp/chatscripts/mode.NONE <<EOT AT EOT # ln -fs mode.3G-pref /etc/ppp/chatscripts/mode
These instructions set up a set of files with symlinks to easily switch between configs. Simply changing the symlinks in
/etc/ppp/chatscripts allows you to change the APN or the (preferred) mode.
Once these configuration files are in place, a simple
pon brings up the connection.
Other useful AT commands
I’ve found the local copy) which listed some other interesting AT-commands:(
AT+CSQreturns the current RSSI (received signal strength indicator). The first number indicates the Rx power = (-113 + <num>*2) dBm. You can convert this to the more usual “bars” unit, this site lists some value-to-bars conversions (local copy).
AT^SYSINFOtells you what mode is currently used (GPRS, EDGE, UMTS, …) in the 7th field:
- 0: No service
- 1: GSM mode
- 2: GPRS mode
- 3: EDGE mode
- 4: WCDMA mode
- 5: HSDPA mode
- 6: HSUPA mode
- 7: HSDPA mode and HSUPA mode
- 8: TD_SCDMA mode
- 9: HSPA+ mode
- 17: HSPA+(64QAM) mode
- 18: HSPA+(MIMO) mode
AT+CGREG=2when used on
/dev/ttyUSB2the cellID of the current cell (on a periodic basis).