Program which allow to send/receive and treat SMS messages by connecting a GSM module to the mbed.

Dependencies:   mbed

Committer:
khettat
Date:
Fri Jun 22 15:25:11 2012 +0000
Revision:
0:1bfc880cdffe
Child:
1:842dea2b7fcf

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
khettat 0:1bfc880cdffe 1 #include "mbed.h"
khettat 0:1bfc880cdffe 2
khettat 0:1bfc880cdffe 3
khettat 0:1bfc880cdffe 4 /***********************************************/
khettat 0:1bfc880cdffe 5 /* Declaration des variables globales */
khettat 0:1bfc880cdffe 6 /***********************************************/
khettat 0:1bfc880cdffe 7 //GSM module connected to pin 13 and 14
khettat 0:1bfc880cdffe 8 Serial GSM(p13,p14);
khettat 0:1bfc880cdffe 9 //PC UART's definition
khettat 0:1bfc880cdffe 10 Serial pc(USBTX,USBRX);
khettat 0:1bfc880cdffe 11 //Declaration d'un Ticker
khettat 0:1bfc880cdffe 12 Ticker t1, t2, t3, t4;
khettat 0:1bfc880cdffe 13 //Definition des LED
khettat 0:1bfc880cdffe 14 DigitalOut myled1(LED1);
khettat 0:1bfc880cdffe 15 DigitalOut myled2(LED2);
khettat 0:1bfc880cdffe 16 DigitalOut myled3(LED3);
khettat 0:1bfc880cdffe 17 DigitalOut myled4(LED4);
khettat 0:1bfc880cdffe 18 //Autres variables
khettat 0:1bfc880cdffe 19 #define BUFSIZE 200
khettat 0:1bfc880cdffe 20 volatile bool FlagRx = false; //Se met � 1 lors de la reception d'une r�ponse compl�te
khettat 0:1bfc880cdffe 21 volatile bool FlagSMS = false; //On le met a 1 lorsque on lit un SMS pour executer la fonction 3 fois
khettat 0:1bfc880cdffe 22 unsigned int etat = 0, taille = 0, k = 0; //utilis� dans l'automate de r�ception pour definir l'�tat
khettat 0:1bfc880cdffe 23 volatile unsigned char BufferRx[BUFSIZE];//Buffer de reception
khettat 0:1bfc880cdffe 24 volatile unsigned char BufSMS[BUFSIZE];//Buffer de reception
khettat 0:1bfc880cdffe 25 volatile unsigned char i = 0, c;
khettat 0:1bfc880cdffe 26
khettat 0:1bfc880cdffe 27 /**************************************************************/
khettat 0:1bfc880cdffe 28 /* Fonction de reception de donnees par interruption */
khettat 0:1bfc880cdffe 29 /**************************************************************/
khettat 0:1bfc880cdffe 30 void Receive(void)
khettat 0:1bfc880cdffe 31 {
khettat 0:1bfc880cdffe 32 c = GSM.getc();
khettat 0:1bfc880cdffe 33 //pc.putc(c);
khettat 0:1bfc880cdffe 34 //myled2 = !myled2;
khettat 0:1bfc880cdffe 35 if(FlagSMS == 0)
khettat 0:1bfc880cdffe 36 {
khettat 0:1bfc880cdffe 37
khettat 0:1bfc880cdffe 38 switch(c)
khettat 0:1bfc880cdffe 39 {
khettat 0:1bfc880cdffe 40 case 0x0D :
khettat 0:1bfc880cdffe 41 if(etat == 0)//Debutde la reception
khettat 0:1bfc880cdffe 42 {
khettat 0:1bfc880cdffe 43 etat = 1;
khettat 0:1bfc880cdffe 44 //pc.printf("etat 1\r\n");
khettat 0:1bfc880cdffe 45 }
khettat 0:1bfc880cdffe 46 if(etat == 2)//Reception du 0x0D de la fin
khettat 0:1bfc880cdffe 47 {
khettat 0:1bfc880cdffe 48 etat = 3;
khettat 0:1bfc880cdffe 49 //pc.printf("etat 3\r\n");
khettat 0:1bfc880cdffe 50 }
khettat 0:1bfc880cdffe 51 break;
khettat 0:1bfc880cdffe 52 case 0x0A :
khettat 0:1bfc880cdffe 53 if(etat == 1)//Toujours au debutde la reception
khettat 0:1bfc880cdffe 54 {
khettat 0:1bfc880cdffe 55 etat = 2;
khettat 0:1bfc880cdffe 56 //pc.printf("etat 2\r\n");
khettat 0:1bfc880cdffe 57 }
khettat 0:1bfc880cdffe 58 if(etat == 3)//Reception du 0x0A de la fin
khettat 0:1bfc880cdffe 59 {
khettat 0:1bfc880cdffe 60 etat = 0;
khettat 0:1bfc880cdffe 61 //pc.printf("ret etat 0\r\n");
khettat 0:1bfc880cdffe 62 taille = i;
khettat 0:1bfc880cdffe 63 i = 0;
khettat 0:1bfc880cdffe 64 FlagRx = 1;
khettat 0:1bfc880cdffe 65 }
khettat 0:1bfc880cdffe 66 break;
khettat 0:1bfc880cdffe 67 default :
khettat 0:1bfc880cdffe 68 if((etat == 2) && !(c == 0x0D))//Debutde lecture de la reponse
khettat 0:1bfc880cdffe 69 {
khettat 0:1bfc880cdffe 70 BufferRx[i] = c;
khettat 0:1bfc880cdffe 71 //pc.printf("default\r\n");
khettat 0:1bfc880cdffe 72 i++;
khettat 0:1bfc880cdffe 73 }
khettat 0:1bfc880cdffe 74 }
khettat 0:1bfc880cdffe 75 }
khettat 0:1bfc880cdffe 76 else
khettat 0:1bfc880cdffe 77 {
khettat 0:1bfc880cdffe 78 switch(c)
khettat 0:1bfc880cdffe 79 {
khettat 0:1bfc880cdffe 80 case 0x0D :
khettat 0:1bfc880cdffe 81 if(etat == 0)//Debutde la reception
khettat 0:1bfc880cdffe 82 {
khettat 0:1bfc880cdffe 83 etat = 1;
khettat 0:1bfc880cdffe 84 //pc.printf("etat 1\r\n");
khettat 0:1bfc880cdffe 85 }
khettat 0:1bfc880cdffe 86 if(etat == 2)//Reception du 0x0D de la fin
khettat 0:1bfc880cdffe 87 {
khettat 0:1bfc880cdffe 88 etat = 3;
khettat 0:1bfc880cdffe 89 //pc.printf("etat 3\r\n");
khettat 0:1bfc880cdffe 90 }
khettat 0:1bfc880cdffe 91 if(etat == 4)//Reception du 0x0D de la fin
khettat 0:1bfc880cdffe 92 {
khettat 0:1bfc880cdffe 93 etat = 5;
khettat 0:1bfc880cdffe 94 //pc.printf("etat 5\r\n");
khettat 0:1bfc880cdffe 95 }
khettat 0:1bfc880cdffe 96 if(etat == 6)//Reception du 0x0D de la fin
khettat 0:1bfc880cdffe 97 {
khettat 0:1bfc880cdffe 98 etat = 7;
khettat 0:1bfc880cdffe 99 //pc.printf("etat 3\r\n");
khettat 0:1bfc880cdffe 100 }
khettat 0:1bfc880cdffe 101 if(etat == 8)//Reception du 0x0D de la fin
khettat 0:1bfc880cdffe 102 {
khettat 0:1bfc880cdffe 103 etat = 9;
khettat 0:1bfc880cdffe 104 //pc.printf("etat 3\r\n");
khettat 0:1bfc880cdffe 105 }
khettat 0:1bfc880cdffe 106 break;
khettat 0:1bfc880cdffe 107 case 0x0A :
khettat 0:1bfc880cdffe 108 if(etat == 1)//Toujours au debutde la reception
khettat 0:1bfc880cdffe 109 {
khettat 0:1bfc880cdffe 110 etat = 2;
khettat 0:1bfc880cdffe 111 //pc.printf("etat 2\r\n");
khettat 0:1bfc880cdffe 112 }
khettat 0:1bfc880cdffe 113 if(etat == 3)//Reception du 0x0A de la fin
khettat 0:1bfc880cdffe 114 {
khettat 0:1bfc880cdffe 115 etat = 4;
khettat 0:1bfc880cdffe 116 //pc.printf("etat 4\r\n");
khettat 0:1bfc880cdffe 117 }
khettat 0:1bfc880cdffe 118 if(etat == 5)//Reception du 0x0D de la fin
khettat 0:1bfc880cdffe 119 {
khettat 0:1bfc880cdffe 120 etat = 6;
khettat 0:1bfc880cdffe 121 //pc.printf("etat 6\r\n");
khettat 0:1bfc880cdffe 122 }
khettat 0:1bfc880cdffe 123 if(etat == 7)//Reception du 0x0D de la fin
khettat 0:1bfc880cdffe 124 {
khettat 0:1bfc880cdffe 125 etat = 8;
khettat 0:1bfc880cdffe 126 //pc.printf("etat 8\r\n");
khettat 0:1bfc880cdffe 127 }
khettat 0:1bfc880cdffe 128 if(etat == 9)//Reception du 0x0A de la fin
khettat 0:1bfc880cdffe 129 {
khettat 0:1bfc880cdffe 130 etat = 0;
khettat 0:1bfc880cdffe 131 //pc.printf("ret etat 0\r\n");
khettat 0:1bfc880cdffe 132 FlagSMS=0;
khettat 0:1bfc880cdffe 133 taille = i;
khettat 0:1bfc880cdffe 134 i = 0;
khettat 0:1bfc880cdffe 135 FlagRx = 1;
khettat 0:1bfc880cdffe 136 }
khettat 0:1bfc880cdffe 137 break;
khettat 0:1bfc880cdffe 138 default :
khettat 0:1bfc880cdffe 139 if((etat == 4) && !(c == 0x0D))//Debutde lecture de la reponse
khettat 0:1bfc880cdffe 140 {
khettat 0:1bfc880cdffe 141 BufferRx[i] = c;
khettat 0:1bfc880cdffe 142 //pc.printf("default\r\n");
khettat 0:1bfc880cdffe 143 i++;
khettat 0:1bfc880cdffe 144 }
khettat 0:1bfc880cdffe 145 }
khettat 0:1bfc880cdffe 146 }
khettat 0:1bfc880cdffe 147 }
khettat 0:1bfc880cdffe 148
khettat 0:1bfc880cdffe 149 /****************************************************/
khettat 0:1bfc880cdffe 150 /* Fonction d'envoi de test avec le ticker */
khettat 0:1bfc880cdffe 151 /****************************************************/
khettat 0:1bfc880cdffe 152 void SendTest(void)
khettat 0:1bfc880cdffe 153 {
khettat 0:1bfc880cdffe 154 //GSM.printf("AT+CNMI?");
khettat 0:1bfc880cdffe 155 GSM.printf("AT+CNMI?");
khettat 0:1bfc880cdffe 156 GSM.putc(0x0D);
khettat 0:1bfc880cdffe 157 myled1 = !myled1;
khettat 0:1bfc880cdffe 158 }
khettat 0:1bfc880cdffe 159
khettat 0:1bfc880cdffe 160 /******************/
khettat 0:1bfc880cdffe 161 /* Blink */
khettat 0:1bfc880cdffe 162 /******************/
khettat 0:1bfc880cdffe 163 void Blink1(void)
khettat 0:1bfc880cdffe 164 {
khettat 0:1bfc880cdffe 165 myled1 = !myled1;
khettat 0:1bfc880cdffe 166 }
khettat 0:1bfc880cdffe 167 void Blink2(void)
khettat 0:1bfc880cdffe 168 {
khettat 0:1bfc880cdffe 169 myled2 = !myled2;
khettat 0:1bfc880cdffe 170 }
khettat 0:1bfc880cdffe 171 void Blink3(void)
khettat 0:1bfc880cdffe 172 {
khettat 0:1bfc880cdffe 173 myled3 = !myled3;
khettat 0:1bfc880cdffe 174 }
khettat 0:1bfc880cdffe 175 void Blink4(void)
khettat 0:1bfc880cdffe 176 {
khettat 0:1bfc880cdffe 177 myled4 = !myled4;
khettat 0:1bfc880cdffe 178 }
khettat 0:1bfc880cdffe 179
khettat 0:1bfc880cdffe 180 /********************************************/
khettat 0:1bfc880cdffe 181 /* Signaled que la carte est pr�te */
khettat 0:1bfc880cdffe 182 /********************************************/
khettat 0:1bfc880cdffe 183 void Ready(void)
khettat 0:1bfc880cdffe 184 {
khettat 0:1bfc880cdffe 185 myled1 = 1;
khettat 0:1bfc880cdffe 186 myled2 = 1;
khettat 0:1bfc880cdffe 187 myled3 = 1;
khettat 0:1bfc880cdffe 188 myled4 = 1;
khettat 0:1bfc880cdffe 189 wait(2);
khettat 0:1bfc880cdffe 190 myled1 = 0;
khettat 0:1bfc880cdffe 191 myled2 = 0;
khettat 0:1bfc880cdffe 192 myled3 = 0;
khettat 0:1bfc880cdffe 193 myled4 = 0;
khettat 0:1bfc880cdffe 194 }
khettat 0:1bfc880cdffe 195
khettat 0:1bfc880cdffe 196 /********************************/
khettat 0:1bfc880cdffe 197 /* Fonction de parsing */
khettat 0:1bfc880cdffe 198 /********************************/
khettat 0:1bfc880cdffe 199 void Parse(unsigned int taille)
khettat 0:1bfc880cdffe 200 {
khettat 0:1bfc880cdffe 201 unsigned int j = 0;
khettat 0:1bfc880cdffe 202 //Test de reception d'un nouvel SMS
khettat 0:1bfc880cdffe 203 if((BufferRx[1]=='C')&&(BufferRx[2]=='M')&&(BufferRx[3]=='T')&&(BufferRx[4]=='I'))
khettat 0:1bfc880cdffe 204 {
khettat 0:1bfc880cdffe 205 //Lecture de l'SMS recu
khettat 0:1bfc880cdffe 206 pc.printf("SMS :");
khettat 0:1bfc880cdffe 207 FlagSMS = 1;
khettat 0:1bfc880cdffe 208 etat = 0;
khettat 0:1bfc880cdffe 209 GSM.printf("AT+CMGR=");
khettat 0:1bfc880cdffe 210 for(j=12;j<taille;j++)
khettat 0:1bfc880cdffe 211 {
khettat 0:1bfc880cdffe 212 GSM.putc(BufferRx[j]);
khettat 0:1bfc880cdffe 213 pc.putc(BufferRx[j]);
khettat 0:1bfc880cdffe 214 }
khettat 0:1bfc880cdffe 215 GSM.putc(0x0D);
khettat 0:1bfc880cdffe 216 pc.printf("\r\n");
khettat 0:1bfc880cdffe 217 while(FlagSMS){;}
khettat 0:1bfc880cdffe 218 //Commande L1ON
khettat 0:1bfc880cdffe 219 if((BufferRx[0]=='L')&&(BufferRx[1]=='1')&&(BufferRx[2]=='O')&&(BufferRx[3]=='N'))
khettat 0:1bfc880cdffe 220 {
khettat 0:1bfc880cdffe 221 myled1 = 1;
khettat 0:1bfc880cdffe 222 }
khettat 0:1bfc880cdffe 223 //Commande L1OF
khettat 0:1bfc880cdffe 224 if((BufferRx[0]=='L')&&(BufferRx[1]=='1')&&(BufferRx[2]=='O')&&(BufferRx[3]=='F'))
khettat 0:1bfc880cdffe 225 {
khettat 0:1bfc880cdffe 226 myled1 = 0;
khettat 0:1bfc880cdffe 227 }
khettat 0:1bfc880cdffe 228 //Commande L2ON
khettat 0:1bfc880cdffe 229 if((BufferRx[0]=='L')&&(BufferRx[1]=='2')&&(BufferRx[2]=='O')&&(BufferRx[3]=='N'))
khettat 0:1bfc880cdffe 230 {
khettat 0:1bfc880cdffe 231 myled2 = 1;
khettat 0:1bfc880cdffe 232 }
khettat 0:1bfc880cdffe 233 //Commande L2OF
khettat 0:1bfc880cdffe 234 if((BufferRx[0]=='L')&&(BufferRx[1]=='2')&&(BufferRx[2]=='O')&&(BufferRx[3]=='F'))
khettat 0:1bfc880cdffe 235 {
khettat 0:1bfc880cdffe 236 myled2 = 0;
khettat 0:1bfc880cdffe 237 }
khettat 0:1bfc880cdffe 238 //Commande L3ON
khettat 0:1bfc880cdffe 239 if((BufferRx[0]=='L')&&(BufferRx[1]=='3')&&(BufferRx[2]=='O')&&(BufferRx[3]=='N'))
khettat 0:1bfc880cdffe 240 {
khettat 0:1bfc880cdffe 241 myled3 = 1;
khettat 0:1bfc880cdffe 242 }
khettat 0:1bfc880cdffe 243 //Commande L3OF
khettat 0:1bfc880cdffe 244 if((BufferRx[0]=='L')&&(BufferRx[1]=='3')&&(BufferRx[2]=='O')&&(BufferRx[3]=='F'))
khettat 0:1bfc880cdffe 245 {
khettat 0:1bfc880cdffe 246 myled3 = 0;
khettat 0:1bfc880cdffe 247 }
khettat 0:1bfc880cdffe 248 //Commande L4ON
khettat 0:1bfc880cdffe 249 if((BufferRx[0]=='L')&&(BufferRx[1]=='4')&&(BufferRx[2]=='O')&&(BufferRx[3]=='N'))
khettat 0:1bfc880cdffe 250 {
khettat 0:1bfc880cdffe 251 myled4 = 1;
khettat 0:1bfc880cdffe 252 }
khettat 0:1bfc880cdffe 253 //Commande L4OF
khettat 0:1bfc880cdffe 254 if((BufferRx[0]=='L')&&(BufferRx[1]=='4')&&(BufferRx[2]=='O')&&(BufferRx[3]=='F'))
khettat 0:1bfc880cdffe 255 {
khettat 0:1bfc880cdffe 256 myled4 = 0;
khettat 0:1bfc880cdffe 257 }
khettat 0:1bfc880cdffe 258 //Commande L1BO
khettat 0:1bfc880cdffe 259 if((BufferRx[0]=='L')&&(BufferRx[1]=='1')&&(BufferRx[2]=='B')&&(BufferRx[3]=='O'))
khettat 0:1bfc880cdffe 260 {
khettat 0:1bfc880cdffe 261 t1.attach(&Blink1, 0.5);
khettat 0:1bfc880cdffe 262 }
khettat 0:1bfc880cdffe 263 //Commande L1BS
khettat 0:1bfc880cdffe 264 if((BufferRx[0]=='L')&&(BufferRx[1]=='1')&&(BufferRx[2]=='B')&&(BufferRx[3]=='S'))
khettat 0:1bfc880cdffe 265 {
khettat 0:1bfc880cdffe 266 t1.detach();
khettat 0:1bfc880cdffe 267 myled1 = 0;
khettat 0:1bfc880cdffe 268 }
khettat 0:1bfc880cdffe 269 //Commande L2BO
khettat 0:1bfc880cdffe 270 if((BufferRx[0]=='L')&&(BufferRx[1]=='2')&&(BufferRx[2]=='B')&&(BufferRx[3]=='O'))
khettat 0:1bfc880cdffe 271 {
khettat 0:1bfc880cdffe 272 t2.attach(&Blink2, 0.5);
khettat 0:1bfc880cdffe 273 }
khettat 0:1bfc880cdffe 274 //Commande L2BS
khettat 0:1bfc880cdffe 275 if((BufferRx[0]=='L')&&(BufferRx[1]=='2')&&(BufferRx[2]=='B')&&(BufferRx[3]=='S'))
khettat 0:1bfc880cdffe 276 {
khettat 0:1bfc880cdffe 277 t2.detach();
khettat 0:1bfc880cdffe 278 myled2 = 0;
khettat 0:1bfc880cdffe 279 }
khettat 0:1bfc880cdffe 280 //Commande L3BO
khettat 0:1bfc880cdffe 281 if((BufferRx[0]=='L')&&(BufferRx[1]=='3')&&(BufferRx[2]=='B')&&(BufferRx[3]=='O'))
khettat 0:1bfc880cdffe 282 {
khettat 0:1bfc880cdffe 283 t3.attach(&Blink3, 0.5);
khettat 0:1bfc880cdffe 284 }
khettat 0:1bfc880cdffe 285 //Commande L3BS
khettat 0:1bfc880cdffe 286 if((BufferRx[0]=='L')&&(BufferRx[1]=='3')&&(BufferRx[2]=='B')&&(BufferRx[3]=='S'))
khettat 0:1bfc880cdffe 287 {
khettat 0:1bfc880cdffe 288 t3.detach();
khettat 0:1bfc880cdffe 289 myled3 = 0;
khettat 0:1bfc880cdffe 290 }
khettat 0:1bfc880cdffe 291 //Commande L4BO
khettat 0:1bfc880cdffe 292 if((BufferRx[0]=='L')&&(BufferRx[1]=='4')&&(BufferRx[2]=='B')&&(BufferRx[3]=='O'))
khettat 0:1bfc880cdffe 293 {
khettat 0:1bfc880cdffe 294 t4.attach(&Blink4, 0.5);
khettat 0:1bfc880cdffe 295 }
khettat 0:1bfc880cdffe 296 //Commande L4BS
khettat 0:1bfc880cdffe 297 if((BufferRx[0]=='L')&&(BufferRx[1]=='4')&&(BufferRx[2]=='B')&&(BufferRx[3]=='S'))
khettat 0:1bfc880cdffe 298 {
khettat 0:1bfc880cdffe 299 t4.detach();
khettat 0:1bfc880cdffe 300 myled4 = 0;
khettat 0:1bfc880cdffe 301 }
khettat 0:1bfc880cdffe 302 }
khettat 0:1bfc880cdffe 303 }
khettat 0:1bfc880cdffe 304
khettat 0:1bfc880cdffe 305 /***************************/
khettat 0:1bfc880cdffe 306 /* Initialisation */
khettat 0:1bfc880cdffe 307 /***************************/
khettat 0:1bfc880cdffe 308 void Init(void)
khettat 0:1bfc880cdffe 309 {
khettat 0:1bfc880cdffe 310 GSM.baud(115200);//GSM baudrate
khettat 0:1bfc880cdffe 311 GSM.format(8,Serial::None,1); //Serial frame format
khettat 0:1bfc880cdffe 312
khettat 0:1bfc880cdffe 313 GSM.printf("AT+CPIN=1234");//Entrer le code PIN
khettat 0:1bfc880cdffe 314 GSM.putc(0x0D);//envoi du caractere \n
khettat 0:1bfc880cdffe 315 pc.printf("Saisie code PIN...\r\n");
khettat 0:1bfc880cdffe 316 wait(5);
khettat 0:1bfc880cdffe 317 GSM.printf("AT+CNMI=1,1");//Configurer le mode de signalement des nouveaux SMS recus
khettat 0:1bfc880cdffe 318 GSM.putc(0x0D);//envoi du caractere \n
khettat 0:1bfc880cdffe 319 // myled4 = 1;
khettat 0:1bfc880cdffe 320 pc.printf("Config de l'alerte SMS\r\n");
khettat 0:1bfc880cdffe 321 wait(2);
khettat 0:1bfc880cdffe 322
khettat 0:1bfc880cdffe 323 GSM.printf("AT+CMGF=1");//Configurer le module en mode text
khettat 0:1bfc880cdffe 324 GSM.putc(0x0D);//envoi du caractere \n
khettat 0:1bfc880cdffe 325 // myled1 = 1;
khettat 0:1bfc880cdffe 326 pc.printf("Passage en mode ""TEXT""\r\n");
khettat 0:1bfc880cdffe 327 wait(2);
khettat 0:1bfc880cdffe 328 /*GSM.printf("AT+CMGS=0647151425");//Initialisation de l'nvoi de l'SMS au moniteur
khettat 0:1bfc880cdffe 329 GSM.putc(0x0D);
khettat 0:1bfc880cdffe 330 myled2 =1;
khettat 0:1bfc880cdffe 331 //pc.printf("num\r\n");
khettat 0:1bfc880cdffe 332 wait(2);
khettat 0:1bfc880cdffe 333 GSM.printf("MBEDOK");//Text du SMS
khettat 0:1bfc880cdffe 334 GSM.putc(0x1A);//Ctrl+Z pour valider l'envoi
khettat 0:1bfc880cdffe 335 wait(5);//Attente de 5s le temps que le SMS parte
khettat 0:1bfc880cdffe 336 pc.printf("Envoi OK\r\n");
khettat 0:1bfc880cdffe 337 myled3 = 1;*/
khettat 0:1bfc880cdffe 338 pc.printf("Fin de l'init...\r\n");
khettat 0:1bfc880cdffe 339 //Vider le buffer de reception
khettat 0:1bfc880cdffe 340 /*for (i=0; i<BUFSIZE; i++) { // vider le buffer
khettat 0:1bfc880cdffe 341 BufferRx[i] = 0;
khettat 0:1bfc880cdffe 342 }*/
khettat 0:1bfc880cdffe 343 etat = 0;
khettat 0:1bfc880cdffe 344 i=0;//reinitialisation de i
khettat 0:1bfc880cdffe 345 FlagSMS = 0;
khettat 0:1bfc880cdffe 346 wait(5);
khettat 0:1bfc880cdffe 347 GSM.attach(&Receive, GSM.RxIrq);//Definition d'une interruption sur la reception de caractere du GSM
khettat 0:1bfc880cdffe 348 pc.printf("Ready...\r\n");
khettat 0:1bfc880cdffe 349 etat = 0;
khettat 0:1bfc880cdffe 350 Ready();
khettat 0:1bfc880cdffe 351 }
khettat 0:1bfc880cdffe 352
khettat 0:1bfc880cdffe 353 int main()
khettat 0:1bfc880cdffe 354 {
khettat 0:1bfc880cdffe 355
khettat 0:1bfc880cdffe 356 Init();
khettat 0:1bfc880cdffe 357
khettat 0:1bfc880cdffe 358 //Routine d'effacement d'SMS
khettat 0:1bfc880cdffe 359 /*for(j=21;j>0;j--)
khettat 0:1bfc880cdffe 360 {
khettat 0:1bfc880cdffe 361 GSM.printf("AT+CMGD=%d",j);
khettat 0:1bfc880cdffe 362 GSM.putc(0x0D);
khettat 0:1bfc880cdffe 363 pc.printf("Effacement SMS N %d\r\n",j);
khettat 0:1bfc880cdffe 364
khettat 0:1bfc880cdffe 365 wait(1);
khettat 0:1bfc880cdffe 366 }*/
khettat 0:1bfc880cdffe 367
khettat 0:1bfc880cdffe 368 while(1)
khettat 0:1bfc880cdffe 369 {
khettat 0:1bfc880cdffe 370 if(FlagRx == 1)
khettat 0:1bfc880cdffe 371 {
khettat 0:1bfc880cdffe 372 FlagRx = 0;
khettat 0:1bfc880cdffe 373
khettat 0:1bfc880cdffe 374 /*for(j=0;j<taille;j++)
khettat 0:1bfc880cdffe 375 {
khettat 0:1bfc880cdffe 376 pc.putc(BufferRx[j]);
khettat 0:1bfc880cdffe 377 }*/
khettat 0:1bfc880cdffe 378 //pc.printf("\r\n");
khettat 0:1bfc880cdffe 379 if(FlagSMS == 0)
khettat 0:1bfc880cdffe 380 {
khettat 0:1bfc880cdffe 381 Parse(taille);
khettat 0:1bfc880cdffe 382 }
khettat 0:1bfc880cdffe 383 }
khettat 0:1bfc880cdffe 384
khettat 0:1bfc880cdffe 385 }
khettat 0:1bfc880cdffe 386 }