GPS NMEA Parser

group GPS_NMEA

Platform independent GPS NMEA parser.

Defines

gps_is_valid(_gh)

Check if current GPS data contain valid signal.

Note

GPS_CFG_STATEMENT_GPRMC must be enabled and GPRMC statement must be sent from GPS receiver

Return

1 on success, 0 otherwise

Parameters
  • [in] _gh: GPS handle

Typedefs

typedef double gps_float_t

GPS float definition, can be either float or double

Note

Check for GPS_CFG_DOUBLE configuration

typedef void (*gps_process_fn)(gps_statement_t res)

Signature for caller-suplied callback function from gps_process.

Parameters
  • [in] res: statement type of recently parsed statement

Enums

enum gps_statement_t

ENUM of possible GPS statements parsed.

Values:

STAT_UNKNOWN = 0

Unknown NMEA statement

STAT_GGA = 1

GPGGA statement

STAT_GSA = 2

GPGSA statement

STAT_GSV = 3

GPGSV statement

STAT_RMC = 4

GPRMC statement

STAT_UBX = 5

UBX statement (uBlox specific)

STAT_UBX_TIME = 6

UBX TIME statement (uBlox specific)

STAT_CHECKSUM_FAIL = UINT8_MAX

Special case, used when checksum fails

enum gps_speed_t

List of optional speed transformation from GPS values (in knots)

Values:

gps_speed_kps

Kilometers per second

gps_speed_kph

Kilometers per hour

gps_speed_mps

Meters per second

gps_speed_mpm

Meters per minute

gps_speed_mips

Miles per second

gps_speed_mph

Miles per hour

gps_speed_fps

Foots per second

gps_speed_fpm

Foots per minute

gps_speed_mpk

Minutes per kilometer

gps_speed_spk

Seconds per kilometer

gps_speed_sp100m

Seconds per 100 meters

gps_speed_mipm

Minutes per mile

gps_speed_spm

Seconds per mile

gps_speed_sp100y

Seconds per 100 yards

gps_speed_smph

Sea miles per hour

Functions

uint8_t gps_init(gps_t *gh)

Init GPS handle.

Return

1 on success, 0 otherwise

Parameters
  • [in] gh: GPS handle structure

uint8_t gps_process(gps_t *gh, const void *data, size_t len, gps_process_fn evt_fn)

Process NMEA data from GPS receiver.

Return

1 on success, 0 otherwise

Parameters
  • [in] gh: GPS handle structure

  • [in] data: Received data

  • [in] len: Number of bytes to process

  • [in] evt_fn: Event function to notify application layer

uint8_t gps_distance_bearing(gps_float_t las, gps_float_t los, gps_float_t lae, gps_float_t loe, gps_float_t *d, gps_float_t *b)

Calculate distance and bearing between 2 latitude and longitude coordinates.

Return

1 on success, 0 otherwise

Parameters
  • [in] las: Latitude start coordinate, in units of degrees

  • [in] los: Longitude start coordinate, in units of degrees

  • [in] lae: Latitude end coordinate, in units of degrees

  • [in] loe: Longitude end coordinate, in units of degrees

  • [out] d: Pointer to output distance in units of meters

  • [out] b: Pointer to output bearing between start and end coordinate in relation to north in units of degrees

gps_float_t gps_to_speed(gps_float_t sik, gps_speed_t ts)

Convert NMEA GPS speed (in knots = nautical mile per hour) to different speed format.

Return

Speed calculated from knots

Parameters
  • [in] sik: Speed in knots, received from GPS NMEA statement

  • [in] ts: Target speed to convert to from knots

struct gps_sat_t
#include <gps.h>

Satellite descriptor.

Public Members

uint8_t num

Satellite number

uint8_t elevation

Elevation value

uint16_t azimuth

Azimuth in degrees

uint8_t snr

Signal-to-noise ratio

struct gps_t
#include <gps.h>

GPS main structure.

Public Members

gps_float_t latitude

Latitude in units of degrees

gps_float_t longitude

Longitude in units of degrees

gps_float_t altitude

Altitude in units of meters

gps_float_t geo_sep

Geoid separation in units of meters

uint8_t sats_in_use

Number of satellites in use

uint8_t fix

Fix status. 0 = invalid, 1 = GPS fix, 2 = DGPS fix, 3 = PPS fix

uint8_t hours

Hours in UTC

uint8_t minutes

Minutes in UTC

uint8_t seconds

Seconds in UTC

gps_float_t dop_h

Dolution of precision, horizontal

gps_float_t dop_v

Dolution of precision, vertical

gps_float_t dop_p

Dolution of precision, position

uint8_t fix_mode

Fix mode. 1 = NO fix, 2 = 2D fix, 3 = 3D fix

uint8_t satellites_ids[12]

List of satellite IDs in use. Valid range is 0 to sats_in_use

uint8_t sats_in_view

Number of satellites in view

gps_sat_t sats_in_view_desc[12]
uint8_t is_valid

GPS valid status

gps_float_t speed

Ground speed in knots

gps_float_t course

Ground coarse

gps_float_t variation

Magnetic variation

uint8_t date

Fix date

uint8_t month

Fix month

uint8_t year

Fix year

gps_float_t utc_tow

UTC TimeOfWeek, eg 113851.00

uint16_t utc_wk

UTC week number, continues beyond 1023

uint8_t leap_sec

UTC leap seconds; UTC + leap_sec = TAI

uint32_t clk_bias

Receiver clock bias, eg 1930035

gps_float_t clk_drift

Receiver clock drift, eg -2660.664

uint32_t tp_gran

Time pulse granularity, eg 43