1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
opengt
set com 115200n81
set comecho off
set senddelay 0.02
waitquiet 0.2 0.2
send "AT\^CURC=0^m"
waitfor 5 "OK","ERROR"
let $c="AT+CGMI^m"
gosub readatcmdnr
let $v=$s
if $toupper($mid($v,0,3)) = "ZTE" goto zte
if $toupper($mid($v,0,3)) = "OPT" goto option
if $toupper($mid($v,0,3)) = "SIE" goto sierra
if $toupper($mid($v,0,3)) = "NOV" goto novatel
if $toupper($mid($v,0,3)) = "HUA" goto huawei
if $toupper($mid($v,0,3)) = "VOD" goto vodafone
if $toupper($mid($v,0,3)) = "NOK" goto vodafone
if $toupper($mid($v,0,4)) = "HSPA" goto ccrap
goto generic
:signal-generic
let $c="AT+CSQ^m"
let $r="+CSQ"
gosub readatcmd
return
:cpin-generic
let $c="AT+CPIN?^m"
let $r="+CPIN"
gosub readatcmd
return
:cpin-qualcomm
let $c="AT$QCPINSTAT?^m"
let $r="$QCPINSTAT"
gosub readatcmd
return
:ccrap
gosub cpin-qualcomm
goto generic
:vodafone
gosub cpin-generic
gosub signal-generic
let $c="AT%NWSTATE=1^m"
let $r="%NWSTATE"
gosub readatcmd
goto next
:novatel
gosub cpin-generic
gosub signal-generic
let $c="AT$CNTI=0^m"
let $r="$CNTI"
gosub readatcmd
goto next
:sierra
gosub cpin-generic
gosub signal-generic
let $c="AT*CNTI=0^m"
let $r="*CNTI"
gosub readatcmd
goto next
:option
gosub cpin-generic
gosub signal-generic
let $c="AT_OCTI?^m"
let $r="_OCTI"
gosub readatcmd
let $c="AT_OWCTI?^m"
let $r="_OWCTI"
gosub readatcmd
goto next
:zte
gosub cpin-generic
gosub signal-generic
let $c="AT+COPS?^m"
let $r="+COPS"
gosub readatcmd
let $c="AT+ZPAS?^m"
let $r="+ZPAS"
gosub readatcmd
goto next1
:huawei
gosub cpin-generic
gosub signal-generic
let $c="AT\^SYSINFOEX^m"
let $r="\^SYSINFOEX"
gosub readatcmd
goto next
:generic
gosub cpin-generic
gosub signal-generic
let $c="AT\^SYSINFO^m"
let $r="\^SYSINFO"
gosub readatcmd
:next
let $c="AT+COPS=3,2; +COPS?^m"
let $r="+COPS"
gosub readatcmd
:next1
let $c="AT+CREG=2; +CREG?^m"
let $r="+CREG"
gosub readatcmd
let $c="AT+CGREG=2; +CGREG?^m"
let $r="+CGREG"
gosub readatcmd
let $c="AT+CGEQNEG=1^m"
let $r="+CGEQNEG"
gosub readatcmd
let $c="ATE1; +CGMM^m"
gosub readatcmdnr
print "\nDEVICE:",$v," ",$s,"\n"
exit 0
:readatcmd
let i=5
send $c
:loop
get 1 "^m" $s
let l=len($r)
if len($s) < l goto loop1
if $mid($s,1,l) <> $r goto loop1
print $s
return
:loop1
if len($s) < 2 goto loop2
if $mid($s,1,2) = "ER" return
if $mid($s,1,2) = "CO" return
:loop2
if i = 0 return
let i=i-1
sleep 0.25
goto loop
:readatcmdnr
let i=10
send $c
:loop3
get 1 "^m" $s
if len($s) < 2 goto loop5
if $mid($s,1,2) = "ER" goto loop4
if $mid($s,1,2) = "OK" goto loop5
if $mid($s,1,2) = "AT" goto loop5
if $mid($s,1,2) = "TE" goto loop5
if $mid($s,1,1) = "+" goto loop5
if $mid($s,1,1) = "\^" goto loop5
let l=len($s)
let $s=$mid($s,1,l)
return
:loop4
let $s=""
return
:loop5
if i = 0 return
let i=i-1
sleep 0.25
goto loop3
|