directip.gcom 961 B

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