24 #ifndef _ADAFRUIT_GPS_H 25 #define _ADAFRUIT_GPS_H 32 #ifndef NMEA_EXTRAS // inject on the compile command line to force extensions 33 #ifndef ARDUINO_ARCH_AVR 34 #define NMEA_EXTENSIONS 38 #define NMEA_EXTENSIONS 42 #if (defined(__AVR__) || ((defined(ARDUINO_UNOR4_WIFI) || defined(ESP8266)) && \ 43 !defined(NO_SW_SERIAL))) 47 #define GPS_DEFAULT_I2C_ADDR \ 49 #define GPS_MAX_I2C_TRANSFER \ 51 #define GPS_MAX_SPI_TRANSFER \ 53 #define MAXLINELENGTH 120 54 #define NMEA_MAX_SENTENCE_ID \ 56 #define NMEA_MAX_SOURCE_ID \ 61 #include <SoftwareSerial.h> 88 bool begin(uint32_t baud_or_i2caddr);
102 size_t write(uint8_t);
111 bool usingInterrupts =
false, uint32_t timeout = 10000);
124 bool check(
char *nmea);
125 bool onList(
char *nmea,
const char **list);
129 #ifdef NMEA_EXTENSIONS 131 char ref =
'R',
bool noCRLF =
false);
137 #ifdef NMEA_EXTENSIONS 141 char *unit = NULL,
unsigned long response = 0,
145 unsigned historyInterval = 20,
146 unsigned historyN = 192);
220 #ifdef NMEA_EXTENSIONS 239 #endif // NMEA_EXTENSIONS 249 const char *tokenOnList(
char *token,
const char list[][4]);
250 bool parseCoord(
char *p,
nmea_float_t *angleDegrees = NULL,
251 nmea_float_t *angle = NULL, int32_t *angle_fixed = NULL,
253 char *parseStr(
char *buff,
char *p,
int n);
256 int32_t *angle_fixed,
char *dir);
258 bool parseAntenna(
char *);
259 bool isEmpty(
char *pStart);
262 static const char PROGMEM sources[][4];
263 static const char PROGMEM sentences_parsed[][4];
264 static const char PROGMEM sentences_known[][4];
268 uint32_t lastUpdate =
270 uint32_t lastFix = 2000000000L;
271 uint32_t lastTime = 2000000000L;
272 uint32_t lastDate = 2000000000L;
273 uint32_t sentTime = 2000000000L;
277 uint8_t parseResponse(
char *response);
279 SoftwareSerial *gpsSwSerial;
281 bool noComms =
false;
282 HardwareSerial *gpsHwSerial;
286 int8_t gpsSPI_cs = -1;
287 SPISettings gpsSPI_settings =
288 SPISettings(1000000, MSBFIRST, SPI_MODE0);
291 int8_t _buff_max = -1, _buff_idx = 0;
298 const char *
volatile lastline =
300 volatile bool recvdflag;
301 volatile bool inStandbyMode;
nmea_float_t PDOP
Definition: Adafruit_GPS.h:198
Definition: NMEA_data.h:51
void showDataValue(nmea_index_t idx, int n=7)
Print out the current state of a data value. Primarily useful as a debugging aid. ...
Definition: NMEA_data.cpp:442
void pause(bool b)
Pause/unpause receiving new data.
Definition: Adafruit_GPS.cpp:395
#define NMEA_MAX_SENTENCE_ID
maximum length of a sentence ID name, including terminating 0
Definition: Adafruit_GPS.h:54
bool onList(char *nmea, const char **list)
Check if an NMEA string is valid and is on a list, perhaps to decide if it should be passed to a part...
Definition: NMEA_parse.cpp:657
gnss_sentence_status_t
Result of validating fields used by a standard navigation decoder.
Definition: Adafruit_GNSS.h:49
nmea_float_t angle
Course in degrees from true north.
Definition: Adafruit_GPS.h:192
int txtN
the TXT sentence number
Definition: Adafruit_GPS.h:238
uint8_t day
GMT day.
Definition: Adafruit_GPS.h:172
nmea_float_t speed
Current speed over ground in knots.
Definition: Adafruit_GPS.h:191
uint8_t minute
GMT minutes.
Definition: Adafruit_GPS.h:167
nmea_float_t HDOP
Definition: Adafruit_GPS.h:194
Definition: Adafruit_GNSS.h:22
void removeHistory(nmea_index_t idx)
Remove history from a data value table entry, if it has been added.
Definition: NMEA_data.cpp:423
has a recognized source ID
Definition: Adafruit_GPS.h:76
char txtTXT[63]
text content from most recent TXT sentence
Definition: Adafruit_GPS.h:235
Definition: Adafruit_GNSS.h:67
uint8_t LOCUS_percent
Log life used percentage.
Definition: Adafruit_GPS.h:218
uint8_t year
GMT year.
Definition: Adafruit_GPS.h:170
bool fix
Have a fix?
Definition: Adafruit_GPS.h:203
char lat
N/S.
Definition: Adafruit_GPS.h:200
Definition: NMEA_data.h:96
void addChecksum(char *buff)
Add *CS where CS is the two character hex checksum for all but the first character in the string...
Definition: NMEA_build.cpp:596
uint8_t LOCUS_distance
Distance setting.
Definition: Adafruit_GPS.h:215
int32_t latitude_fixed
Definition: Adafruit_GPS.h:182
Adafruit_GPS()
Constructor when there are no communications attached.
Definition: Adafruit_GPS.cpp:141
uint8_t seconds
GMT seconds.
Definition: Adafruit_GPS.h:168
bool wakeup(void)
Wake the sensor up.
Definition: Adafruit_GPS.cpp:590
passed none of the checks
Definition: Adafruit_GPS.h:71
char * lastNMEA(void)
Returns the last NMEA line received and unsets the received flag.
Definition: Adafruit_GPS.cpp:403
void common_init(void)
Initialization code used by all constructor types.
Definition: Adafruit_GPS.cpp:151
uint8_t LOCUS_config
Contents of configuration.
Definition: Adafruit_GPS.h:213
nmea_float_t depthToKeel
depth from surface to bottom of keel in metres
Definition: Adafruit_GPS.h:225
nmea_float_t boatAngle(nmea_float_t s, nmea_float_t c)
Estimate a direction in -180 to 180 degree range from the values of the sine and cosine of the compou...
Definition: NMEA_data.cpp:518
nmea_history_t * initHistory(nmea_index_t idx, nmea_float_t scale=10.0, nmea_float_t offset=0.0, unsigned historyInterval=20, unsigned historyN=192)
Attempt to add history to a data value table entry. If it fails to malloc the space, history will not be added. Test the pointer for a check if needed. Select scale and offset values carefully so that operations and results will fit inside 16 bit integer limits. For example a scale of 1.0 and an offset of 100000.0 would be a good choice for atmospheric pressure in Pa with values ranging ~ +/- 3500, while a scale of 10.0 would be pushing the integer limits.
Definition: NMEA_data.cpp:382
size_t available(void)
How many bytes are available to read - part of 'Print'-class functionality.
Definition: Adafruit_GPS.cpp:198
Definition: Adafruit_GNSS.h:84
has a recognized sentence ID
Definition: Adafruit_GPS.h:77
char * build(char *nmea, const char *thisSource, const char *thisSentence, char ref='R', bool noCRLF=false)
Build an NMEA sentence string based on the relevant variables. Sentences start with a $...
Definition: NMEA_build.cpp:68
uint8_t LOCUS_type
Log type, 0: Overlap, 1: FullStop.
Definition: Adafruit_GPS.h:211
has a recognized parseable sentence ID
Definition: Adafruit_GPS.h:78
int thisCheck
the results of the check on the current sentence
Definition: Adafruit_GPS.h:154
char thisSource[NMEA_MAX_SOURCE_ID]
the first two letters of the current sentence, e.g. WI, GP
Definition: Adafruit_GPS.h:155
nmea_float_t secondsSinceFix()
Time in seconds since the last position fix was obtained. The time returned is limited to 2^32 millis...
Definition: Adafruit_GPS.cpp:612
bool LOCUS_StopLogger(void)
Stop the LOCUS logger.
Definition: Adafruit_GPS.cpp:504
bool isCompoundAngle(nmea_index_t idx)
Check if it is a compound angle.
Definition: NMEA_data.cpp:503
Definition: NMEA_data.h:190
uint8_t fixquality_3d
3D fix quality (1, 3, 3 = Nofix, 2D fix, 3D fix)
Definition: Adafruit_GPS.h:205
char mag
Magnetic variation direction.
Definition: Adafruit_GPS.h:202
uint8_t hour
GMT hours.
Definition: Adafruit_GPS.h:166
The GPS class.
Definition: Adafruit_GPS.h:85
nmea_float_t magvariation
Magnetic variation in degrees (vs. true north)
Definition: Adafruit_GPS.h:193
nmea_float_t depthToTransducer
depth of transducer below the surface in metres
Definition: Adafruit_GPS.h:227
int txtID
id of the text message
Definition: Adafruit_GPS.h:237
bool begin(uint32_t baud_or_i2caddr)
Start the HW or SW serial port.
Definition: Adafruit_GPS.cpp:42
nmea_float_t secondsSinceTime()
Time in seconds since the last GPS time was obtained. The time returned is limited to 2^32 millisecon...
Definition: Adafruit_GPS.cpp:624
int txtTot
total TXT sentences in group
Definition: Adafruit_GPS.h:236
uint8_t LOCUS_status
0: Logging, 1: Stop logging
Definition: Adafruit_GPS.h:217
nmea_float_t longitude
Definition: Adafruit_GPS.h:176
virtual ~Adafruit_GPS()
Destroy the object.
Definition: Adafruit_GPS.cpp:184
void newDataValue(nmea_index_t tag, nmea_float_t v)
Update the value and history information with a new value. Call whenever a new data value is received...
Definition: NMEA_data.cpp:44
nmea_float_t altitude
Altitude in meters above MSL.
Definition: Adafruit_GPS.h:190
Transport-independent decoding of standard GNSS fields.
uint8_t antenna
1=problem, 2=internal, 3=external (PGTOP or PCD)
Definition: Adafruit_GPS.h:207
nmea_index_t
Definition: NMEA_data.h:121
uint8_t LOCUS_interval
Interval setting.
Definition: Adafruit_GPS.h:214
has a valid checksum at the end
Definition: Adafruit_GPS.h:74
gnss_position_t lastPosition() const
Decode the latest received sentence with exact coordinate precision.
Definition: Adafruit_GPS.cpp:430
bool standby(void)
Standby Mode Switches.
Definition: Adafruit_GPS.cpp:568
#define MAXWAITSENTENCE
maximum number of sentences to examine when looking for a response
Definition: Adafruit_PMTK.h:117
nmea_datavalue_t val[NMEA_MAX_INDEX]
Definition: Adafruit_GPS.h:223
uint8_t satellites
Number of satellites in use.
Definition: Adafruit_GPS.h:206
bool check(char *nmea)
Validate NMEA framing and checksum, then recognize its source and complete sentence ID...
Definition: NMEA_parse.cpp:587
#define NMEA_MAX_SOURCE_ID
maximum length of a source ID name, including terminating 0
Definition: Adafruit_GPS.h:56
bool parse(char *)
Parse a standard NMEA string and update the relevant variables. Sentences start with a $...
Definition: NMEA_parse.cpp:70
nmea_float_t latitudeDegrees
Latitude in decimal degrees.
Definition: Adafruit_GPS.h:187
nmea_float_t secondsSinceDate()
Time in seconds since the last GPS date was obtained. The time returned is limited to 2^32 millisecon...
Definition: Adafruit_GPS.cpp:636
void resetSentTime()
Fakes time of receipt of a sentence. Use between build() and parse() to make the timing look like the...
Definition: Adafruit_GPS.cpp:646
bool newNMEAreceived()
Check to see if a new NMEA line has been received.
Definition: Adafruit_GPS.cpp:387
uint8_t LOCUS_speed
Speed setting.
Definition: Adafruit_GPS.h:216
#define MAXLINELENGTH
how long are max NMEA lines to parse?
Definition: Adafruit_GPS.h:53
Definition: Adafruit_NMEA.h:33
uint8_t parseHex(char c)
Parse a hex character and return the appropriate decimal value.
Definition: NMEA_parse.cpp:873
bool LOCUS_ReadStatus(void)
Read the logger status.
Definition: Adafruit_GPS.cpp:516
size_t write(uint8_t)
Write a byte to the underlying transport - part of 'Print'-class functionality.
Definition: Adafruit_GPS.cpp:229
nmea_check_t
type for resulting code from running check()
Definition: Adafruit_GPS.h:70
nmea_float_t latitude
Definition: Adafruit_GPS.h:174
uint16_t LOCUS_records
Log number of data record.
Definition: Adafruit_GPS.h:210
char fromID[NMEA_MAX_WP_ID]
id of waypoint coming from on this segment of the route
Definition: Adafruit_GPS.h:232
uint8_t LOCUS_mode
Logging mode, 0x08 interval logger.
Definition: Adafruit_GPS.h:212
char thisSentence[NMEA_MAX_SENTENCE_ID]
the next three letters of the current sentence, e.g. GLL, RMC
Definition: Adafruit_GPS.h:157
has a dollar sign or exclamation mark in the first position
Definition: Adafruit_GPS.h:72
#define GPS_MAX_I2C_TRANSFER
The max number of bytes we'll try to read at once.
Definition: Adafruit_GPS.h:49
nmea_float_t compassAngle(nmea_float_t s, nmea_float_t c)
Estimate a direction in 0 to 360 degree range from the values of the sine and cosine of the compound ...
Definition: NMEA_data.cpp:559
nmea_float_t longitudeDegrees
Longitude in decimal degrees.
Definition: Adafruit_GPS.h:188
uint16_t milliseconds
GMT milliseconds.
Definition: Adafruit_GPS.h:169
uint8_t month
GMT month.
Definition: Adafruit_GPS.h:171
bool waitForSentence(const char *wait, uint8_t max=MAXWAITSENTENCE, bool usingInterrupts=false, uint32_t timeout=10000)
Wait for a specified sentence from the device.
Definition: Adafruit_GPS.cpp:454
void initDataValue(nmea_index_t idx, char *label=NULL, char *fmt=NULL, char *unit=NULL, unsigned long response=0, nmea_value_type_t type=NMEA_SIMPLE_FLOAT)
Initialize the contents of a data value table entry.
Definition: NMEA_data.cpp:341
nmea_value_type_t
Definition: NMEA_data.h:71
char lon
E/W.
Definition: Adafruit_GPS.h:201
bool LOCUS_StartLogger(void)
Start the LOCUS logger.
Definition: Adafruit_GPS.cpp:492
nmea_float_t getSmoothed(nmea_index_t idx)
Clearer approach to retrieving NMEA values.
Definition: NMEA_data.cpp:320
uint8_t fixquality
Fix quality (0, 1, 2 = Invalid, GPS, DGPS)
Definition: Adafruit_GPS.h:204
nmea_float_t geoidheight
Diff between geoid height and WGS84 height.
Definition: Adafruit_GPS.h:189
uint16_t LOCUS_serial
Log serial number.
Definition: Adafruit_GPS.h:209
int32_t longitude_fixed
Definition: Adafruit_GPS.h:184
char lastSource[NMEA_MAX_SOURCE_ID]
Definition: Adafruit_GPS.h:159
char read(void)
Read one character from the GPS device.
Definition: Adafruit_GPS.cpp:279
char lastSentence[NMEA_MAX_SENTENCE_ID]
Definition: Adafruit_GPS.h:162
#define NMEA_MAX_WP_ID
maximum length of a waypoint ID name, including terminating 0
Definition: NMEA_data.h:10
void sendCommand(const char *)
Send a command to the GPS device.
Definition: Adafruit_GPS.cpp:371
A simple floating point number.
Definition: NMEA_data.h:72
nmea_float_t VDOP
Definition: Adafruit_GPS.h:196
NMEA_FLOAT_T nmea_float_t
the type of variables to use for floating point
Definition: NMEA_data.h:35
there is a token after the $ followed by a comma
Definition: Adafruit_GPS.h:75
char toID[NMEA_MAX_WP_ID]
id of waypoint going to on this segment of the route
Definition: Adafruit_GPS.h:230