Skip to content

Light-weight Android Java library for NMEA sentences parsing

License

Notifications You must be signed in to change notification settings

petr-s/android-nmea-parser

Repository files navigation

android-nmea-parser Build Status Coverage Status

Light-weight Android Java library for NMEA sentences parsing

Supported sentences:

  • GPRMC
  • GPGGA
  • GPGSV
  • GPGSA

NMEA Parser

flow parser build on top of the BasicNMEAParser that maps raw NMEA data to useful Android objects such as Location and GpsSatellite

Location parsing

To get an Android Location object you have to parse both RMC and GGA with the same time.

NMEAHandler handler = new NMEAHandler() {
    ...
    @Override
    public void onLocation(Location location) {

    }
    ...
};
NMEAParser parser = new NMEAParser(handler);
parser.parse("$GPRMC,163407.000,A,5004.7485,N,01423.8956,E,0.04,36.97,180416,,*38");
parser.parse("$GPGGA,163407.000,5004.7485,N,01423.8956,E,1,07,1.7,285.7,M,45.5,M,,0000*5F");

Satellites parsing

To get a list of gps satellites you have to parse all of GSVs and at least one GSA sentence. Since Android GpsSatellite class is inaccessible (only trough reflection), the package level GpsSatellite is introduced.

NMEAHandler handler = new NMEAHandler() {
    ...
    @Override
    public void onSatellites(List<GpsSatellite> satellites) {

    }
    ...
};
NMEAParser parser = new NMEAParser(handler);
parser.parse("$GPGSV,3,1,11,29,86,273,30,25,60,110,38,31,52,278,47,02,28,050,39*7D");
parser.parse("$GPGSV,3,2,11,12,23,110,34,26,18,295,29,21,17,190,30,05,11,092,25*72");
parser.parse("$GPGSV,3,3,11,14,02,232,13,23,02,346,12,20,01,135,13*48");
parser.parse("$GPGSA,A,3,25,02,26,05,29,31,21,12,,,,,1.6,1.0,1.3*3B");

if you don't need all methods there's also an Adapter

Basic NMEA Parser

flow parser that allows you to access raw NMEA data

BasicNMEAHandler handler = new BasicNMEAHandler() {
    ...
    @Override
    public void onRMC(long date, long time, double latitude, double longitude, float speed, float direction) {
    }
    ...
};
BasicNMEAParser parser = new BasicNMEAParser(handler);
parser.parse("$GPRMC,163407.000,A,5004.7485,N,01423.8956,E,0.04,36.97,180416,,*38");

if you don't need all methods there's also an Adapter

Gradle

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.github.petr-s:android-nmea-parser:0.5.0'
}

Maven

<dependency>
  <groupId>com.github.petr-s</groupId>
  <artifactId>android-nmea-parser</artifactId>
  <version>0.5.0</version>
  <type>aar</type>
</dependency>

About

Light-weight Android Java library for NMEA sentences parsing

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages