123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #include <SoftwareSerial.h>
- #include <Minitel.h>
- Minitel m(12,13); //Définition pour le Serial du Minitel
- SoftwareSerial GSM(2, 3); //Le SoftwareSerial pour le Shield Serial HS CAR ARDUINO UNO = MOISI
- void saisieNum();
- void saisieTxt();
- void send_AT_cmd(const char *at_cmd);
- void setup()
- {
- /****Init Shield GPRS Hardware mode*****/
- Serial.begin(19200);
- /****Simulation ON/OFF*****/
- // pinMode(8, OUTPUT);
- // digitalWrite(8, HIGH);
- m.clearScreen();
- /**** Saisie du code PIN *****/
- send_AT_cmd("AT+CPIN=2507");
- m.textMode();
- m.textColor(WHITE);
- m.bgColor(BLACK);
- m.text("[*] Set pin code ", 2, 1);
- m.text("[ ]", 2, 3);
- m.blink();
- m.text("Waiting for Auth Network .....", 6, 3);
-
-
-
-
- // send_AT_cmd("");
- // delay(15000);
- m.noBlink();
- m.text("[*]", 2, 3);
- m.text("You are now connected ! ", 6, 3);
- // send_AT_cmd("AT+CGREG?\r");
-
- }
- void loop()
- {
- // send_AT_cmd("AT+CGATT?\r");
- // saisieNum();
- /** Faire la fonction saisir Message **/
- /** Puis l'envoyer, pardi ! **/
-
- }
- void saisieNum() {
-
-
- m.clearScreen();
- m.textMode();
- m.textColor(WHITE);
- m.bgColor(RED);
- m.text(" SMS Sender ", 4, 1);
- m.bgColor(BLACK);
- m.text("Number : +", 1, 4);
- m.cursor();
- m.moveCursorTo(12,4);
- send_AT_cmd("AT+CMGF=1"); //Mode texte pour SMS
- delay(100);
- send_AT_cmd("AT+CMGS=\"+"); //Debut commande ATM pour num destinataire
- delay(100);
- while(1) {
- if(m.available()>0) {
- char key = NULL;
- // Obligation de lire 2 buffer en cas de touche Menu
- key = m.getKey();
- if(key != NULL) {
- if (m.isMenuKey() == true) {
- key = m.getKey();
- if (key == '8') {
- /**** AJOUTER LE CHAR FIN DE COMMANDE AT PUIS PASSER SAISIE MESSAGES ****/
- send_AT_cmd("\"");
- delay(100);
- return saisieTxt();
- }
- }
- else {
- m.textChar(key);
- Serial.print(key);
- delay(100);
- // send_AT_cmd(&key);
- }
- }
- }
- }
- }
- void saisieTxt() {
- m.text("Message : ", 1, 6);
- m.moveCursorTo(1,7);
- /*** COMMANDE ATM ***/
- while(1) {
- if(m.available()>0) {
- char key = NULL;
- // Obligation de lire 2 buffer en cas de touche Menu
- key = m.getKey();
- if(key != NULL) {
- if (m.isMenuKey() == true) {
- key = m.getKey();
- if (key == '8') {
- /**** AJOUTER LE CHAR CTRL + Z pour fin SMS ****/
- GSM.print(char(26));
- delay(100);
- send_AT_cmd("\r");
- delay(100);
- return loop();
- }
- }
- else {
- m.textChar(key);
- GSM.print(key);
- delay(100);
- // send_AT_cmd(&key);
- }
- }
- }
- }
-
- }
- void send_AT_cmd(const char *at_cmd)
- {
- GSM.println(at_cmd);
- while(GSM.available()!=0) {
- char reponse = GSM.read();
- GSM.print(reponse);
- }
- }
|