AssetTrackerRK
Public Member Functions | Static Public Attributes
LegacyAdapter Class Reference

This class adapts the output from TinyGPS++ to match the results from the Adafruit parser and official Particle AssetTracker library. More...

#include <LegacyAdapter.h>

Inheritance diagram for LegacyAdapter:
AssetTracker

Public Member Functions

 LegacyAdapter (TinyGPSPlus &gpsData)
 Constructs the LegacyAdapter object. More...
 
virtual ~LegacyAdapter ()
 Destructor.
 
float convertToDegreesMinutes (double deg) const
 Converts a degree value (as a double) into the weird GPS DDMM.MMMMM format (degrees * 100 + minutes). More...
 
float readLat (void) const
 Return the latitude in a GPS-style value DDMM.MMMMM format (degrees * 100 + minutes). More...
 
float readLon (void) const
 Return the longitude in a GPS-style value DDMM.MMMMM format (degrees * 100 + minutes). More...
 
float readLatDeg (void) const
 Returns the latitude in degrees as a float. May be positive or negative. More...
 
float readLonDeg (void) const
 Returns the longitude in degrees as a float. May be positive or negative. More...
 
float getSpeed () const
 Gets the speed in knots. More...
 
float getAngle () const
 Get the course angle in degrees 0 <= deg < 360.
 
uint8_t getHour () const
 Get the current hour (in UTC)
 
uint8_t getMinute () const
 Get the current minute (in UTC)
 
uint8_t getSeconds () const
 Get the current second (in UTC)
 
uint16_t getMilliseconds () const
 Get the current millisecond (in UTC) More...
 
uint8_t getYear () const
 Get the current year (in UTC) More...
 
uint8_t getMonth () const
 Get the current month (1-12) (at UTC)
 
uint8_t getDay () const
 Get the current day of month (1-31) (at UTC)
 
uint32_t getGpsTimestamp () const
 Returns the number of milliseconds since the last GPS reading.
 
uint8_t getFixQuality () const
 Returns true (1) if there is a GPS fix or false (0) if not.
 
float readHDOP (void) const
 Gets the HDOP value. More...
 
float getGpsAccuracy () const
 Gets the GPS accuracy.
 
float getAltitude () const
 Get the altitude in meters.
 
float getGeoIdHeight () const
 Get the GeoID separation in meters. More...
 
uint8_t getSatellites () const
 Gets the number of satellites found.
 
bool gpsFix (void) const
 Returns true if there is a GPS fix. More...
 
String readLatLon (void) const
 Returns a string version of latitude and longitude. More...
 

Static Public Attributes

static const unsigned long MAX_GPS_AGE_MS = 10000
 GPS location must be newer than this to be considered valid.
 

Detailed Description

This class adapts the output from TinyGPS++ to match the results from the Adafruit parser and official Particle AssetTracker library.

Constructor & Destructor Documentation

◆ LegacyAdapter()

LegacyAdapter::LegacyAdapter ( TinyGPSPlus gpsData)

Constructs the LegacyAdapter object.

Parameters
gpsDataThe TinyGPSPlus object containing the actual data

You will likely never need to do this as AssetTracker is a superclass of this object. This class just separates out the legacy translation features so they can be kept together and also to be tested by the unit test framework.

Member Function Documentation

◆ convertToDegreesMinutes()

float LegacyAdapter::convertToDegreesMinutes ( double  deg) const

Converts a degree value (as a double) into the weird GPS DDMM.MMMMM format (degrees * 100 + minutes).

This is the format for the Adafruit methods that don't have "Deg" in them, like readLat() and readLon(). Because of rounding it may not be the same as the actual value returned by the GPS, but it should be close.

◆ getGeoIdHeight()

float LegacyAdapter::getGeoIdHeight ( ) const
inline

Get the GeoID separation in meters.

Geoid separation is difference between ellipsoid and mean sea level.

◆ getMilliseconds()

uint16_t LegacyAdapter::getMilliseconds ( ) const
inline

Get the current millisecond (in UTC)

Note that this is the time of the last timestamp received by GPS, and does not automatically increment, so it's not useful for measuring the actual time to the nearest millisecond!

◆ getSpeed()

float LegacyAdapter::getSpeed ( ) const
inline

Gets the speed in knots.

If you want to get more common units, you can use:

Miles per hour: getTinyGPSPlus()->getSpeed().mph(); Meters per second: getTinyGPSPlus()->getSpeed().mps(); Kilometers per hour: getTinyGPSPlus()->getSpeed().kmph();

◆ getYear()

uint8_t LegacyAdapter::getYear ( ) const
inline

Get the current year (in UTC)

Because the AssetTracker V1 only returned a 2-digit year, that is returned here as well.

The 4-digit year can be found with: getTinyGPSPlus()->getDate().year()

◆ gpsFix()

bool LegacyAdapter::gpsFix ( void  ) const
inline

Returns true if there is a GPS fix.

Note: It may take 10 seconds for for this to go to false after losing GPS signal.

◆ readHDOP()

float LegacyAdapter::readHDOP ( void  ) const
inline

Gets the HDOP value.

HDOP: Acronym for horizontal dilution of precision. A measure of the geometric quality of a GPS satellite configuration in the sky. HDOP is a factor in determining the relative accuracy of a horizontal position. The smaller the DOP number, the better the geometry.

◆ readLat()

float LegacyAdapter::readLat ( void  ) const
inline

Return the latitude in a GPS-style value DDMM.MMMMM format (degrees * 100 + minutes).

The result is always positive! To find out if the latitude is south, check location.rawLat().negative or check the sign of readLatDeg().

◆ readLatDeg()

float LegacyAdapter::readLatDeg ( void  ) const
inline

Returns the latitude in degrees as a float. May be positive or negative.

Negative values are used for south latitude.

◆ readLatLon()

String LegacyAdapter::readLatLon ( void  ) const
inline

Returns a string version of latitude and longitude.

The values are in signed degrees in lat,lon format.

◆ readLon()

float LegacyAdapter::readLon ( void  ) const
inline

Return the longitude in a GPS-style value DDMM.MMMMM format (degrees * 100 + minutes).

The result is always positive! To find out if the latitude is east, check location.rawLng().negative or check the sign of readLonDeg().

◆ readLonDeg()

float LegacyAdapter::readLonDeg ( void  ) const
inline

Returns the longitude in degrees as a float. May be positive or negative.

Negative values are used for east longitude.


The documentation for this class was generated from the following files: