ver1

Dependents:   EM_ver1 template FM_ver3_for_ARLISS FM_ver3_for_test

GPS.cpp

Committer:
Nerosho
Date:
2019-07-16
Revision:
0:3d25bc7ff80e
Child:
1:432f77f0d864

File content as of revision 0:3d25bc7ff80e:

#include "GPS.h"
#include "mbed.h"


GPS::GPS(PinName tx, PinName rx):gps(tx,rx)
{
    _tx=tx;
    _rx=rx;

}

int GPS::getGPGGA()
{
    //Serial gps(_tx,_rx);
    gps.baud(9600);
    //Serial pc(USBTX,USBRX);
    //pc.baud(9600);

    char recvGPS=0;
    char getGPS[128];
    //char GPSMessage[128];
    int i=0;
    

    if(gps.readable()) {

        recvGPS=gps.getc();
        getGPS[i]=recvGPS;

        if(getGPS[i]==10) {

            if((getGPS[5]==71)&&(getGPS[6]==65)) {

                for(int n=0; n<i+1; n++) {

                    GPSMessage[n] = getGPS[n];
                
                    
                }
            return 1;

            }

            i=0;

        }

        i++;
    }

    //char eGPSMessage[]= "Could not get GPS data!";
    return 0;

}