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