mikalhart / TinyGPSPlus

A new, customizable Arduino NMEA parsing library
http://arduiniana.org
1.08k stars 490 forks source link

Support for Beidou & GLONASS #128

Open JasonPittenger opened 11 months ago

JasonPittenger commented 11 months ago

Can you add support for Beidou & GLONASS?
Instead of a string compare for an exact match, I suggest a string search for the sentence type. This then is agnostic to the system being used.

Global Positioning System (GPS, SBAS, QZSS) = GP Global Navigation Satellite System (GNSS) = GN Global Navigation Satellite System (GLONASS) = GL Beidou Navigation Satellite System (BDS) = BD

This

#define _GPRMCterm   "GPRMC"
#define _GPGGAterm   "GPGGA"
#define _GNRMCterm   "GNRMC"
#define _GNGGAterm   "GNGGA"

becomes

#define __RMCterm   "RMC"
#define __GGAterm   "GGA"

and

if (!strcmp(term, _GPRMCterm) || !strcmp(term, _GNRMCterm))
      curSentenceType = GPS_SENTENCE_GPRMC;
    else if (!strcmp(term, _GPGGAterm) || !strcmp(term, _GNGGAterm))
      curSentenceType = GPS_SENTENCE_GPGGA;
    else
      curSentenceType = GPS_SENTENCE_OTHER;

Becomes

if (strstr(term, __RMCterm)
      curSentenceType = GPS_SENTENCE_GPRMC;
    else if (strstr(term, __GGAterm))
      curSentenceType = GPS_SENTENCE_GPGGA;
    else
      curSentenceType = GPS_SENTENCE_OTHER;