summaryrefslogtreecommitdiffstats
path: root/package/query3g/files/usr/share/3gmodem/model.gcom
blob: 40dcc409620fcdf7a8575862641839389367abee (plain)
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
opengt
 set com 115200n81
 set comecho off
 set senddelay 0.02
 waitquiet 0.2 0.2

 send "AT^m"
 waitfor 1 "OK","ERROR"

 let $c="AT+CGMI^m"
 gosub readatcmdnr
 let $v=$s

 let $c="AT+CGSN^m"
 gosub readatcmdnr
 let $n=$s

 let $c="AT+CGMM^m"
 gosub readatcmdnr
 print $v,",",$s,",",$n,"\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