1
0

setpin.gcom 919 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # set pin code from evnironment "$PINCODE"
  2. opengt
  3. set com 115200n81
  4. set senddelay 0.05
  5. waitquiet 3 0.5
  6. flash 0.1
  7. let c=0
  8. :start
  9. send "AT+CPIN?^m"
  10. waitfor 15 "SIM PUK","SIM PIN","READY","ERROR","ERR"
  11. if % = -1 goto timeout
  12. if % = 0 goto ready
  13. if % = 1 goto setpin
  14. if % = 2 goto ready
  15. if % = 3 goto checkrepeat
  16. if % = 4 goto checkrepeat
  17. :checkrepeat
  18. inc c
  19. if c>3 goto pinerror
  20. waitquiet 12 0.5
  21. goto start
  22. :timeout
  23. print "timeout checking for PIN."
  24. exit 1
  25. :ready
  26. print "SIM ready\n"
  27. goto continue
  28. exit 0
  29. :setpin
  30. # check if output was "SIM PIN2", that's ok.
  31. waitfor 1 "2"
  32. if % = 0 goto ready
  33. print "Trying to set PIN\n"
  34. send "AT+CPIN=\""
  35. send $env("PINCODE")
  36. send "\"^m"
  37. waitfor 20 "OK","ERR"
  38. if % = -1 goto pinerror
  39. if % = 0 goto continue
  40. if % = 1 goto pinerror
  41. :pinerror
  42. print "Error setting PIN, check card manually\n"
  43. exit 1
  44. :continue
  45. print "PIN set successfully\n"
  46. exit 0