#include #include Minitel m(53,52); //Dfinition pour le Serial du Minitel void saisieNum(char *num); void saisieTxt(char *txt); void send_AT_cmd(const char *at_cmd); void setup() { /****Init Shield GPRS Hardware mode*****/ Serial.begin(19200); Serial1.begin(19200); /****Simulation ON/OFF*****/ // pinMode(8, OUTPUT); // digitalWrite(8, HIGH); m.clearScreen(); /**** Saisie future du code PIN *****/ m.text("[*] Set pin code ", 2, 1); send_AT_cmd("AT+CPIN=2507\r"); m.textMode(); m.textColor(WHITE); m.bgColor(BLACK); m.text("[ ]", 2, 3); m.blink(); m.text("Waiting for Auth Network .....", 6, 3); m.noBlink(); m.text("[*]", 2, 3); m.text("You are now connected ! ", 6, 3); send_AT_cmd("AT+CGREG?\r"); send_AT_cmd("AT+CMGF=1\r"); //Mode texte pour SMS } void loop() { char num[20]; char txt[160]; // char *cmgs = "AT+CMGS=\"+"; // char *endcmgs = "\""; char cmdcmgs[100]; // strcpy(cmdcmgs, cmgs); // Serial.print(cmdcmgs); //send_AT_cmd("AT+CGATT?\r"); saisieNum(num); saisieTxt(txt); //Serial.print(num); // strcat(cmdcmgs, num); // Serial.print(cmdcmgs); // strcat(cmdcmgs, endcmgs); sprintf(cmdcmgs, "AT+CMGS=\"+%s\"%s\n", num, txt); send_AT_cmd(cmdcmgs); } void saisieNum(char *num) { int strCount = 0; 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); delay(100); 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 COM MANDE AT PUIS PASSER SAISIE MESSAGES ****/ num[strCount]='\0'; return; } } else { m.textChar(key); //print sur minitel // Serial.print(key); //print sur le prompt num[strCount] = key; strCount++; strCount%=19; } } } } } void saisieTxt(char *txt) { int strCount = 0; 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') { txt[strCount]='\x1a'; txt[strCount+1]='\0'; return; } } else { m.textChar(key); txt[strCount] = key; strCount++; strCount%=159; } } } } } void send_AT_cmd(const char *at_cmd) { Serial1.println(at_cmd); Serial.println(at_cmd); while(Serial1.available()>0) { char reponse = Serial1.read(); Serial.print(reponse); } delay(1000); }