My first experience of dealing with GSM modem was for an SMS gateway using Huawei E220 in which only a SIM card without a broadband Internet connection was used. I had tried several times in those days to connect to the Internet using SIM cards with a broadband Internet connection to no avail because I always got stuck when executing `sudo wvdial' in which fancy ASCII characters were displayed on the screen. I didn't pursue the solution because a GSM modem was still expensive and the 3G signal was weak at my place. But, this time I really needed to connect to the Internet using Prolink PHS100 GSM modem.
First thing of course I googled for "ubuntu prolink phs100" that made me visit http://nmlaxaman.blogspot.com/2009/04/prolink-phs100-hsdpa-workout-for-d.... From there, I went to http://www.draisberghof.de/usb_modeswitch/ to download the source code. It turned out that the source code, which is version 1.1.1, is newer from nmlaxaman's description and already has PHS100 integrated.
Navigating the source tree a little bit as well as the website, I re-realized a simple fact: A GSM modem is simply another dial-up modem that responds to Hayes/AT command set just like my old 56k dial-up modem that connected to my serial port. The role of Draisberghof's, or to be exact, Josua's usb_modeswitch is to get access to the logical serial device contained in the USB GSM modem. Once it is accessible, everything works like with the old 56k modem. But, getting Prolink PHS100 to work with my laptop was not that simple. For a quick solution, see the conclusion at the end of this article. Now I am going to describe my little research.
First, nmlaxaman wrote that: "ttyUSB3 will the working one for data connection." But, I only found ttyUSB0, ttyUSB1 and ttyUSB2. Since `sudo wvdial'-ing to them at best returned "Modem not responding", I googled for the error message and landed on http://mybroadband.co.za/vb/archive/index.php/t-67729.html that suggests that usb_storage module should be `rmmod'-ed after running usb_modeswitch but before `modprobe'-ing usbserial module. Since I didn't want to plug 'n pray using usb_modeswitch's udev rule, I uninstalled usb_modeswitch and did everything manually as follows:
#!/bin/bash sudo /home/eus/usb-modeswitch-1.1.1/usb_modeswitch -v 0x1e0e -p 0xf000 -V 0x1e0e -P 0x9000 -C 0xff -m 0x1 -M 555342431234567800000000000006bd000000020000000000000000000000 -r 0x1 sleep 1 sudo rmmod usb_storage sudo modprobe usbserial vendor=0x1e0e product=0x9000
That did the trick. I found ttyUSB3. However, `sudo wvdial'-ing to ttyUSB3, wvdial got stuck with Terminate Request (Message: "No network protocols running" ), which means that the IPCP fails because no response is received for IPCP Config-Requests after a while (http://mybroadband.co.za/vb/archive/index.php/t-75139.html). This leads to the second culprit.
Second, it turned out that the modem needs to be sort of activated in Windows. Plug the modem in a Microsoft Windows machine and wait until the manager software runs and the LED of the modem turns magenta. Without doing anything else, unplug the "activated" modem. If this step that I discovered accidentally is not done, wvdial will always get stuck with error message "No network protocols running" due to IPCP Config-Requests timeout and the LED of the modem will always be red in the GNU/Linux machine. Otherwise, the LED will start with red and then turn to magenta and wvdial will succeed. To deactivate the modem, simply plug the modem in a Microsoft Windows machine, wait until the manager software runs, and without doing anything, close the manager. You will be see a prompt that should be answered with OK. Then, the LED of the modem will turn red.
Third, with my manual script, I can connect to the Internet and download data at the rate of 35 kB/s. However, when I plug in the modem to my GNU/Linux Ubuntu 9.04 machine before running my manual script, Nautilus will crash, and so there is no more automount of USB devices under /media and the like (c.f., http://ubuntuforums.org/showthread.php?t=1251626), with the following message of `dmesg':
[ 3265.438946] nautilus: segfault at 8756008 ip b5629dc6 sp b5059fb0 error 4 in libbrasero-media.so.0.1.1[b5618000+1f000]
The segfault happens after the kernel recognizes the logical USB storage device of the modem, and Nautilus gets the kernel event. This compelled me to install usb_modeswitch and be done with my manual script since I hoped that doing so will prevent Nautilus from segfaulting. This does the trick. But, there is a quirk.
Fourth, when the "activated" modem is plugged in for the very first time, the installed usb_modeswitch's udev script will handle the modem and Nautilus will not crash. However, upon loading the `option' module, the udev script stops, and so, there is no ttyUSB* under /dev (see the log message of the udev script as well as the dmesg, the /var/log/messages and /var/log/syslog). Unplugging the modem and plugging it back again will make usb_modeswitch successful in summoning ttyUSB* under /dev (see the udev script log as well as the dmesg, /var/log/messages and /var/log/syslog). However, ttyUSB3 will not exist. The trick is to `sudo wvdial' to ttyUSB2, and everything will work fine ending my little research.
There is, however, a little mystery. Having not seen the reason why the following lines in /etc/wvdial.conf described by nmlaxaman should start from `Init2',
... Init2 = ATZ Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init4 = AT+CGDCONT=1,"IP","" ...
I changed it to:
... Init1 = ATZ Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init3 = AT+CGDCONT=1,"IP","indosatm2" ...
It turned out that the use of `Init2' was crucial to avoid seeing fancy ASCII characters on the screen as illustrated here. Without the fancy ASCII characters, a successful dial-up is illustrated here. I saw that when using `Init2', ATZ is sent twice. However, changing /etc/wvdial.conf to output ATZ twice as follows does no good:
... Init1 = ATZ Init2 = ATZ Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init4 = AT+CGDCONT=1,"IP","indosatm2" ...
So, this the use of `Init2' is still a mystery for me. Anyone can throw a light?
To conclude, to make Prolink PHS100 USB GSM modem works in a GNU/Linux Ubuntu 9.04 (Jaunty), do the following steps except step 1 in Terminal (i.e, Applications -> Accessories -> Terminal):
1. "Activate" the modem in a Microsoft Windows machine by plugging the modem, waiting till the modem manager software appears and the modem LED turns magenta, and immediately unplugging the modem while the LED is still magenta.
2. Fire `sudo aptitude install wvdial' if you don't have it installed yet.
3. Save the following text as /etc/wvdial.conf and adjust `indosatm2', the phone number, the username and the password accordingly:
Modem = /dev/ttyUSB2 Baud = 115200 Modem Type = USB Modem Init2 = ATZ Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init4 = AT+CGDCONT=1,"IP","indosatm2" Dial Command = ATDT Phone = *99# Username = ... Password = ... Stupid Mode = yes
4. Install usb-modeswitch 1.1.1 by downloading the code, extracting it, going to the extracted directory and firing `sudo make install'.
5. Fire `sudo gedit /etc/usb_modeswitch.conf' and change `EnableLogging' to 1.
6. Fire `sudo rm /var/log/usb_modeswitch_*' to remove any existing log.
7. Plug the modem in.
8. Fire `tail /var/log/usb_modeswitch_*' to see usb_modeswitch activity log on the plugged modem.
9. If the last non-blank line says `All done, exiting', proceed to step 10. But, you have to unplug the modem and go back to step 6 if the last two non-blank lines says:
Trying to load the option driver loader is: /sbin/modprobe
10. Wait for about 1 minute. While waiting, repeatedly fire `ls /dev/ttyUSB*'. Once `ls' returns some files instead of saying "No such file or directory", you can go to step 11. If `ls' returns no file after 1 minute, unplug the modem, fire `sudo rmmod option' and go back to step 6.
11. Turn off NetworkManager by firing `sudo /etc/init.d/NetworkManager stop' (c.f., http://developer.pidgin.im/ticket/8545).
12. Fire `sudo wvdial', and if everything is okay, you should see an output like this. For subsequent use of the modem after the modem is unplugged or the machine is restarted or powered off, you only need to start from step 6.