Vodacom 3G

From TLUGWiki

Jump to: navigation, search


Vodacom 3G is a pain in the backside to get working, here is a quick and dirty howto. Please feel free to clean it up.

Whilst the majority of this is still perfectly valid, you should probably also take a look at http://jkroon.blogs.uls.co.za/it/networking/3g-pins-prompts-and-pppd that builds on this but takes it a little further.

Contents

[edit] kernel module

  • modprobe option

You should now see a few /dev/ttyUSB* devices.

If this module does not exist on your system you will need to activate the CONFIG_USB_SERIAL_OPTION in your kernel and recompile. Binary distributions will hopefully have a package you can install to get the module, otherwise you will need to download the kernel sources for your distro (look for a package called kernel-sources or similar, on debian I recommend using make-kpkg).

You do NOT need external kernel modules.

[edit] huaweiAktBbo

In some cases the huawei E220 modems doesn't come up in the right mode, this can be seen by only having a single (or none with more recent kernels) /dev/ttyUSB device after inserting the modem, in these cases:

Whenever it locks up, just rerun the last command there.

[edit] Using udev

The above can be done from udev. It seems the newer units at least reliably go into braindead mode. Can't give firmware versions though, the following content in /etc/udev/rules.d/??-????.rules (99-huawei.rules in my case) helps (Assuming you've copied the executable into /usr/local/sbin):

SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/sbin/modprobe option"
SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="sleep 10"
SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/usr/local/sbin/huaweiAktBbo"

However, I personally found it breaks half the time, and the other time the device is ready in < 3 seconds, and sometimes it takes much, much longer (I've seen 40 seconds and up). So I wrote this:

#! /bin/bash

lockfile=/tmp/.huawei_lock
maxretries=100
retrywait=1
huaweiakt=/usr/local/sbin/huaweiAktBbo
logger="logger -t huawei -p user.info -s --"

/usr/bin/dotlockfile -p -l -r 3 "${lockfile}" || exit -1
trap "/usr/bin/dotlockfile -p -u '${lockfile}'" EXIT

retry=0
while  $retry -lt $maxretries ; do
    $huaweiakt | $logger
     $? -eq 0  && exit 0
    (( retry += 1 ))
done

$logger "Failed to set huawei device up."
tty -s && echo "Failed to set huawei device up." >&2

exit -2

Stored it as /usr/local/sbin/huawei_wrapper, and now have this in 99-huawei.rules:

SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/sbin/modprobe option"
SUBSYSTEM=="usb", SYSFS{idProduct}=="1003", SYSFS{idVendor}=="12d1", RUN+="/usr/local/sbin/huawei_wrapper"

Which at least for the three or four test runs worked flawlessly. Based on that you should even be able to do funky stuff like for off the pppd processes when the device gets plugged in, and starts successfully, and using udev again, kill that same pppd proces when the device gets removed. I don't know udev well enough for that just yet.

Whilst the above works I believe there is a better way now. I'm working on a mechanism whereby the modprobe gets loaded, which will cause additional events to be run. Also, since multiple EVENT=="add" events gets generated I'm still looking for ways to trigger the correct commands at the right times based on those events.

[edit] 3G Connect (chat) script

ABORT BUSY
ABORT 'NO CARRIER'
ABORT ERROR
REPORT CONNECT
TIMEOUT 10
SAY "Calling ONE\r\n"
"" "ATZ"
#### This section if you're using a PIN, just comment it if you don't.
# Replace your PIN in here in place of 1234
OK "AT+CPIN=1234"
## Cheat by only looking for O, which apears in both OK and +CME ERROR :).
O ATZ
#### End of variable bits
TIMEOUT 60
OK "ATE1V1&D2&C1S0=0+IFC=2,2"
OK AT+CGDCONT=1,"IP","internet"
OK "AT+IPR=115200"
OK "ATE1"
OK "ATDT*99***1#"
CONNECT \c

Store the above in /etc/ppp/chat-3g-connect.

The above works pretty well, but there is a risk: If you have multiple SIM cards and regularly swap them out the above can get run multiple times with the wrong PIN and you're going to end up with a PUKed sim.

We looked at ways of avoiding that, but the closest we could get was to identify the modem before issueing the AT+CPIN command, but it's not the modem that is PIN blocked, it's the SIM, so we really need to identify the SIM, then be able to look up the PIN in an external database. So for this isn't happening and there exists a couple of solutions:

  1. Don't use multiple SIM cards on the same machine
  2. Disable the PINs on the SIMs.
  3. Use the same PIN on all SIMs.
  4. Never swap SIMs in the modems, identify the modem, and lookup the PIN for the SIM associated with that modem.

[edit] Peer file

# If pppd reports this as a non-modem thing, then run the huaweiAktBbo program
/dev/ttyUSB0
460800

# Don't require the peer to authenticate (this _seems_ to get the connection going in a shorter time)
noauth

# If you want more detailed logs, enable this (it doesn't generate that much noise, but assists a lot in finding problems):
# debug

# modem initialization
connect "/usr/sbin/chat -V -f /etc/ppp/chat-3g-connect"

# We probably want to use the DNS as advertized by the peer
usepeerdns

# Use this link as the default gateway
defaultroute

# 3G doesn't like all kinds of compression ... wish they did - it's slow enough.
noccp
nobsdcomp
novj

# Make the connection persistent, and not terminate if/when errors occur.
persist
maxfail 0

I store this in /etc/ppp/peers/3g.

[edit] Connecting

Debian:

# pon 3g

Others:

# pppd call 3g

You can add options such as debug and nodetach here as well, this is great for debugging.

[edit] Alternative Linux friendly 3G modems

  • Advinne AMC HSDPA/3G/EDGE/GPRS USB Modem
    The Advinne AMC is a Linux friendly alternative to the Huawei E220 modem. The AMC modem uses the CDC-ACM USB driver that comes standard with the Linux 2.6 kernel. As with the huawei modems, you do not need third-party modules to get the modem working. If you are using udev, then two /dev/ttyACM* devices will automatically appear when you plug the modem into your USB port.
  • Option Wireless GlobeTrotter HSDPA: This card works with the Nozomi driver which provides 4 tty's for your AT command pleasure. The HSDPA can scale up to 7.2Mbps. I've gotten very good speeds with this on Vodacom (at times up to 1.2Mbps from local sites).

[edit] 3G modems to avoid

  • Novatel Wireless U740 HSDPA: This card works with the usbserial driver, but only the first of the two COM ports is usable, preventing querying signal levels, or anything else while running PPP (the second one uses a proprietary binary protocol that encapsulates the AT commands). I could also never get it to transfer faster than ~300Kbps, which would seem to indicate that HSDPA was not working.
Personal tools