waitready.comgt 527 B

12345678910111213141516171819202122232425262728293031323334
  1. # wait till the sim is ready
  2. opengt
  3. set com 115200n81
  4. set senddelay 0.02
  5. waitquiet 1 0.2
  6. flash 0.1
  7. :start
  8. print "Waiting for SIM..."
  9. let c=0
  10. :waitready
  11. send "AT+CPIN?^m"
  12. waitfor 2 "SIM PUK","SIM PIN","READY","ERROR","ERR"
  13. if % = -1 goto tryagain
  14. if % = 0 goto simready
  15. if % = 1 goto simready
  16. if % = 2 goto simready
  17. if % = 3 goto tryagain
  18. if % = 4 goto tryagain
  19. :tryagain
  20. if c > 120 goto waittimeout
  21. let c=c+2
  22. print "."
  23. goto waitready
  24. :waittimeout
  25. print " Timeout
  26. "
  27. exit 1
  28. :simready
  29. print " OK
  30. "
  31. exit 0