|
@@ -1,55 +1,70 @@
|
|
|
#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
|
|
|
+Minitel m(53,52); //Dfinition pour le Serial du Minitel
|
|
|
|
|
|
-void saisieNum();
|
|
|
-void saisieTxt();
|
|
|
+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 du code PIN *****/
|
|
|
- send_AT_cmd("AT+CPIN=2507");
|
|
|
+ /**** 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("[*] Set pin code ", 2, 1);
|
|
|
+ m.bgColor(BLACK);
|
|
|
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");
|
|
|
-
|
|
|
+ send_AT_cmd("AT+CGREG?\r");
|
|
|
+ send_AT_cmd("AT+CMGF=1\r"); //Mode texte pour SMS
|
|
|
+
|
|
|
}
|
|
|
|
|
|
void loop()
|
|
|
{
|
|
|
-// send_AT_cmd("AT+CGATT?\r");
|
|
|
-// saisieNum();
|
|
|
- /** Faire la fonction saisir Message **/
|
|
|
- /** Puis l'envoyer, pardi ! **/
|
|
|
+ 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() {
|
|
|
-
|
|
|
+void saisieNum(char *num) {
|
|
|
+ int strCount = 0;
|
|
|
|
|
|
m.clearScreen();
|
|
|
m.textMode();
|
|
@@ -60,30 +75,29 @@ void saisieNum() {
|
|
|
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(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();
|
|
|
+ /**** AJOUTER LE CHAR FIN DE COM MANDE AT PUIS PASSER SAISIE MESSAGES ****/
|
|
|
+ num[strCount]='\0';
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- m.textChar(key);
|
|
|
- Serial.print(key);
|
|
|
- delay(100);
|
|
|
- // send_AT_cmd(&key);
|
|
|
+ m.textChar(key); //print sur minitel
|
|
|
+// Serial.print(key); //print sur le prompt
|
|
|
+ num[strCount] = key;
|
|
|
+ strCount++;
|
|
|
+ strCount%=19;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -91,7 +105,8 @@ void saisieNum() {
|
|
|
}
|
|
|
|
|
|
|
|
|
-void saisieTxt() {
|
|
|
+void saisieTxt(char *txt) {
|
|
|
+ int strCount = 0;
|
|
|
m.text("Message : ", 1, 6);
|
|
|
m.moveCursorTo(1,7);
|
|
|
/*** COMMANDE ATM ***/
|
|
@@ -104,31 +119,30 @@ void saisieTxt() {
|
|
|
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();
|
|
|
+ txt[strCount]='\x1a';
|
|
|
+ txt[strCount+1]='\0';
|
|
|
+ return;
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
m.textChar(key);
|
|
|
- GSM.print(key);
|
|
|
- delay(100);
|
|
|
- // send_AT_cmd(&key);
|
|
|
+ txt[strCount] = key;
|
|
|
+ strCount++;
|
|
|
+ strCount%=159;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
void send_AT_cmd(const char *at_cmd)
|
|
|
{
|
|
|
- GSM.println(at_cmd);
|
|
|
- while(GSM.available()!=0) {
|
|
|
- char reponse = GSM.read();
|
|
|
- GSM.print(reponse);
|
|
|
+ Serial1.println(at_cmd);
|
|
|
+ Serial.println(at_cmd);
|
|
|
+ while(Serial1.available()>0) {
|
|
|
+ char reponse = Serial1.read();
|
|
|
+ Serial.print(reponse);
|
|
|
}
|
|
|
-}
|
|
|
+ delay(1000);
|
|
|
+}
|