Master Implementation of WANOT

Dependencies:   SX1276Lib mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GPS.cpp Source File

GPS.cpp

00001 #include "WANOT.h"
00002 
00003 /*
00004  *  Global variables declarations
00005  */
00006 
00007 
00008 void GPS_Read(char* StoreRead)
00009 {
00010     debug("GPS Data Query Started...\n\r");
00011     int j;
00012     int parts;
00013     char Parts_TimeBuffer[4];
00014 
00015 
00016     // struct tm t;         // setup time structure reffered to GPS
00017 
00018     Serial SS(NC,PC_11);
00019     SS.baud(4800);
00020 
00021     uint8_t Loop_Counter = 0;
00022 
00023     while(Loop_Counter < 3) {
00024         
00025         SS.gets(StoreRead,50);
00026         
00027         debug("New Statement Read\n\r");
00028 
00029         if(StoreRead[0]=='$' && StoreRead[1]=='G' && StoreRead[2]=='P'&& StoreRead[3]=='G'&& StoreRead[4]=='G' && StoreRead[5]=='A') { //GPGGA Message
00030 
00031             debug("GPGGA Statement\n\r");
00032             Loop_Counter++;          // To make sure it gets GPGGA Statement
00033         }
00034     }
00035     
00036     debug("GPS Data Fix Finished...\n\r");
00037     
00038     /*Parts of second*/
00039     for(j=0; j<3; j++) {
00040         //debug("%c",StoreRead[14+j]);//send parts of second
00041         Parts_TimeBuffer[j] = StoreRead[14+j];
00042     }
00043 
00044     Parts_TimeBuffer[3] = 0;
00045 
00046     parts = atoi(Parts_TimeBuffer);   // change to intege for mktime function
00047     wait_ms(1000-parts);              // to make time reffered to 00.00 of parts
00048     
00049     debug("GPS Synch Finished...\n\r");
00050 }