summaryrefslogtreecommitdiff
path: root/package/network/utils/comgt/files/directip.gcom
blob: afaaacf4ad5b57bcbc80b91c329e0afec9ed7071 (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
opengt
set com 115200n81
set comecho off
set senddelay 0.05
waitquiet 1 0.2

:start
 if $env("USE_AUTH") = "0" goto connect
 send "AT$QCPDPP=3,"
 send $env("USE_AUTH")
 send ",\""
 if $env("USE_USER") <> "" send $env("USE_USER")
 send "\",\""
 if $env("USE_PASS") <> "" send $env("USE_PASS")
 send "\"^m"
 waitfor 5 "OK"
 if % = 0 goto connect
 print "WWAN error. Auth failed.\r\n"
 exit 1

:connect
 send "AT+CFUN=1^m"
 send "AT+CGDCONT=3,\"IP\",\""
 send $env("USE_APN")
 send "\"^m"
 waitfor 5 "OK"
 if % = 0 goto connok
 print "WWAN error. Connection failed.\r\n"
 exit 1

:connok
 let c=1
:loop
 sleep 2
 send "AT+CGATT?^m"
 waitfor 5 "+CGATT: 1"
 if % = 0 goto carrierok
 if c > 10 goto carriererr
 inc c
 goto loop

carriererr:
 print "WWAN error. No carrier.\r\n"
 exit 1

:carrierok
 send "AT!SCACT=1,3^m"
 waitfor 5 "OK"
 if % = 0 goto dialok
 print "WWAN error. Dialing failed.\r\n"
 exit 1

:dialok
 print "WWAN connection established.\r\n"
 exit 0