Saturday, June 21, 2008

using 3G usb modem with linux (ubuntu 8.04)

Today i have a hand on a 3G usb modem and i was sad that it only has drivers for both windows and Apple
so i connect it to windows to see how it works
it install the driver automatically and then a software is installed that allow it to dial by just clicking Connect (easy windows)
after i successfully use it under windows i start searching for how to make it work with linux

and i was surprised that ubuntu has the driver for it

this is what i did to make my 3G USB modem (Huawei E220)

1- sudo apt-get install wvdial gnome-ppp
to install wvdial, a PPP dial-in command line software, and a GNOME frontend to it

2- wvdialconf
Editing `/etc/wvdial.conf'.

Scanning your serial ports for a modem.

Modem Port Scan<*1>: S0 S1 S2 S3
WvModem<*1>: Cannot get information for serial port.
ttyUSB0<*1>: ATQ0 V1 E1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB0<*1>: Modem Identifier: ATI -- Manufacturer: huawei
ttyUSB0<*1>: Speed 9600: AT -- OK
ttyUSB0<*1>: Max speed is 9600; that should be safe.
ttyUSB0<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
WvModem<*1>: Cannot get information for serial port.
ttyUSB1<*1>: ATQ0 V1 E1 -- OK
ttyUSB1<*1>: ATQ0 V1 E1 Z -- OK
ttyUSB1<*1>: ATQ0 V1 E1 S0=0 -- OK
ttyUSB1<*1>: ATQ0 V1 E1 S0=0 &C1 -- OK
ttyUSB1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 -- OK
ttyUSB1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK
ttyUSB1<*1>: Modem Identifier: ATI -- Manufacturer: huawei
ttyUSB1<*1>: Speed 9600: AT -- OK
ttyUSB1<*1>: Max speed is 9600; that should be safe.
ttyUSB1<*1>: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 -- OK

Found a modem on /dev/ttyUSB0.
Modem configuration written to /etc/wvdial.conf.
/etc/wvdial.conf: Can't write '/etc/wvdial.conf.tmp13605': Permission denied
/etc/wvdial.conf: Can't write '/etc/wvdial.conf' ('/etc/wvdial.conf'): Bad file descriptor
ttyUSB0: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
ttyUSB1: Speed 9600; init "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"

it cannot write to /etc/wvdial, i should have been run it inside sudo

3- sudo vi /etc/wvdial.conf
[Dialer Defaults]
Modem = /dev/ttyUSB0
Baud = 460800
Init1 = ATZ
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ISDN = 0
Modem Type = Analog Modem
Phone = *99#
Username = username
Password = password
Stupid Mode = 1

i only changed the name of the modem

4- wvdial
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT*99#
--> Waiting for carrier.
ATDT*99#
CONNECT
--> Carrier detected. Starting PPP immediately.
--> Starting pppd at Sat Jun 21 21:52:03 2008
--> Warning: Could not modify /etc/ppp/pap-secrets: Permission denied
--> --> PAP (Password Authentication Protocol) may be flaky.
--> Warning: Could not modify /etc/ppp/chap-secrets: Permission denied
--> --> CHAP (Challenge Handshake) may be flaky.
--> Pid of pppd: 13733
--> Using interface ppp0
--> pppd: h�[06][08] �[06][08]
--> pppd: h�[06][08] �[06][08]
--> pppd: h�[06][08] �[06][08]
--> pppd: h�[06][08] �[06][08]
--> pppd: h�[06][08] �[06][08]
--> local IP address 10.70.34.143
--> pppd: h�[06][08] �[06][08]
--> remote IP address 10.64.64.64
--> pppd: h�[06][08] �[06][08]
--> primary DNS address 212.103.160.26
--> pppd: h�[06][08] �[06][08]
--> secondary DNS address 4.2.2.2
--> pppd: h�[06][08] �[06][08]
--> pppd: h�[06][08] �[06][08]
--> Connect time 0.5 minutes.
--> pppd: h�[06][08] �[06][08]
--> pppd: h�[06][08] �[06][08]
--> pppd: h�[06][08] �[06][08]
--> Disconnecting at Sat Jun 21 21:52:34 2008
--> The PPP daemon has died: A modem hung up the phone (exit code = 16)
--> man pppd explains pppd error codes in more detail.
--> Try again and look into /var/log/messages and the wvdial and pppd man pages for more information.
--> Auto Reconnect will be attempted in 5 seconds
--> Cannot open /dev/ttyUSB0: No such file or directory
--> Cannot open /dev/ttyUSB0: No such file or directory
--> Cannot open /dev/ttyUSB0: No such file or directory

and her it works and i can surf the internet

enjoy it and try it for different operators and tell me about your test

8 comments:

Samer Azmy aka Kernel The Canine said...

This One Rocks
Congrats
I will try it

Anonymous said...

...or if you don't like messing with command line commands:

- Install gnome-ppp using the Synaptic installer.
- Start gnome-ppp from the Internet menu
- Enter username and password
- Enter *99# in "Phone number"
- Press "Setup"
- Press "Detect"
- Chose type "USB modem"
- Press "Close"
- Press "Connect"
Voilá

This worked with a Nokia N90
The speed seems slow though?

Arne

Anonymous said...

thanks for real.
after a lot of tries... i found your suggestion... and it's working.

just a suggestion, you forget to add that gnome-ppp (that you suggested to install) provides the graphical interface for the command line wvdial and so for the UI userd users its better for keeping track of the time spent and the data exchanged during the connection.

nice post anyway and thanks again.

Samer Azmy aka Kernel The Canine said...

Wael,
Please If I use Ubuntu, and I want to define the Access point Name (APN) that the mobile/Computer will use, how I may do that ?

waelaase said...

Hi Samer
in my case i did not need to define the Access point Name (APN)
all you have to check
1- the number to dial (*99# in my case this to check with your operator)
2- the username (you can get this from the mobile APN)
3- the password (you can get this from the mobile APN)
if it wont work, please post the full log
thank you

Big G said...

Thank you for this!!!
For months I have been trying to use Kannel on my Ubuntu server. For the life of me I could not get kannel connecting to my Nokia phones ....

I have done so many re-installs and config changes ... nothing helped :-(

Then I followed these simple steps on my server and Wholla!! I see Ubuntu connects to my phone not using ttyUSB but ttyACM !!!! Changed the setting and now everything works!!!!!!!!! :-)

Regards,
Big G

waelaase said...

Hello Big G
I'm happy it works for you
and thank you for your comment
also I'd like to add that Ubuntu 8.10 discover the 3G modem and works without configuration
try it

Big G said...

Hi waelaase

What was strange is that I was trying to use it on Ubuntu server 8.04 / 8.10 / 9.04 - with no luck!! I also installed the desktop unto the server instal ... still no luck :-( - BUT hey, it now works!! :-)

On the desktop upgrade it did detect & install some stuff for my phone but Kannel still did not pick up the phone!!

Again, thank you for your post!!!


Big G