el codigo de google maps

Dependencies:   GPS_G mbed

/media/uploads/tony63/tareagsm.png

Revision:
1:e2bd083802c0
Parent:
0:b2a6aa7c0c8c
Child:
2:ea6275d1222f
--- a/main.cpp	Fri Jun 19 17:45:34 2015 +0000
+++ b/main.cpp	Fri Jun 03 01:03:02 2016 +0000
@@ -1,44 +1,35 @@
-//programa para celular siemens que recibe un mensaje de texto t activa una salida en formato
+///Tarea de comunicación celular y módulo GPS 
+//programa para celular siemens que recibe un mensaje de texto y activa una salida en formato
 //pdu hex
 #include "mbed.h"
 #include "DebouncedIn.h"
 #include "stdio.h"
 #include "string.h"
 #include "GPS.h"
-
-
-
-
+//Salidas digitales
 Timer t;
 DigitalOut LedVerde(LED2);
 DigitalOut LedRojo(LED1);
 DigitalOut LedAzul(LED3);
 
-///////////////////////////////////////////
+//Declaración de los puertos de la FRDm, modem y GPS
  
 Serial GSM(PTE0,PTE1);  //puertos del FRDM para el modem
 Serial pc(USBTX,USBRX);
 GPS gps(PTE22, PTE23);   // Puerto del FDRM para el gps 
 
-////////////////////////////
-//PARAMETROS
-////////////////////////////////
+//Declaración de variables
 
-
+//Cadenas de caracteres con las que se va a trabajar
 short DE[255];
 short DS[255];
-
 char buffer[512];
 char buffermsg[100];
 char buffer1[13];
 char mensaje[100];
+//Variables enteras y caracteres
 int count;
 int i,K,LENOUT,LENIN,C;
-
-char Tel[15];
-char cel[15];
-char ojala[15]; // OJO
-
 int c=0;
 int cont=0;
 unsigned char CtrlZ = 0x1A; 
@@ -46,28 +37,24 @@
 char r[]=""; 
 char msg[256];
 char char1;
-
 int index;
+//Adquisición de números de teléfono, emisor - receptor
+char Tel[15];
+char cel[15];
+char ojala[15]; // OJO
 
-//////
-//longitud  y latitud 
-////
-
+//El GPS entregará al celular coordenadas expresadas en latitud y longitud según la ubicación que encuentre
+// por tanto se declaran estas variables:
 
 float lo,la;
-char clo[255], cla[255];   //
+char clo[255], cla[255];   //Cadenas a capturar para latitud y longitud
 int LENINlo,LENINla,LENINla_lo;
 char la_lo[255];
-
+//Cadena de google maps
 char http2[255];
 char http[] = "http://maps.google.com/maps?q=";
 
-
-
-//////////////
-// convercion oct sept 
-////////////
-
+//Conversión octetos septetos
 
 int iht,Kht,ChtLENOUTht,LENINht;
 int ioct,Koct,LENOUToct,LENINoct,Coct;
@@ -75,17 +62,13 @@
 char DSoct[255];
 char buf[100];
 
-/////////////////////////
-//cocanteo rellenos y numero 
-//////////////////////////
+//Relleno de datos - con el fin de que tengan el mismo número de caracteres
 
 char relle1[]=  "0011000A91";
 char relle2[]=  "10000AA";
 char relle3[]=     "68";
 
-/////////////////////////////////////////////
-// funciones  
-////////////////////////////////////////////
+//Funciones del programa
  
 int readBuffer(char *buffer,int count)
 {
@@ -113,21 +96,18 @@
     return 0;
 }
 
-///////////////////////////////////////////////
-//Programass
-///////////////////////////////////////////////
+//Programas a ejecutar
     
 int main(void)
        { 
-       
+//LED´S en alto
        LedVerde=1;
        LedRojo=1;
        LedAzul=1;
- 
-   
+//Tasa de baudios 
        GSM.baud(9600);
        GSM.format(8,Serial::None,1); 
-
+//Lectura del modem
        GSM.printf("AT\r\n");
        wait(0.5);
        GSM.printf("AT+CNMI=1,1\r\n");
@@ -138,10 +118,9 @@
        wait(0.5);
        GSM.printf("CBST=0,0,1\r\n");
        wait(0.5);  
-             
-     
+                
      while(1){ 
-          
+//Lectura del buffer          
        if (GSM.readable()) {
             readBuffer(buffer,100);
             pc.printf("buffer= %s\n\r ",buffer);
@@ -151,7 +130,7 @@
                  pc.printf("mensaje= %s\n\r ",buffermsg); 
                  pc.printf("mensaje[72]= %c mensaje[73]=%c\n\r ",buffermsg[72],buffermsg[73]);        
                  buffer[67]='c';
-                 
+ //Si llegan estos tres tipos de mensajes...                
                  if (buffermsg[69] == '2'){    // PARA CUANDO LA CLAVE ES On
                         LENIN=2; //numero de caracteres de abajo son los octetos
                         DE[0]=0x47;
@@ -163,6 +142,7 @@
                         DE[1]=0xB3;
                         DE[2]=0x19;
                     }
+//Recepción de las coordenadas otorgadas por el GPS
                   if (buffermsg[69] == '3'&& buffermsg[70] == 'C'){  // PARA CUANDO LA CLAVE ES Cor
                         LENIN=3; //numero de caracteres de abajo son los octetos
                         DE[0]=0xC3;
@@ -188,11 +168,10 @@
                     {
                      Tel[i] = buffermsg[40+i];
                     }   
+//Lectura del número de teléfono
                     pc.printf("\n");
-                    pc.printf("%c%c%c%c%c%c%c%c%c%c",Tel[1],Tel[0],Tel[3],Tel[2],Tel[5],Tel[4],Tel[7],Tel[6],Tel[9],Tel[8]);
-            
-                 }
-                      
+                    pc.printf("%c%c%c%c%c%c%c%c%c%c",Tel[1],Tel[0],Tel[3],Tel[2],Tel[5],Tel[4],Tel[7],Tel[6],Tel[9],Tel[8]);          
+                 }                     
         if(buffer[10]=='S'&& buffer[11]=='M'){
              for(i=0;i<5;i++)
              {buffer1[i]=buffer[2+i];}
@@ -204,9 +183,7 @@
             wait(0.5);
             GSM.printf("AT+CMGL=0\r\n");
             buffer1[3]='p';
-            }
-            
-       
+            }     
         if(DS[0]-67 == 0&& DS[1]-111==0)   // Cor en octetos es 436f72
         {
         pc.printf("\n");
@@ -214,37 +191,26 @@
         
         DS[0] = '\0';
         DS[1] = '\0';
-           
+//Entrega los datos de longitud y latitud
            if(gps.sample())
             {
                lo =gps.longitude;
                la =gps.latitude;
                pc.printf("longitud_entera=%f, Latitud entera=%f\n", lo, la);
-         
-                  wait(0.5);         
+                  wait(0.5);   
+                        
             //LONGITUD/        
             sprintf (clo, "%f", lo); 
             pc.printf ( "\nlongitud = %s\n",clo);
             LENINlo=strlen(clo);  
+            wait(0.5);
             
-            /*  for (ilo=0;ilo<LENINlo;ilo++){
-                pc.printf("%c,",clo[ilo]);       
-            } */        
-            
-           wait(0.5);
            //LATITUD/
            sprintf (cla, "%f", la); 
            pc.printf ( "\nlatitud = %s\n",cla);
            LENINla=strlen(cla); 
-            
-           /*for (ila1=0;ila1<LENINla1;ila1++){
-                pc.printf("%c,",cla[ila1]);       
-           }*/
-
-          
-        ///////////////////////////////////////////////////            
-        // CONCATENO LONGITUD Y LATITUD
-        ///////////////////////////////////////////////////
+         
+        //Concatenando las cadenas de Latitud y Longitud...
 
            strcpy(la_lo,cla);
            strcat(la_lo,",");
@@ -254,22 +220,14 @@
            
            LENINla_lo=strlen(la_lo);
 
-           /*for (j=0;j<LENINla_lo;j++){
-                pc.printf("%c\n",la_lo[j]);       
-           }*/    
-           
-         ////////////////////////////////////////////////////////      
-        // CONCATENO LONGITUD, LATITUD Y EL http//:
-        ////////////////////////////////////////////////////////
+         //Ahora se juntan las cadenas obtenidas y se agrega el protocolo de transferencia de hipertextos http
             strcpy(http2,http);
             strcat(http2,la_lo);         
             pc.printf ( "%s\n",http2);
             pc.printf ( "\n" );
            
            
-        //////////////////////////////////////////////////////////////////////
-        // convierto http2 de oct a sep
-        ////////////////////////////////////////////////////////////////////////       
+        //Conversión de la cadena de http2 de octetos a septetos 
        
         LENINht=strlen(http2);
         pc.printf("%d\n",LENINht); 
@@ -277,8 +235,6 @@
              pc.printf("%2X",http2[iht]);       
             } 
         pc.printf ( "\n" );
-      
-        /////////////////////////////////////
 
         LENINoct=strlen(http2);
         pc.printf("%d\n",LENINoct);
@@ -287,8 +243,7 @@
                 DEoct[ioct]=http2[ioct];
                 pc.printf("%2X,%d\n",DEoct[ioct],ioct);       
            }
-        ////////////////////////////////////////        
-       
+
          Koct=0;
          Coct=0;
         
@@ -304,9 +259,7 @@
                             pc.printf("%2X,%d\r\n",DSoct[ioct]&0x000000FF,ioct);
                         }
                   }
-       //             pc.printf("LENOUT:%d,LENIN:%d\r\n",LENOUToct,strlen(DEoct));
                   
-                  //}
                  Koct++;
                 if (Koct==7)
                 {
@@ -314,13 +267,7 @@
                 } // se chequea que ya se acabaron los bits en un ciclo de conversion.
          }  
         
-        /////////////////////////////////////////////////////////
-        // CONCATENO LOS RELLENOS Y EL NUMERO DEL CELULAR 
-        ////////////////////////////////////////////////////////
-        
-        
-        
-        
+        //Concatenación de los datos relleno y el número de celular
         wait(5);
         index=56;
         GSM.printf("AT+CMGS=%d\r\n",index);
@@ -351,25 +298,24 @@
             pc.printf(">%s\n",buf);
           pc.printf("\n");
           
-           }  // if 
-            
-            
-    
+           }
         }
-
+//Si el mensaje recibido fue OFF...
         if(DS[0]-79==0 && DS[1]-102==0)     // Off en octetos es 4F6666
         {
-               LedAzul=1; //apaga con Lgeverde
+            //Secuencia de apagado
+               LedAzul=1;
                LedVerde = 0;
                LedRojo=1;
         }   
-        
+//Si el mensaje recibido fue ON...       
         if(DS[0]-71==0 && DS[1]-110==0)  // On en octetos es 476E
         {
-               LedAzul=1;  //apaga con Lgeverde
+                //Secuencia de apagado
+               LedAzul=1;
                LedRojo =0;
                LedVerde = 1;
         } 
      }           
 }
-}
+}
\ No newline at end of file