Minitel_SM.ino 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #include <SoftwareSerial.h>
  2. #include <Minitel.h>
  3. Minitel m(12,13); //Définition pour le Serial du Minitel
  4. SoftwareSerial GSM(2, 3); //Le SoftwareSerial pour le Shield Serial HS CAR ARDUINO UNO = MOISI
  5. void saisieNum();
  6. void saisieTxt();
  7. void send_AT_cmd(const char *at_cmd);
  8. void setup()
  9. {
  10. /****Init Shield GPRS Hardware mode*****/
  11. Serial.begin(19200);
  12. /****Simulation ON/OFF*****/
  13. // pinMode(8, OUTPUT);
  14. // digitalWrite(8, HIGH);
  15. m.clearScreen();
  16. /**** Saisie du code PIN *****/
  17. send_AT_cmd("AT+CPIN=2507");
  18. m.textMode();
  19. m.textColor(WHITE);
  20. m.bgColor(BLACK);
  21. m.text("[*] Set pin code ", 2, 1);
  22. m.text("[ ]", 2, 3);
  23. m.blink();
  24. m.text("Waiting for Auth Network .....", 6, 3);
  25. // send_AT_cmd("");
  26. // delay(15000);
  27. m.noBlink();
  28. m.text("[*]", 2, 3);
  29. m.text("You are now connected ! ", 6, 3);
  30. // send_AT_cmd("AT+CGREG?\r");
  31. }
  32. void loop()
  33. {
  34. // send_AT_cmd("AT+CGATT?\r");
  35. // saisieNum();
  36. /** Faire la fonction saisir Message **/
  37. /** Puis l'envoyer, pardi ! **/
  38. }
  39. void saisieNum() {
  40. m.clearScreen();
  41. m.textMode();
  42. m.textColor(WHITE);
  43. m.bgColor(RED);
  44. m.text(" SMS Sender ", 4, 1);
  45. m.bgColor(BLACK);
  46. m.text("Number : +", 1, 4);
  47. m.cursor();
  48. m.moveCursorTo(12,4);
  49. send_AT_cmd("AT+CMGF=1"); //Mode texte pour SMS
  50. delay(100);
  51. send_AT_cmd("AT+CMGS=\"+"); //Debut commande ATM pour num destinataire
  52. delay(100);
  53. while(1) {
  54. if(m.available()>0) {
  55. char key = NULL;
  56. // Obligation de lire 2 buffer en cas de touche Menu
  57. key = m.getKey();
  58. if(key != NULL) {
  59. if (m.isMenuKey() == true) {
  60. key = m.getKey();
  61. if (key == '8') {
  62. /**** AJOUTER LE CHAR FIN DE COMMANDE AT PUIS PASSER SAISIE MESSAGES ****/
  63. send_AT_cmd("\"");
  64. delay(100);
  65. return saisieTxt();
  66. }
  67. }
  68. else {
  69. m.textChar(key);
  70. Serial.print(key);
  71. delay(100);
  72. // send_AT_cmd(&key);
  73. }
  74. }
  75. }
  76. }
  77. }
  78. void saisieTxt() {
  79. m.text("Message : ", 1, 6);
  80. m.moveCursorTo(1,7);
  81. /*** COMMANDE ATM ***/
  82. while(1) {
  83. if(m.available()>0) {
  84. char key = NULL;
  85. // Obligation de lire 2 buffer en cas de touche Menu
  86. key = m.getKey();
  87. if(key != NULL) {
  88. if (m.isMenuKey() == true) {
  89. key = m.getKey();
  90. if (key == '8') {
  91. /**** AJOUTER LE CHAR CTRL + Z pour fin SMS ****/
  92. GSM.print(char(26));
  93. delay(100);
  94. send_AT_cmd("\r");
  95. delay(100);
  96. return loop();
  97. }
  98. }
  99. else {
  100. m.textChar(key);
  101. GSM.print(key);
  102. delay(100);
  103. // send_AT_cmd(&key);
  104. }
  105. }
  106. }
  107. }
  108. }
  109. void send_AT_cmd(const char *at_cmd)
  110. {
  111. GSM.println(at_cmd);
  112. while(GSM.available()!=0) {
  113. char reponse = GSM.read();
  114. GSM.print(reponse);
  115. }
  116. }