LwGPS

group LWGPS

Lightweight GPS NMEA parser.

Defines

lwgps_speed_kps

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_kph

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_mps

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_mpm

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_mips

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_mph

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_fps

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_fpm

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_mpk

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_spk

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_sp100m

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_mipm

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_spm

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_sp100y

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_speed_smph

Backward compatibility.

Deprecated:

Use lwgps_speed_t instead

lwgps_is_valid(_gh)

Check if current GPS data contain valid signal.

Note

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

Parameters
  • _gh[in] GPS handle

Returns

1 on success, 0 otherwise

Typedefs

typedef double lwgps_float_t

GPS float definition, can be either float or double

Note

Check for LWGPS_CFG_DOUBLE configuration

typedef void (*lwgps_process_fn)(lwgps_statement_t res)

Signature for caller-suplied callback function from gps_process.

Param res

[in] statement type of recently parsed statement

Enums

enum lwgps_statement_t

ENUM of possible GPS statements parsed.

Values:

enumerator STAT_UNKNOWN = 0

Unknown NMEA statement

enumerator STAT_GGA = 1

GPGGA statement

enumerator STAT_GSA = 2

GPGSA statement

enumerator STAT_GSV = 3

GPGSV statement

enumerator STAT_RMC = 4

GPRMC statement

enumerator STAT_UBX = 5

UBX statement (uBlox specific)

enumerator STAT_UBX_TIME = 6

UBX TIME statement (uBlox specific)

enumerator STAT_CHECKSUM_FAIL = UINT8_MAX

Special case, used when checksum fails

enum lwgps_speed_t

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

Values:

enumerator LWGPS_SPEED_KPS

Kilometers per second

enumerator LWGPS_SPEED_KPH

Kilometers per hour

enumerator LWGPS_SPEED_MPS

Meters per second

enumerator LWGPS_SPEED_MPM

Meters per minute

enumerator LWGPS_SPEED_MIPS

Miles per second

enumerator LWGPS_SPEED_MPH

Miles per hour

enumerator LWGPS_SPEED_FPS

Foots per second

enumerator LWGPS_SPEED_FPM

Foots per minute

enumerator LWGPS_SPEED_MPK

Minutes per kilometer

enumerator LWGPS_SPEED_SPK

Seconds per kilometer

enumerator LWGPS_SPEED_SP100M

Seconds per 100 meters

enumerator LWGPS_SPEED_MIPM

Minutes per mile

enumerator LWGPS_SPEED_SPM

Seconds per mile

enumerator LWGPS_SPEED_SP100Y

Seconds per 100 yards

enumerator LWGPS_SPEED_SMPH

Sea miles per hour

Functions

uint8_t lwgps_init(lwgps_t *gh)

Init GPS handle.

Parameters

ghandle[in] GPS handle structure

Returns

1 on success, 0 otherwise

uint8_t lwgps_process(lwgps_t *gh, const void *data, size_t len, lwgps_process_fn evt_fn)

Process NMEA data from GPS receiver.

Parameters
  • ghandle[in] GPS handle structure

  • data[in] Received data

  • len[in] Number of bytes to process

  • evt_fn[in] Event function to notify application layer. This parameter is available only if LWGPS_CFG_STATUS is enabled

Returns

1 on success, 0 otherwise

uint8_t lwgps_distance_bearing(lwgps_float_t las, lwgps_float_t los, lwgps_float_t lae, lwgps_float_t loe, lwgps_float_t *d, lwgps_float_t *b)

Calculate distance and bearing between 2 latitude and longitude coordinates.

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

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

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

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

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

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

Returns

1 on success, 0 otherwise

lwgps_float_t lwgps_to_speed(lwgps_float_t sik, lwgps_speed_t ts)

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

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

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

Returns

Speed calculated from knots

struct lwgps_sat_t
#include <lwgps.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 lwgps_t
#include <lwgps.h>

GPS main structure.

Public Members

lwgps_float_t latitude

Latitude in units of degrees

lwgps_float_t longitude

Longitude in units of degrees

lwgps_float_t altitude

Altitude in units of meters

lwgps_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

lwgps_float_t dgps_age

Age of DGPS correction data (in seconds)

lwgps_float_t dop_h

Dolution of precision, horizontal

lwgps_float_t dop_v

Dolution of precision, vertical

lwgps_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

lwgps_sat_t sats_in_view_desc[12]
uint8_t is_valid

GPS valid status

lwgps_float_t speed

Ground speed in knots

lwgps_float_t course

Ground coarse

lwgps_float_t variation

Magnetic variation

uint8_t date

Fix date

uint8_t month

Fix month

uint8_t year

Fix year

lwgps_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

lwgps_float_t clk_drift

Receiver clock drift, eg -2660.664

uint32_t tp_gran

Time pulse granularity, eg 43