User:Crazystick

From ArchWiki

Vodafone/Huawei K3772

As of January 2013 the K3771 is the basic 3G dongle from Vodafone. It is fairly easy to get working, by following the instructions at USB 3G Modem. Most of the information here is taken from that article, with some specific information for the K3772.

Verify the device

When you plug the device in, it should look like the following:

# lsusb
Bus 001 Device 086: ID 12d1:1526 Huawei Technologies Co., Ltd. 

Switching into modem mode

Install usb_modeswitch from the official repositories and run (as root)

/
# udevadm control --reload

Replug the device, and you should now see the following:

# lsusb
Bus 001 Device 086: ID 12d1:14cf Huawei Technologies Co., Ltd. 
# ls /dev/ttyUSB*
/dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2 

Dialing

wvdial

See main article: wvdial

Once you have switched the mode of the dongle, you need to dial a connection. The easiest way is to install wvdial from the official repositories

Run (as root) wvdialconf to create a default configuration. It should detect the modem on ttyUSB0 and write the configuration in /etc/wvdial.conf. You now need to edit this file.

A working wvdial.conf to look like the following (basically add Init3, Phone, Username, Password and change Baud):

[Dialer Defaults]
Modem Type = Analog Modem
ISDN = 0
Modem = /dev/ttyUSB0
Baud = 460800
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2
Init3 = AT+CGDCONT=1,"IP", "smart"
Phone = *99#
Username = web
Password = web

You will need to change Init3, Username and Password depending on what kind of SIM you have (PAYG, Pay Monthly). You'll have to do some searching for this information, for example you could try http://mbed.org/cookbook/VodafoneUSBModem

Once you have your configuration, start it by issuing the wvdial command as root:

# wvdial

--> WvDial: Internet dialer version 1.61
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2
ATQ0 V1 E1 S0=0 &C1 &D2
OK
--> Sending: AT+CGDCONT=1,"IP", "internet"
AT+CGDCONT=1,"IP", "internet"
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT
--> Carrier detected.  Waiting for prompt.

You should get to the Carrier detected message. At this point you'll have to wait around 30 seconds before wvdial starts pppd and continues:


--> Don't know what to do!  Starting pppd and hoping for the best.
--> Starting pppd at Tue Jan 22 20:24:04 2013
--> Pid of pppd: 22798
--> Using interface ppp0
--> pppd: �~� �x� �x� 
--> pppd: �~� �x� �x� 
--> pppd: �~� �x� �x� 
--> pppd: �~� �x� �x� 
--> pppd: �~� �x� �x� 
--> pppd: �~� �x� �x� 
--> pppd: �~� �x� �x� 
--> local  IP address 10.49.239.5
--> pppd: �~� �x� �x� 
--> remote IP address 10.64.64.64
--> pppd: �~� �x� �x� 
--> primary   DNS address 88.82.13.60
--> pppd: �~� �x� �x� 
--> secondary DNS address 88.82.13.60
--> pppd: �~� �x� �x� 

If you receive an IP address and DNS servers, you are connected, and the modem should have a steady blue light.

Dialing when the device is plugged in

If you want to have the connection started as soon as the device is plugged in, we can do this with the help of netcfg-wvdialAUR from the Arch User Repository.

Create the network profile /etc/network.d/wvdial:


CONNECTION="wvdial"
WVDIAL_PROFILE=""
INTERFACE="ignore"
WVDIAL_CTL_FILE="/tmp/wvdial.pid"
WVDIAL_FLAGS=""

Finally, add a udev rule (for example to {ic|/etc/udev/rules.d/91-local.rules}}) to start the service:


ATTR{idVendor}=="12d1", ATTR{idProduct}=="14cf", TAG+="systemd", ENV{SYSTEMD_WANTS}="netcfg@wvdial.service"

On slower machines, usb_modeswitch might be too slow, and maybe this rule instead will be more reliable:


KERNEL=="ttyUSB*", SYMLINK=="gsmmodem", TAG+="systemd", ENV{SYSTEMD_WANTS}="netcfg@wvdial.service"

Troubleshooting

usb_modeswitch doesn't convert the device

Make sure you plug the device directly into a root USB port, not an external hub, as the hub seems to prevent usb_modeswitch from doing it's job.

If your version of usb_modeswitch for some reason doesn't include the configuration for the Vodafone K3772, you might need to override it, by creating /etc/usb_modeswitch.d/12d1:1526

DefaultVendor=0x12d1
DefaultProduct=0x1526

TargetVendor=0x12d1
TargetProduct=0x14cf

MessageContent="555342437f0000000002000080000a11062000000000000100000000000000"

TODO

Automatically Reconnecting

So far, the only way I've found to make a reconnection happen is via a cron job and the following script:


#!/bin/sh

if [ -z "$(pidof pppd)" ]; then
    logger No pppd connection found, restarting wvdial
    systemctl restart netcfg@wvdial.service
    exit 0
else
    # connected
    logger pppd running
    exit 0
fi

Run it as root. Obviously it won't work if are supposed to have more than one ppp running.