Slave Implementation of WANOT Slave

Dependencies:   SX1276Lib mbed-src

GPS.cpp

Committer:
semsem
Date:
2016-05-23
Revision:
0:80ebf9b1dd4f

File content as of revision 0:80ebf9b1dd4f:

#include "WANOT.h"

/*
 *  Global variables declarations
 */


void GPS_Read(char* StoreRead)
{
    debug("GPS Data Query Started...\n\r");
    int j;
    int parts;
    char Parts_TimeBuffer[4];


    // struct tm t;         // setup time structure reffered to GPS

    Serial SS(NC,PC_11);
    SS.baud(4800);

    uint8_t Loop_Counter = 0;

    while(Loop_Counter < 3) {
        
        SS.gets(StoreRead,50);
        
        debug("New Statement Read\n\r");

        if(StoreRead[0]=='$' && StoreRead[1]=='G' && StoreRead[2]=='P'&& StoreRead[3]=='G'&& StoreRead[4]=='G' && StoreRead[5]=='A') { //GPGGA Message

            debug("GPGGA Statement\n\r");
            Loop_Counter++;          // To make sure it gets GPGGA Statement
        }
    }
    
    debug("GPS Data Fix Finished...\n\r");
    
    /*Parts of second*/
    for(j=0; j<3; j++) {
        //debug("%c",StoreRead[14+j]);//send parts of second
        Parts_TimeBuffer[j] = StoreRead[14+j];
    }

    Parts_TimeBuffer[3] = 0;

    parts = atoi(Parts_TimeBuffer);   // change to intege for mktime function
    wait_ms(1000-parts);              // to make time reffered to 00.00 of parts
    
    debug("GPS Synch Finished...\n\r");
}