2010-05-12

UMTS-Stick Console Step-by-Step (part #5485 since 100201).

Foreword: This is still work-in-progress, as I do switch my bootable sticks for real now :-)

You remember my "multi-connection-mobile-routing-device"? Funny, really? Since February I have not found the time to move on with it. Darn Pirates and those elections in Europe. Let's go ahead.

1. You've got an UMTS-stick, f.ex. as backup-modem for your mobile (as the mobile works with it's own battery).
2. You have a very small Debian system as me and do NOT want to install everything as proposed (like 'my first mobile minimal system' ;-).
3. You bought one of those crazy PrePaid-cards with 24h Flatrate incl. a PIN (whyever they want to a PIN - anti-terrorism? - crazy idea).

I found a long script which really looks great for all my needs from which I try to extract the essential commands (I found nothing better):
http://www.salixos.org/forum/viewtopic.php?f=24&t=270

Stated in the script is a small programm called "comgt" - it is not included in Debian Lenny - a short search on the web shows the older version for Lenny was/is "gcom". It needs about 140k of your SSD.
>sudo apt-get install gcom

So, right now, I got one of those strange "HUAWEI" sticks - totally unconfigured and a cheapo-PrePaid-SIM from a supermarket in Germany called "Aldi". Let's check the /var/log/messages
-----
option 5-3:1.0: GSM modem (1-port) converter detected
usb 5-3: GSM modem (1-port) converter now attached to ttyUSB0
option 5-3:1.1: GSM modem (1-port) converter detected
usb 5-3: GSM modem (1-port) converter now attached to ttyUSB1
-----
I am always irritated by naming two TTY-devices ... ok. So we do have ttyUSB0 and ttyUSB1. Let's see what we can get from them.

>~$ gcom -d /dev/ttyUSB0
Enter PIN number: XXXX
Waiting for Registration..(120 sec max)..
Registered on Home network: "MEDIONmobile",2
Signal Quality: 11,99

I am not quite sure if the "Signal Quality" really shows the signal quality or the price I paid for the SIM-card. But is this really working? Has the network accepted the PIN?
A 2nd try:
>~$ gcom -d /dev/ttyUSB0
SIM ready
Waiting for Registration..(120 sec max)
Registered on Home network: "MEDIONmobile",2
Signal Quality: 11,99

Ah. Ok. "SIM ready" - I do believe the scripts's message - for now.
From now on it should be possible with f.ex. 'wvdial' to connect (you are able to hear my laughter, not?)



Famous last words:
Another good resource I have found was at http://www.klabs.be/~fpiat/linux/debian/Option_Qualcomm_MSM6275_UMTS/

For all the freaks:

...here's the long verbosive transcript:

/var/log/messages
----------------------
scsi5 : SCSI emulation for USB Mass Storage devices
scsi6 : SCSI emulation for USB Mass Storage devices
usb 5-3: New USB device found, idVendor=12d1, idProduct=1003
usb 5-3: New USB device strings: Mfr=3, Product=2, SerialNumber=0
May 12 22:09:56 kernel: [ 557.944933] usb 5-3: Product: HUAWEI Mobile
May 12 22:09:56 kernel: [ 557.944933] usb 5-3: Manufacturer: HUAWEI Technology
May 12 22:09:56 kernel: [ 557.949275] usbcore: registered new interface driver usbserial
May 12 22:09:56 kernel: [ 557.949275] usbserial: USB Serial support registered for generic
May 12 22:09:56 kernel: [ 557.949275] usbcore: registered new interface driver usbserial_generic
May 12 22:09:56 kernel: [ 557.949275] usbserial: USB Serial Driver core
May 12 22:09:56 kernel: [ 557.967010] usbserial: USB Serial support registered for GSM modem (1-port)
May 12 22:09:56 kernel: [ 557.967066] option 5-3:1.0: GSM modem (1-port) converter detected
May 12 22:09:56 kernel: [ 557.967371] usb 5-3: GSM modem (1-port) converter now attached to ttyUSB0
May 12 22:09:56 kernel: [ 557.967431] option 5-3:1.1: GSM modem (1-port) converter detected
May 12 22:09:56 kernel: [ 557.967662] usb 5-3: GSM modem (1-port) converter now attached to ttyUSB1
May 12 22:09:56 kernel: [ 557.967741] usbcore: registered new interface driver option
May 12 22:09:56 kernel: [ 557.967756] option: USB Driver for GSM modems: v0.7.2
May 12 22:09:57 kernel: [ 558.957058] scsi 5:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2
May 12 22:09:57 kernel: [ 559.170042] Driver 'sr' needs updating - please use bus_type methods
May 12 22:09:57 kernel: [ 559.191900] sr0: scsi-1 drive
Uniform CD-ROM driver Revision: 3.20
sd 1:0:0:0: Attached scsi generic sg0 type 0
sd 1:0:1:0: Attached scsi generic sg1 type 0
sr 5:0:0:0: Attached scsi generic sg2 type 5
scsi 6:0:0:0: Direct-Access HUAWEI MMC Storage 2.31 PQ: 0 ANSI: 2
sd 6:0:0:0: [sdc] Attached SCSI removable disk
sd 6:0:0:0: Attached scsi generic sg3 type 0
-------------

>~$ gcom -v -d /dev/ttyUSB0
gcom 22:58:10 -> Verbose output enabled
gcom 22:58:10 -> argc:4
gcom 22:58:10 -> argv[0]=gcom
gcom 22:58:10 -> argv[1]=-v
gcom 22:58:10 -> argv[2]=-d
gcom 22:58:10 -> argv[3]=/dev/ttyUSB0
gcom 22:58:10 -> ---Script---
1@0000 opengt
2@0007 set com 115200n81
3@0029 set senddelay 0.05
4@0052 send "AT+CFUN=1^m"
5@0075 waitquiet 1 0.2
6@0095 :start
7@0104 flash 0.1
8@0118 send "AT+CPIN?^m"
9@0140 waitfor 30 "SIM PUK","SIM PIN","READY","ERROR","ERR"
10@0197 if % = -1 goto error
11@0222 if % = 0 goto ready
12@0246 if % = 1 goto getpin
13@0271 if % = 2 goto ready
14@0295 if % = 3 goto error
15@0319 if % = 4 goto error
16@0343 :error
17@0352 print $s," ***SIM ERROR***
18@0383 "
19@0385 print "Check device port configuration.
20@0429 Check SIM is inserted
21@0451 Test SIM in a mobile phone?
22@0479 "
23@0481 exit 1
24@0492 :getpin
25@0502 #handle case where Vodafone 3 generates wrong response
26@0561 waitfor 1 "2"
27@0579 if % = 0 goto ready
28@0603 print "
29@0615 Enter PIN number: "
30@0635 input $x
31@0648 let a=len($x)
32@0666 if a<>5 goto getpin
33@0690 let c=0
34@0702 :test
35@0710 let $c=$mid($x,c,1)
36@0734 if $c<"0" goto getpin
37@0760 if $c>"9" goto getpin
38@0786 inc c
39@0796 if c<4 goto test
40@0817 let a=val($x)
41@0835 if a<0 goto getpin
42@0858 if a>9999 goto getpin
43@0884 let $c=$left($x,4)
44@0907 :enterpin
45@0919 send "AT+CPIN=\""
46@0941 send $c
47@0953 send "\"^m"
48@0969 waitfor 20 "OK","ERR"
49@0995 if % = -1 goto timeerror
50@1024 if % = 0 goto cont
51@1047 if % = 1 goto pinerror
52@1074 :pinerror
53@1086 :timeerror
54@1099 print "ERROR entering PIN code
55@1134 "
56@1136 print "Caution! - entering the wrong PIN code three times will lock the SIM
57@1216 "
58@1218 exit 1
59@1229 :ready
60@1238 print "SIM ready
61@1259 "
62@1261 :cont
63@1269 print "Waiting for Registration..(120 sec max)"
64@1321 let c = 0
65@1335 :waitreg
66@1346 send "AT+CREG?^m"
67@1368 waitfor 2 "+CREG: 0,1","+CREG: 0,5"
68@1408 if % = -1 goto regagain
69@1436 if % = 0 goto homereg
70@1462 if % = 1 goto roamreg
71@1488 :regagain
72@1500 if c > 120 goto regtimeout
73@1531 let c=c+2
74@1545 print "."
75@1559 goto waitreg
76@1576 :regtimeout
77@1590 print "
78@1602 Failed to register
79@1621 "
80@1623 exit 1
81@1634 :homereg
82@1645 print "
83@1657 Registered on Home network: "
84@1687 goto registered
85@1707 :roamreg
86@1718 print "
87@1730 Registered on Roaming network: "
88@1763 goto registered
89@1783 :registered
90@1797 waitquiet 1 0.1
91@1817 send "AT+COPS?^m"
92@1839 get 2 "^m" $s
93@1857 get 2 "^m" $s
94@1875 let a=len($s)
95@1893 let b=a-12
96@1908 if b < 1 goto regtimeout
97@1937 let $c=$right($s,b)
98@1961 print $c,"
99@1976 "
100@1978 let c=0
101@1990 :signal
102@2000 waitquiet 1 0.1
103@2020 send "AT+CSQ^m"
104@2040 get 2 "^m" $s
105@2058 get 2 "^m" $s
106@2076 let a=len($s)
107@2094 let a=a-6
108@2108 let $s=$right($s,a)
109@2132 if $s <> "0,0" goto sigcont
110@2164 if c > 3 goto sigexit
111@2190 let c=c+1
112@2204 pause 1
113@2216 goto signal
114@2232 :sigexit
115@2243 print "Signal strength measure 0,0 too low!"
116@2292 exit 1
117@2303 :sigcont
118@2314 print "Signal Quality:",$s,"\n"
119@2350 waitquiet 1 0.1
gcom 22:58:10 -> ---End of script---
gcom 22:58:10 -> @0000 opengt
gcom 22:58:10 -> Opened /dev/ttyUSB0 as FD 3
gcom 22:58:10 -> @0011 set com 115200n81
gcom 22:58:10 -> @0033 set senddelay 0.05
gcom 22:58:10 -> @0056 send "AT+CFUN=1^m"
gcom 22:58:11 -> @0079 waitquiet 1 0.2
gcom 22:58:11 -> @0097 :start
gcom 22:58:11 -> @0108 flash 0.1
gcom 22:58:11 -> @0122 send "AT+CPIN?^m"
gcom 22:58:12 -> @0144 waitfor 30 "SIM PUK","SIM PIN","READY","ERROR","ERR"
gcom 22:58:12 -> @0201 if % = -1 goto error
gcom 22:58:12 -> @0226 if % = 0 goto ready
gcom 22:58:12 -> @0250 if % = 1 goto getpin
gcom 22:58:12 -> @0259 goto getpin
gcom 22:58:12 -> @0494 :getpin
gcom 22:58:12 -> @0506 #handle case where Vodafone 3 generates wrong response
gcom 22:58:12 -> @0565 waitfor 1 "2"
gcom 22:58:13 -> @0583 if % = 0 goto ready
gcom 22:58:13 -> @0607 print "

Enter PIN number: gcom 22:58:13 -> @0639 input $x

XXXX < this is for sure my PIN ;-)

gcom 22:58:25 -> @0652 let a=len($x)
gcom 22:58:25 -> @0670 if a<>5 goto getpin
gcom 22:58:25 -> @0694 let c=0
gcom 22:58:25 -> @0704 :test
gcom 22:58:25 -> @0714 let $c=$mid($x,c,1)
gcom 22:58:25 -> @0738 if $c<"0" goto getpin
gcom 22:58:25 -> @0764 if $c>"9" goto getpin
gcom 22:58:25 -> @0790 inc c
gcom 22:58:25 -> @0800 if c<4 goto test
gcom 22:58:25 -> @0807 goto test
gcom 22:58:25 -> @0704 :test
gcom 22:58:25 -> @0714 let $c=$mid($x,c,1)
gcom 22:58:25 -> @0738 if $c<"0" goto getpin
gcom 22:58:25 -> @0764 if $c>"9" goto getpin
gcom 22:58:25 -> @0790 inc c
gcom 22:58:25 -> @0800 if c<4 goto test
gcom 22:58:25 -> @0807 goto test
gcom 22:58:25 -> @0704 :test
gcom 22:58:25 -> @0714 let $c=$mid($x,c,1)
gcom 22:58:25 -> @0738 if $c<"0" goto getpin
gcom 22:58:25 -> @0764 if $c>"9" goto getpin
gcom 22:58:25 -> @0790 inc c
gcom 22:58:25 -> @0800 if c<4 goto test
gcom 22:58:25 -> @0807 goto test
gcom 22:58:25 -> @0704 :test
gcom 22:58:25 -> @0714 let $c=$mid($x,c,1)
gcom 22:58:25 -> @0738 if $c<"0" goto getpin
gcom 22:58:25 -> @0764 if $c>"9" goto getpin
gcom 22:58:25 -> @0790 inc c
gcom 22:58:25 -> @0800 if c<4 goto test
gcom 22:58:25 -> @0821 let a=val($x)
gcom 22:58:25 -> @0839 if a<0 goto getpin
gcom 22:58:25 -> @0862 if a>9999 goto getpin
gcom 22:58:25 -> @0888 let $c=$left($x,4)
gcom 22:58:25 -> @0909 :enterpin
gcom 22:58:25 -> @0923 send "AT+CPIN=\""
gcom 22:58:25 -> @0945 send $c
gcom 22:58:26 -> @0957 send "\"^m"
gcom 22:58:26 -> @0973 waitfor 20 "OK","ERR"
gcom 22:58:26 -> @0999 if % = -1 goto timeerror
gcom 22:58:26 -> @1028 if % = 0 goto cont
gcom 22:58:26 -> @1037 goto cont
gcom 22:58:26 -> @1263 :cont
gcom 22:58:26 -> @1273 print "Waiting for Registration..(120 sec max)"
Waiting for Registration..(120 sec max)
gcom 22:58:26 -> @1325 let c = 0
gcom 22:58:26 -> @1337 :waitreg
gcom 22:58:26 -> @1350 send "AT+CREG?^m"
gcom 22:58:26 -> @1372 waitfor 2 "+CREG: 0,1","+CREG: 0,5"
gcom 22:58:28 -> @1412 if % = -1 goto regagain
gcom 22:58:28 -> @1422 goto regagain
gcom 22:58:28 -> @1490 :regagain
gcom 22:58:28 -> @1504 if c > 120 goto regtimeout
gcom 22:58:28 -> @1535 let c=c+2
gcom 22:58:28 -> @1549 print "."
.gcom 22:58:28 -> @1563 goto waitreg
gcom 22:58:28 -> @1337 :waitreg
gcom 22:58:28 -> @1350 send "AT+CREG?^m"
gcom 22:58:29 -> @1372 waitfor 2 "+CREG: 0,1","+CREG: 0,5"
gcom 22:58:31 -> @1412 if % = -1 goto regagain
gcom 22:58:31 -> @1422 goto regagain
gcom 22:58:31 -> @1490 :regagain
gcom 22:58:31 -> @1504 if c > 120 goto regtimeout
gcom 22:58:31 -> @1535 let c=c+2
gcom 22:58:31 -> @1549 print "."
.gcom 22:58:31 -> @1563 goto waitreg
gcom 22:58:31 -> @1337 :waitreg
gcom 22:58:31 -> @1350 send "AT+CREG?^m"
gcom 22:58:31 -> @1372 waitfor 2 "+CREG: 0,1","+CREG: 0,5"
gcom 22:58:31 -> @1412 if % = -1 goto regagain
gcom 22:58:31 -> @1440 if % = 0 goto homereg
gcom 22:58:31 -> @1449 goto homereg
gcom 22:58:31 -> @1636 :homereg
gcom 22:58:31 -> @1649 print "
Registered on Home network:
gcom 22:58:31 -> @1691 goto registered
gcom 22:58:31 -> @1785 :registered
gcom 22:58:31 -> @1801 waitquiet 1 0.1
gcom 22:58:31 -> @1821 send "AT+COPS?^m"
gcom 22:58:32 -> @1843 get 2 "^m" $s
gcom 22:58:32 -> @1861 get 2 "^m" $s
gcom 22:58:32 -> @1879 let a=len($s)
gcom 22:58:32 -> @1897 let b=a-12
gcom 22:58:32 -> @1912 if b < 1 goto regtimeout
gcom 22:58:32 -> @1941 let $c=$right($s,b)
gcom 22:58:32 -> @1965 print $c,"
"MEDIONmobile",2
gcom 22:58:32 -> @1982 let c=0
gcom 22:58:32 -> @1992 :signal
gcom 22:58:32 -> @2004 waitquiet 1 0.1
gcom 22:58:32 -> @2024 send "AT+CSQ^m"
gcom 22:58:32 -> @2044 get 2 "^m" $s
gcom 22:58:32 -> @2062 get 2 "^m" $s
gcom 22:58:32 -> @2080 let a=len($s)
gcom 22:58:32 -> @2098 let a=a-6
gcom 22:58:32 -> @2112 let $s=$right($s,a)
gcom 22:58:32 -> @2136 if $s <> "0,0" goto sigcont
gcom 22:58:32 -> @2151 goto sigcont
gcom 22:58:32 -> @2305 :sigcont
gcom 22:58:32 -> @2318 print "Signal Quality:",$s,"\n"
Signal Quality: 14,99
gcom 22:58:32 -> @2354 waitquiet 1 0.1
gcom 22:58:33 -> Exit with code 0.