123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- #include <SoftwareSerial.h>
- #include <Minitel.h>
- 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);
- }
|