BSNL had recently launched their 3G services in India with speeds of up to 3.6Mbps. Interestingly the 3G USB modem provided by BSNL also comes with a wvdial front end targeting GNU Linux users. Welcome change from the national telecom provider. Unfortunately the 3G USB device(ZTE MF626 HSDPA with device id 19d2:2000) had the same problem with switching the mode from the storage device, that it gets detected by default, like its predecessors. Here are the steps for configuring the BSNL 3G modem in Ubuntu. This should work with minor variations in other GNU Linux distros as well.

First download and install usb_modeswitch. Get the latest version from

http://www.draisberghof.de/usb_modeswitch/#download

The version at the time of writing this article was usb-modeswitch-1.1.2.tar.bz2. Extract and install following the instructions at the above page. Please also make sure that you install usb-modeswitch-data package from the same page. You could also install usb-modeswitch package straight from the ubuntu repositories but the device definitions that come with the repository version would very likely be dated compared to the latest version available from the draisberghof site.

Plug in your 3G USB modem and check that the device is the same as the one this article is based on. If not then you will have to make appropriate changes in the configuration files as required.

Try lsusb to see if the product id of the device is 19d2:2000

Open the corresponding file from /etc/usb_modeswitch.d/[device-id] for editing. In this case open /etc/usb_modeswitch.d/19d2\:2000

Add the product id 0108 to the TargetProductList. The target product id 0108 was identified by installing the device on windows and checking the product id after installing the driver using the SniffUSB tool (http://www.pcausa.com/Utilities/UsbSnoop/default.htm) and installing the sniffusb filter to the device. If your device does not work after the whole process is completed then you might want to come back and do some USB sniffing in one of your friends' computers to find the right TargetProduct id.

You can verify that this(0108) is indeed the correct product id by running usb_modeswitch from the command line using the following command.

sudo usb_modeswitch -v 0x19d2 -p 0x2000 -V 0x19d2 -P 0x0108 -M 55534243123456782000000080000c85010101180101010101000000000000 -R -W

Note that the message was taken from the /etc/usb_modeswitch.d/19d2\:2000 file. You can test if the switching was successful by running lsusb before and after the switch to see if the device id had successfully changed.

To check if the device id that was changed to was correct, you will have to load usbserial with the target vendor and product id and check dmesg to see if the device was detected as /dev/ttySOMETHING. Running wvdialconf is another easy way to see if the modem was detected correctly after the modeswitch. If the modem was detected correctly then wvdialconf will try to generate the configuration for the modem. If not it will complain that no modem was found.

sudo modprobe usbserial vendor=0x19d2 product=0x0108
dmesg
wvdialconf

The following would be how the file should look (unless new product ids have been added by usb_modeswitch) after adding the new product id.

# ZTE MF622 and probably others (WE NEED MORE ID INFO)

DefaultVendor= 0x19d2
DefaultProduct= 0x2000

TargetVendor= 0x19d2
TargetProductList="0001,0002,0015,0016,0017,0031,0037,0052,0055,0063,0108"

CheckSuccess=20
MessageContent="55534243123456782000000080000c85010101180101010101000000000000"

Now in ubuntu modem-modeswitch tries to do exactly the same thing that usb_modeswitch does but unfortunately it does not work with the 19d2:2000 product class. But this however causes a problem with the usb_modeswitch application. It checks for udev rules and on finding that there is a rule for 19d2:2000 usb_modeswitch just ignores the device. The solution is to edit

lib/udev/rules.d/61-mobile-action.rules

and then take out the lines

ZTE MF6xx
ATTRS{idVendor}=="19d2", ATTRS{idProduct}=="2000", RUN+="/usr/bin/eject %k"

Please note that commenting these lines will not work. The modified file should look like

ACTION!="add", GOTO="mobile_action_end"

SUBSYSTEM=="usb", ATTR{bDeviceClass}=="00|ff", ATTR{bDeviceSubClass}=="00|ff", ENV{DEVTYPE}=="usb_device", GOTO="mobile_action_switch"
GOTO="mobile_action_end"

LABEL="mobile_action_switch"
ATTRS{idVendor}=="0df7", ATTRS{idProduct}=="0800", RUN+="modem-modeswitch -v 0x%s{idVendor} -p 0x%s{idProduct} -t mobile-action-8280p"
LABEL="mobile_action_end"

We figured this issue by enabling logging for usb_modeswitch. You can do so by editing

/etc/usb_modeswitch.conf

and setting

EnableLogging=1

After restarting udev by running

udevadm control --reload_rules

You can see the error/debug messages inside
/var/log/usb_modeswitch_1-2:1.0 (or some similar filename)

Now your modem should really be working fine as a modem. You can configure Ubuntu to start the connection automatically as soon as a modem is plugged in by configuring NetworkManager. Open Network manager

Under Mobile Broadband

Create new connection HSPA Incorporated HSPA WCDMA Technologies MSM

Under Mobile Broadband Tab

In basic section

set

Number *99#

In advanced section

set APN - bsnlnet

In IPv4 settings

Select - Method Automatic(PPP)

That should be it and you should be ready to surf your newly configured BSNL 3G connection at blazing 3G speeds using the power and safety of GNU Linux.

Post your comments / questions