comgt: add metric, defaultroute and peerdns options for ncm protocol
[openwrt/staging/dedeckeh.git] / package / network / utils / comgt / files / directip.gcom
1 opengt
2 set com 115200n81
3 set comecho off
4 set senddelay 0.05
5 waitquiet 1 0.2
6
7 :start
8 if $env("USE_AUTH") = "0" goto connect
9 send "AT$QCPDPP=3,"
10 send $env("USE_AUTH")
11 send ",\""
12 if $env("USE_USER") <> "" send $env("USE_USER")
13 send "\",\""
14 if $env("USE_PASS") <> "" send $env("USE_PASS")
15 send "\"^m"
16 waitfor 5 "OK"
17 if % = 0 goto connect
18 print "WWAN error. Auth failed.\r\n"
19 exit 1
20
21 :connect
22 send "AT+CFUN=1^m"
23 send "AT+CGDCONT=3,\"IP\",\""
24 send $env("USE_APN")
25 send "\"^m"
26 waitfor 5 "OK"
27 if % = 0 goto connok
28 print "WWAN error. Connection failed.\r\n"
29 exit 1
30
31 :connok
32 let c=1
33 :loop
34 sleep 2
35 send "AT+CGATT?^m"
36 waitfor 5 "+CGATT: 1"
37 if % = 0 goto carrierok
38 if c > 10 goto carriererr
39 inc c
40 goto loop
41
42 :carriererr
43 print "WWAN error. No carrier.\r\n"
44 exit 1
45
46 :carrierok
47 send "AT!SCACT=1,3^m"
48 waitfor 5 "OK"
49 if % = 0 goto dialok
50 print "WWAN error. Dialing failed.\r\n"
51 exit 1
52
53 :dialok
54 print "WWAN connection established.\r\n"
55 exit 0