Saturday, May 12, 2007

HUAWEI EC321 on Linux

So what do you do after two days of non-sleep and a 5 hour party? You try to make your recently acquired gadget to work on linux :) I wish I was kidding!

It all started due to a cow orker "borrowing" the team laptop and somehow loading it upto the brim with spyware And Gopal trying to browse on it. within 12 minutes we were booting linux.

I had just procured a Tata Indicom cdma data card as replacement for my now broken reliance cdma card. Since the reliance junk would never work on linux. I was rubbing my hands in anticipation on my way back home.


Out with the reasons and on to the quest.

After a few Google queries we ran into a few helpful Chinese characters. Even though we couldn't read any chinese ... the commands were all in plain old ASCII.

So, if you do a

$cat /proc/bus/usb/devices
$sudo modprobe usbserial vendor=0x12d1 product=0x1001


you should be able to see /dev/ttyUSB0 /dev/ttyUSB1. If you're not using udev. you can

#mknod /dev/ttyUSB0 c 188 0
#mknod /dev/ttyUSB1 c 188 1


Congratulations, you are now the proud configurer of a modem. And, it's time to pull an old cat out of the bag. wvdial :)

cat > /etc/wvdial.conf
[Modem0]
Modem = /dev/ttyUSB0
Baud = 115200
SetVolume = 0
Dial Command = ATDT
Init1 = ATZ
FlowControl = Hardware (CRTSCTS)

[Dialer cdma]
Username = username
Password = *******
Phone = #777
Stupid Mode = 1
Inherits = Modem0


And then do a wvdial cdma and say hello to Intraweb 2,0TM

But we didnt just stop there, Mr Gopal is too lazy to type modprobe everytime he boots the comp, and so should be you. :D

So, As a little gift to our chinese fellows we give you a set of hotplug scripts.

cat > /etc/hotplug/usb/datacard.usermap
# Huawei EC321 CDMA data card
datacard 0x0003 0x12d1 0x1001 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00 0x00 0x00000000


The first three numbers are important here, if you noticed when we did a cat /proc/bus/usb/devices grep -a2 -b1 Huawei it looked like,

1565-P: Vendor=12d1 ProdID=1001 Rev= 0.00
1603:S: Manufacturer=Huawei Technologies
1643:S: Product=Huawei Mobile
1686-S: SerialNumber=HUAWEI EC3X1


0x12d1 and 0x1001 is just the vendor and device identifier (duh!), So much for the linux is difficult. We just like to make it look confusing :D notice the useless 0x0000 padding that follows, reserved for future use and confusing all present grey matter.

Now that we have found the device we should be able to hotplug it. the script below should do just fine.

cat > /etc/hotplug/usb/datacard
#!/bin/bash
SED=/bin/sed

#/usr/bin/env > /tmp/datacard.log

if [ "$ACTION" = "add" ] && [ -f "$DEVICE" ]
then
VENDOR="`echo "$PRODUCT" $SED "s/^\(.*\)\/.*\/.*$/\1/"`";
PRODUCT_ID="`echo "$PRODUCT" $SED "s/^.*\/\(.*\)\/.*$/\1/"`";
modprobe usbserial "vendor=0x$VENDOR" "product=0x$PRODUCT_ID"
fi


Make sure you do a chmod +x /etc/hotplug/usb/datacard .

The above script is simply finding out the same vendor and device ID automagically ;) and doing a modprobe with it.

At this point you should stop your wvdial, proudly take out the card, push it back in and just do a wvdial again.

It should Just WorkTM.

this article was taken from Mailing List (thanks for the author)

No comments: