este programa sirve para probar que el siemens manda mensajes de texto a su celular cambie mi numero por el suyo guiese del ultimo doc y mande un mensaje diferente

Dependencies:   DebouncedIn mbed

/media/uploads/tony63/pruebatx.png

Committer:
tony63
Date:
Mon Dec 01 04:54:29 2014 +0000
Revision:
0:edc50cf04b46
Child:
1:6b506dde0a6e
este programa sirve para probar que el siemens manda mensajes de texto a su celular  cambie mi numero por el suyo guiese del ultimo doc y mande un mensaje diferente

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tony63 0:edc50cf04b46 1 // Programa para enviar desde la FRDMKL25Z un mensaje de texto en formatp PDU
tony63 0:edc50cf04b46 2 // Como modem usa un celular SIEMENS a56i
tony63 0:edc50cf04b46 3 // ENVIAR -----la palabra "ALARMA 1"
tony63 0:edc50cf04b46 4 //
tony63 0:edc50cf04b46 5
tony63 0:edc50cf04b46 6 // OJO CON ESTO
tony63 0:edc50cf04b46 7 // conector del siemens cable verde es RX conectelo a PTE0 cable blanco es TX conectelo a PTE1
tony63 0:edc50cf04b46 8 #include "mbed.h"
tony63 0:edc50cf04b46 9 #include "DebouncedIn.h"
tony63 0:edc50cf04b46 10 #include "stdio.h"
tony63 0:edc50cf04b46 11 #include "string.h"
tony63 0:edc50cf04b46 12 Timer t;
tony63 0:edc50cf04b46 13 DigitalOut LedVerde(LED2);
tony63 0:edc50cf04b46 14 DigitalOut LedRojo(LED1);
tony63 0:edc50cf04b46 15 DigitalOut LedAzul(LED3);
tony63 0:edc50cf04b46 16 DebouncedIn button1(PTC12); //señal que inicia el envio del mensaje
tony63 0:edc50cf04b46 17 Serial GSM(PTE0,PTE1); //Configura puerto UART de la FRDMKL25Z
tony63 0:edc50cf04b46 18 Serial pc(USBTX,USBRX);//Configura puerto USB a la consola serial del PC conectado.
tony63 0:edc50cf04b46 19 void Rx_interrupt();
tony63 0:edc50cf04b46 20 int position=0;
tony63 0:edc50cf04b46 21 int lenpack=6;
tony63 0:edc50cf04b46 22 int longi=0;
tony63 0:edc50cf04b46 23 char tel[10];
tony63 0:edc50cf04b46 24 char DE[50];
tony63 0:edc50cf04b46 25 char buffer[512];
tony63 0:edc50cf04b46 26 char NUMBER[13];
tony63 0:edc50cf04b46 27 int index;
tony63 0:edc50cf04b46 28 int count;
tony63 0:edc50cf04b46 29 int i = 0;
tony63 0:edc50cf04b46 30 int c=0;
tony63 0:edc50cf04b46 31 unsigned char CtrlZ = 0x1A; // comodin de emision controlZ
tony63 0:edc50cf04b46 32 bool Flag = false; // bandera
tony63 0:edc50cf04b46 33 char r[]=""; //Cadena de recepcion de la trama PDU si se usa!!
tony63 0:edc50cf04b46 34 char msg[256];
tony63 0:edc50cf04b46 35 char char1;
tony63 0:edc50cf04b46 36 //Flush serial para el buffer
tony63 0:edc50cf04b46 37 void FlushGSM(void) {
tony63 0:edc50cf04b46 38 char1 = 0;
tony63 0:edc50cf04b46 39 while (GSM.readable()){
tony63 0:edc50cf04b46 40 char1 = GSM.getc();}
tony63 0:edc50cf04b46 41 return;}
tony63 0:edc50cf04b46 42
tony63 0:edc50cf04b46 43 void callback() {
tony63 0:edc50cf04b46 44 // Note: you need to actually read from the serial to clear the RX interrupt
tony63 0:edc50cf04b46 45 pc.printf("%c\n", GSM.getc());
tony63 0:edc50cf04b46 46
tony63 0:edc50cf04b46 47 }
tony63 0:edc50cf04b46 48
tony63 0:edc50cf04b46 49 int readBuffer(char *buffer,int count)
tony63 0:edc50cf04b46 50 {
tony63 0:edc50cf04b46 51 int i=0;
tony63 0:edc50cf04b46 52 t.start(); // start timer
tony63 0:edc50cf04b46 53 while(1) {
tony63 0:edc50cf04b46 54 while (GSM.readable()) {
tony63 0:edc50cf04b46 55 char c = GSM.getc();
tony63 0:edc50cf04b46 56 if (c == '\r' || c == '\n') c = '$';
tony63 0:edc50cf04b46 57 buffer[i++] = c;
tony63 0:edc50cf04b46 58 if(i > count)break;
tony63 0:edc50cf04b46 59 }
tony63 0:edc50cf04b46 60 if(i > count)break;
tony63 0:edc50cf04b46 61 if(t.read() > 3) {
tony63 0:edc50cf04b46 62 t.stop();
tony63 0:edc50cf04b46 63 t.reset();
tony63 0:edc50cf04b46 64 break;
tony63 0:edc50cf04b46 65 }
tony63 0:edc50cf04b46 66 }
tony63 0:edc50cf04b46 67 wait(0.5);
tony63 0:edc50cf04b46 68 while(GSM.readable()) { // display the other thing..
tony63 0:edc50cf04b46 69 char c = GSM.getc();
tony63 0:edc50cf04b46 70 }
tony63 0:edc50cf04b46 71 return 0;
tony63 0:edc50cf04b46 72 }
tony63 0:edc50cf04b46 73
tony63 0:edc50cf04b46 74 /* esta funcion de abajo limpia o borra todo un "buffer" de tamaño "count"
tony63 0:edc50cf04b46 75 lo revisa uno por un elemento y le mete el caracter null que indica fin de cadena
tony63 0:edc50cf04b46 76 no retorna nada
tony63 0:edc50cf04b46 77 */
tony63 0:edc50cf04b46 78 //***************************************************************************************
tony63 0:edc50cf04b46 79 void cleanBuffer(char *buffer, int count)
tony63 0:edc50cf04b46 80 {
tony63 0:edc50cf04b46 81 for(int i=0; i < count; i++) {
tony63 0:edc50cf04b46 82 buffer[i] = '\0';
tony63 0:edc50cf04b46 83 }
tony63 0:edc50cf04b46 84 }
tony63 0:edc50cf04b46 85 /* esta funcion de abajo envia un comando parametrizado como cadena
tony63 0:edc50cf04b46 86 */
tony63 0:edc50cf04b46 87 //***************************************************************************************
tony63 0:edc50cf04b46 88 void sendCmd(char *cmd)
tony63 0:edc50cf04b46 89 {
tony63 0:edc50cf04b46 90 GSM.puts(cmd);
tony63 0:edc50cf04b46 91 }
tony63 0:edc50cf04b46 92 /* esta funcion de abajo espera la respuesta de un comando que debe ser identica a la cadena "resp" y un tiempo timeout"
tony63 0:edc50cf04b46 93 si todo sale bien retorna un cero que en la programacion hay que validar
tony63 0:edc50cf04b46 94 si algo sale mal ( no se parece o se demora mucho )retorna -1 que debera validarse con alguna expresion logica
tony63 0:edc50cf04b46 95 */
tony63 0:edc50cf04b46 96 //***************************************************************************************
tony63 0:edc50cf04b46 97 int waitForResp(char *resp, int timeout)
tony63 0:edc50cf04b46 98 {
tony63 0:edc50cf04b46 99 int len = strlen(resp);
tony63 0:edc50cf04b46 100 int sum=0;
tony63 0:edc50cf04b46 101 t.start();
tony63 0:edc50cf04b46 102
tony63 0:edc50cf04b46 103 while(1) {
tony63 0:edc50cf04b46 104 if(GSM.readable()) {
tony63 0:edc50cf04b46 105 char c = GSM.getc();
tony63 0:edc50cf04b46 106 sum = (c==resp[sum]) ? sum+1 : 0;// esta linea de C# sum se incrementa o se hace cero segun c
tony63 0:edc50cf04b46 107 if(sum == len)break; //ya acabo se sale
tony63 0:edc50cf04b46 108 }
tony63 0:edc50cf04b46 109 if(t.read() > timeout) { // time out chequea el tiempo minimo antes de salir perdiendo
tony63 0:edc50cf04b46 110 t.stop();
tony63 0:edc50cf04b46 111 t.reset();
tony63 0:edc50cf04b46 112 return -1;
tony63 0:edc50cf04b46 113 }
tony63 0:edc50cf04b46 114 }
tony63 0:edc50cf04b46 115 t.stop(); // stop timer antes de retornar
tony63 0:edc50cf04b46 116 t.reset(); // clear timer
tony63 0:edc50cf04b46 117 while(GSM.readable()) { // display the other thing..
tony63 0:edc50cf04b46 118 char c = GSM.getc();
tony63 0:edc50cf04b46 119 }
tony63 0:edc50cf04b46 120
tony63 0:edc50cf04b46 121 return 0;
tony63 0:edc50cf04b46 122 }
tony63 0:edc50cf04b46 123 /* esta funcion de abajo es muy completa e util se encarga de enviar el comando y esperar la respuesta
tony63 0:edc50cf04b46 124 si todo sale bien retorna un cero(herencia de las funciones contenedoras) que en la programacion hay que validar
tony63 0:edc50cf04b46 125 con alguna expresion logica
tony63 0:edc50cf04b46 126 */
tony63 0:edc50cf04b46 127 //***************************************************************************************
tony63 0:edc50cf04b46 128 int sendCmdAndWaitForResp(char *cmd, char *resp, int timeout)
tony63 0:edc50cf04b46 129 {
tony63 0:edc50cf04b46 130 sendCmd(cmd);
tony63 0:edc50cf04b46 131 return waitForResp(resp,timeout);
tony63 0:edc50cf04b46 132 }
tony63 0:edc50cf04b46 133 /* esta funcion de abajo chequea que el modem este vivo envia AT y le contesta con OK y espera 2 segundos
tony63 0:edc50cf04b46 134 */
tony63 0:edc50cf04b46 135 //***************************************************************************************
tony63 0:edc50cf04b46 136 int powerCheck(void)// este comando se manda para verificar si el modem esta vivo o conectado
tony63 0:edc50cf04b46 137 {
tony63 0:edc50cf04b46 138 return sendCmdAndWaitForResp("AT\r\n", "OK", 2);
tony63 0:edc50cf04b46 139 }
tony63 0:edc50cf04b46 140 /* esta funcion de abajo chequea el estado de la sim card
tony63 0:edc50cf04b46 141 y si todo sale bien retorna un cero que en la programacion hay que validar
tony63 0:edc50cf04b46 142 con alguna expresion logica
tony63 0:edc50cf04b46 143 */
tony63 0:edc50cf04b46 144 //***************************************************************************************
tony63 0:edc50cf04b46 145 int checkSIMStatus(void)
tony63 0:edc50cf04b46 146 {
tony63 0:edc50cf04b46 147 char gprsBuffer[30];
tony63 0:edc50cf04b46 148 int count = 0;
tony63 0:edc50cf04b46 149 cleanBuffer(gprsBuffer,30);
tony63 0:edc50cf04b46 150 while(count < 3) {
tony63 0:edc50cf04b46 151 sendCmd("AT+CPIN?\r\n");
tony63 0:edc50cf04b46 152 readBuffer(gprsBuffer,30);
tony63 0:edc50cf04b46 153 if((NULL != strstr(gprsBuffer,"+CPIN: READY"))) {
tony63 0:edc50cf04b46 154 break;
tony63 0:edc50cf04b46 155 }
tony63 0:edc50cf04b46 156 count++;
tony63 0:edc50cf04b46 157 wait(1);
tony63 0:edc50cf04b46 158 }
tony63 0:edc50cf04b46 159
tony63 0:edc50cf04b46 160 if(count == 3) {
tony63 0:edc50cf04b46 161 return -1;
tony63 0:edc50cf04b46 162 }
tony63 0:edc50cf04b46 163 return 0;
tony63 0:edc50cf04b46 164 }
tony63 0:edc50cf04b46 165 /* esta funcion de abajo chequea la calidad de la señal
tony63 0:edc50cf04b46 166 y si todo sale bien retorna cun el valor de señal util o un -1 si nop es aceptable, en la programacion hay que validar
tony63 0:edc50cf04b46 167 con alguna expresion logica
tony63 0:edc50cf04b46 168 */
tony63 0:edc50cf04b46 169 //***************************************************************************************
tony63 0:edc50cf04b46 170 int checkSignalStrength(void)
tony63 0:edc50cf04b46 171 {
tony63 0:edc50cf04b46 172 char gprsBuffer[100];
tony63 0:edc50cf04b46 173 int index,count = 0;
tony63 0:edc50cf04b46 174 cleanBuffer(gprsBuffer,100);
tony63 0:edc50cf04b46 175 while(count < 3) {
tony63 0:edc50cf04b46 176 sendCmd("AT+CSQ\r\n");
tony63 0:edc50cf04b46 177 readBuffer(gprsBuffer,25);
tony63 0:edc50cf04b46 178 if(sscanf(gprsBuffer, "AT+CSQ$$$$+CSQ: %d", &index)>0) {
tony63 0:edc50cf04b46 179 break;
tony63 0:edc50cf04b46 180 }
tony63 0:edc50cf04b46 181 count++;
tony63 0:edc50cf04b46 182 wait(1);
tony63 0:edc50cf04b46 183 }
tony63 0:edc50cf04b46 184 if(count == 3) {
tony63 0:edc50cf04b46 185 return -1;
tony63 0:edc50cf04b46 186 }
tony63 0:edc50cf04b46 187 return index;
tony63 0:edc50cf04b46 188 }
tony63 0:edc50cf04b46 189 /* esta funcion de abajo configura el modem de forma inicial con comandas AT
tony63 0:edc50cf04b46 190 y si todo sale bien retorna un cero que en la programacion hay que validar
tony63 0:edc50cf04b46 191 con alguna expresion logica pero si algo sale mal retorna un -1
tony63 0:edc50cf04b46 192 */
tony63 0:edc50cf04b46 193 //***************************************************************************************
tony63 0:edc50cf04b46 194 /*int settingSMS() //esta funcion se invoca para configurar el modem al principio
tony63 0:edc50cf04b46 195 {
tony63 0:edc50cf04b46 196 if(0 != sendCmdAndWaitForResp("AT\r\n", "OK", 1)) {
tony63 0:edc50cf04b46 197 return -1;
tony63 0:edc50cf04b46 198 }
tony63 0:edc50cf04b46 199 if(0 != sendCmdAndWaitForResp("AT+CNMI=1,1\r\n", "OK", 1)) {
tony63 0:edc50cf04b46 200 return -1;
tony63 0:edc50cf04b46 201 }
tony63 0:edc50cf04b46 202 if(0 != sendCmdAndWaitForResp("AT+CMGF=0\r\n", "OK", 1)) {
tony63 0:edc50cf04b46 203 return -1;
tony63 0:edc50cf04b46 204 }
tony63 0:edc50cf04b46 205 if(0 != sendCmdAndWaitForResp("ATE\r\n", "OK", 1)) {
tony63 0:edc50cf04b46 206 return -1;
tony63 0:edc50cf04b46 207 }
tony63 0:edc50cf04b46 208 if(0 != sendCmdAndWaitForResp("CBST=0,0,1\r\n", "OK", 1)) {
tony63 0:edc50cf04b46 209 return -1;
tony63 0:edc50cf04b46 210 }
tony63 0:edc50cf04b46 211 return 0;
tony63 0:edc50cf04b46 212 }
tony63 0:edc50cf04b46 213 */
tony63 0:edc50cf04b46 214
tony63 0:edc50cf04b46 215
tony63 0:edc50cf04b46 216 /* esta funcion de abajo inicaliza el modem se compone de un grupo de subfunciones ya definidas previamente
tony63 0:edc50cf04b46 217 primero chequea que este vivo
tony63 0:edc50cf04b46 218 segundo chequea el estado de la simcard
tony63 0:edc50cf04b46 219 tercero chequea la intencidad de señal celular
tony63 0:edc50cf04b46 220 cuarto aplica la configuracion
tony63 0:edc50cf04b46 221 y si todo sale bien retorna un cero que en la programacion hay que validar
tony63 0:edc50cf04b46 222 con alguna expresion logica
tony63 0:edc50cf04b46 223 */
tony63 0:edc50cf04b46 224 //***************************************************************************************
tony63 0:edc50cf04b46 225 int init()
tony63 0:edc50cf04b46 226 {
tony63 0:edc50cf04b46 227 for(int i = 0; i < 3; i++){
tony63 0:edc50cf04b46 228 sendCmdAndWaitForResp("AT\r\n", "OK", 1);
tony63 0:edc50cf04b46 229 wait(0.5);
tony63 0:edc50cf04b46 230 }
tony63 0:edc50cf04b46 231 if(0 != checkSIMStatus()) {
tony63 0:edc50cf04b46 232 return -1;
tony63 0:edc50cf04b46 233 }
tony63 0:edc50cf04b46 234 if(checkSignalStrength()<1) {
tony63 0:edc50cf04b46 235 return -1;
tony63 0:edc50cf04b46 236 }
tony63 0:edc50cf04b46 237
tony63 0:edc50cf04b46 238 GSM.attach(&Rx_interrupt, Serial::RxIrq);
tony63 0:edc50cf04b46 239 return 0;
tony63 0:edc50cf04b46 240 }
tony63 0:edc50cf04b46 241 /* esta funcion de abajo intenta leer un mensaje de texto en formato PDU o HEX
tony63 0:edc50cf04b46 242 y si todo sale bien retorna un cero que en la programacion hay que validar
tony63 0:edc50cf04b46 243 con alguna expresion logica
tony63 0:edc50cf04b46 244 */
tony63 0:edc50cf04b46 245 //***************************************************************************************
tony63 0:edc50cf04b46 246 int readSMSpdu(char *message, int index)
tony63 0:edc50cf04b46 247 {
tony63 0:edc50cf04b46 248 int i = 0;
tony63 0:edc50cf04b46 249 char gprsBuffer[100];
tony63 0:edc50cf04b46 250 char *p,*s;
tony63 0:edc50cf04b46 251 GSM.printf("AT+CMGR=%d\r\n",index);
tony63 0:edc50cf04b46 252 cleanBuffer(gprsBuffer,100);
tony63 0:edc50cf04b46 253 readBuffer(gprsBuffer,100);
tony63 0:edc50cf04b46 254 if(NULL == ( s = strstr(gprsBuffer,"+CMGR"))) {
tony63 0:edc50cf04b46 255 return -1;
tony63 0:edc50cf04b46 256 }
tony63 0:edc50cf04b46 257 if(NULL != ( s = strstr(gprsBuffer,"+32"))) {
tony63 0:edc50cf04b46 258 p = s + 6;
tony63 0:edc50cf04b46 259 while((*p != '$')&&(i < 5)) {
tony63 0:edc50cf04b46 260 message[i++] = *(p++);
tony63 0:edc50cf04b46 261 }
tony63 0:edc50cf04b46 262 message[i] = '\0';
tony63 0:edc50cf04b46 263 }
tony63 0:edc50cf04b46 264 return 0;
tony63 0:edc50cf04b46 265 }
tony63 0:edc50cf04b46 266 /* esta funcion de abajo borra mensajes SMS del modem
tony63 0:edc50cf04b46 267 y si todo sale bien retorna un cero que en la programacion hay que validar
tony63 0:edc50cf04b46 268 con alguna expresion logica
tony63 0:edc50cf04b46 269 */
tony63 0:edc50cf04b46 270 //***************************************************************************************
tony63 0:edc50cf04b46 271 int deleteSMS(int index)
tony63 0:edc50cf04b46 272 {
tony63 0:edc50cf04b46 273 char cmd[32];
tony63 0:edc50cf04b46 274 snprintf(cmd,sizeof(cmd),"AT+CMGD=%d\r\n",index);
tony63 0:edc50cf04b46 275 sendCmd(cmd);
tony63 0:edc50cf04b46 276 return 0;
tony63 0:edc50cf04b46 277 }
tony63 0:edc50cf04b46 278 //***0*********************************************************************************
tony63 0:edc50cf04b46 279
tony63 0:edc50cf04b46 280 // Interupt Routine to read in data from serial port
tony63 0:edc50cf04b46 281 void Rx_interrupt(){
tony63 0:edc50cf04b46 282 }
tony63 0:edc50cf04b46 283 /*
tony63 0:edc50cf04b46 284 readBuffer(buffer,6);
tony63 0:edc50cf04b46 285 if(strncmp(buffer, "+CMTI", 5)){
tony63 0:edc50cf04b46 286 wait(1);
tony63 0:edc50cf04b46 287 GSM.printf("AT+CMGL=%d\r\n",0);
tony63 0:edc50cf04b46 288 readBuffer(buffer,100);}
tony63 0:edc50cf04b46 289 if(strncmp(buffer, "+CMGL:", 5)){
tony63 0:edc50cf04b46 290 for (i=0;i<31;i++){
tony63 0:edc50cf04b46 291 buffer[5+i]=c; // 32 de basura
tony63 0:edc50cf04b46 292 }
tony63 0:edc50cf04b46 293 }
tony63 0:edc50cf04b46 294 for (i=0;i<10;i++){
tony63 0:edc50cf04b46 295 buffer[36+i]=tel[i]; // numero telefonico
tony63 0:edc50cf04b46 296 }
tony63 0:edc50cf04b46 297 for (i=0;i<18;i++){
tony63 0:edc50cf04b46 298 buffer[46+i]=c; // 18 de basura
tony63 0:edc50cf04b46 299 }
tony63 0:edc50cf04b46 300 for (i=0;i<2;i++){
tony63 0:edc50cf04b46 301 buffer[64+i]=tel[i]; // tamaño de septetos
tony63 0:edc50cf04b46 302 }
tony63 0:edc50cf04b46 303 for (i=0;i<30;i++){
tony63 0:edc50cf04b46 304 buffer[66+i]=DE[i]; // datos en octetos hex
tony63 0:edc50cf04b46 305 if (buffer[i]=='\0'){
tony63 0:edc50cf04b46 306 }
tony63 0:edc50cf04b46 307 */
tony63 0:edc50cf04b46 308
tony63 0:edc50cf04b46 309
tony63 0:edc50cf04b46 310 int main(void)
tony63 0:edc50cf04b46 311 {
tony63 0:edc50cf04b46 312
tony63 0:edc50cf04b46 313 //NVIC_DisableIRQ(UART1_IRQn);
tony63 0:edc50cf04b46 314 //apagamos los 3 leds
tony63 0:edc50cf04b46 315 LedVerde=1;
tony63 0:edc50cf04b46 316 LedRojo=1;
tony63 0:edc50cf04b46 317 LedAzul=1;
tony63 0:edc50cf04b46 318 lenpack=6; //tamaño de "ALARMA"
tony63 0:edc50cf04b46 319 GSM.baud(9600);//configura los baudios de la FRDMKL25Z en 9600
tony63 0:edc50cf04b46 320 GSM.format(8,Serial::None,1); //configura el formato de los datos de la UART
tony63 0:edc50cf04b46 321 //configuro modem GSM
tony63 0:edc50cf04b46 322 GSM.printf("AT\r\n");
tony63 0:edc50cf04b46 323 wait(0.5);
tony63 0:edc50cf04b46 324 GSM.printf("AT+CNMI=1,1\r\n");
tony63 0:edc50cf04b46 325 wait(0.5);
tony63 0:edc50cf04b46 326 GSM.printf("AT+CMGF=0\r\n");
tony63 0:edc50cf04b46 327 wait(0.5);
tony63 0:edc50cf04b46 328 GSM.printf("ATE\r\n");
tony63 0:edc50cf04b46 329 wait(0.5);
tony63 0:edc50cf04b46 330 GSM.printf("CBST=0,0,1\r\n");
tony63 0:edc50cf04b46 331 wait(0.5);
tony63 0:edc50cf04b46 332 LedVerde=0;
tony63 0:edc50cf04b46 333
tony63 0:edc50cf04b46 334 //if(0!= init()){ //se configura y chequea el modem GSM
tony63 0:edc50cf04b46 335 // LedRojo=0;
tony63 0:edc50cf04b46 336 //}
tony63 0:edc50cf04b46 337 while(1){
tony63 0:edc50cf04b46 338 if (button1.falling())
tony63 0:edc50cf04b46 339 { LedVerde=1;
tony63 0:edc50cf04b46 340 wait(2);
tony63 0:edc50cf04b46 341 if (!button1)
tony63 0:edc50cf04b46 342 {LedVerde=0;
tony63 0:edc50cf04b46 343 index=20;
tony63 0:edc50cf04b46 344 //GSM.printf("AT+CNMI=1,1\r\n"); //configuracion inicial del MODEM!
tony63 0:edc50cf04b46 345 GSM.printf("AT+CMGS=%d\r\n",index);
tony63 0:edc50cf04b46 346 wait(0.2);
tony63 0:edc50cf04b46 347 GSM.printf("0011000A9113223717370000AA08416650DA0C8262"); //esto es "ALARMA 1"
tony63 0:edc50cf04b46 348 wait(0.5);
tony63 0:edc50cf04b46 349 GSM.putc((char)0x1A); //esto es controlZ
tony63 0:edc50cf04b46 350 LedVerde=1;
tony63 0:edc50cf04b46 351 LedRojo=0; //lo prendo
tony63 0:edc50cf04b46 352 wait(3);
tony63 0:edc50cf04b46 353 LedRojo=1; //lo apago
tony63 0:edc50cf04b46 354 LedVerde=0;
tony63 0:edc50cf04b46 355 }
tony63 0:edc50cf04b46 356
tony63 0:edc50cf04b46 357 }
tony63 0:edc50cf04b46 358 }
tony63 0:edc50cf04b46 359 }