|
@@ -0,0 +1,134 @@
|
|
|
+#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);
|
|
|
+ }
|
|
|
+}
|