fix URL in specfile - rm svn-keywords
[comgt.git] / operator
1 ############################################################################
2 #  operator - a gcom script for viewing and selecting networks
3 #
4 #           An example of how you might do operator selection when travelling
5 #           in a foreign country.
6 #           Big ToDo - improve the interface!!!
7 #
8 #  Copyright (C) 2003  Paul Hardwick <paul@peck.org>
9 #
10 #  This program is free software; you can redistribute it and/or modify
11 #  it under the terms of the GNU General Public License as published by
12 #  the Free Software Foundation; either version 2 of the License, or
13 #  (at your option) any later version.
14 #
15 #  This program is distributed in the hope that it will be useful,
16 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 #  GNU General Public License for more details.
19 #
20 #  You should have received a copy of the GNU General Public License
21 #  along with this program; if not, write to the Free Software
22 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 #
24 ###########################################################################
25
26 ############################################################################
27 # $Id: gcom.h 10 2006-01-04 12:40:44Z paul $
28 # $HeadURL: http://10.0.0.4/svn/gcom/gcom.h $
29 ############################################################################
30 opengt
31 set com 115200n81
32 set senddelay 0.05
33 waitquiet 2 0.5
34   :operator
35     send "AT+COPS=?^m"
36     waitfor 20 "+COPS=?","Error"
37     if % = -1 goto timeout
38     if % = 0 goto getlist
39     print "Error response from device\n"
40     exit 1
41   :getlist
42     let c=0
43     print "Getting Operator list: "
44   :waiting    
45     print "."
46     get 2 "^m" $s
47     if % = -1 goto stillwaiting
48     waitquiet 1 0.2
49     print "\n"
50     print $s,"\n\n==============================================================\n"
51     print "Format: (Access,Long Name, Short Name, Network ID [,Technology])\n"
52     print "Access: 2 - Registered, 1 - Available, 3 - Forbidden\n"
53     print "Technology: 0 - GSM/GPRS, 2 - UMTS (Not available on all cards)\n"
54     print "\nEnter the Network ID to attempt manual registration\n [blank = automatic selection]:"
55     input $a
56     let a=len($a)
57     dec a
58     let $a=$left($a,a)
59     if $a = "" goto automatic
60     let $b="AT+COPS=1,2,\""+$a
61     let $b=$b+"\"^m"
62     send $b
63     goto waitresult
64   :automatic
65     let $b="AT+COPS=0^m"
66     send $b   
67   :waitresult
68     waitfor 60 "OK","ERR"
69     if % = -1 goto timeout
70     if % = 2 goto failedreg
71     print "Registration request accepted\n"
72     print "Command was: ",$b,"\n"    
73     exit 0
74   :failedreg
75     print "Registration request refused\n"
76     print "Command was: ",$b,"\n"
77     exit 1
78   :stillwaiting
79     if c > 60 goto timeout
80     let c=c+1
81     goto waiting
82   :timeout
83     print "Network Search Timeout\n"
84     exit 1