2020-05-04 18:15:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GPS.h"
|
|
|
|
#include "Observer.h"
|
|
|
|
#include "SparkFun_Ublox_Arduino_Library.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A gps class that only reads from the GPS periodically (and FIXME - eventually keeps the gps powered down except when reading)
|
|
|
|
*
|
|
|
|
* When new data is available it will notify observers.
|
|
|
|
*/
|
2020-10-01 16:11:54 +00:00
|
|
|
class UBloxGPS : public GPS
|
2020-05-04 18:15:05 +00:00
|
|
|
{
|
|
|
|
SFE_UBLOX_GPS ublox;
|
2020-10-05 06:43:44 +00:00
|
|
|
uint8_t fixType = 0;
|
2020-05-04 18:15:05 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
UBloxGPS();
|
|
|
|
|
2020-08-21 17:14:03 +00:00
|
|
|
/**
|
|
|
|
* Reset our GPS back to factory settings
|
|
|
|
*
|
|
|
|
* @return true for success
|
|
|
|
*/
|
|
|
|
bool factoryReset();
|
2020-05-04 18:15:05 +00:00
|
|
|
|
2020-10-01 16:11:54 +00:00
|
|
|
protected:
|
2020-10-05 07:29:26 +00:00
|
|
|
/**
|
|
|
|
* Returns true if we succeeded
|
|
|
|
*/
|
|
|
|
virtual bool setupGPS();
|
|
|
|
|
2020-10-01 16:11:54 +00:00
|
|
|
/** Subclasses should look for serial rx characters here and feed it to their GPS parser
|
|
|
|
*
|
|
|
|
* Return true if we received a valid message from the GPS
|
|
|
|
*/
|
|
|
|
virtual bool whileIdle();
|
|
|
|
|
2020-10-05 06:43:44 +00:00
|
|
|
/** Idle processing while GPS is looking for lock */
|
|
|
|
virtual void whileActive();
|
|
|
|
|
2020-10-01 16:11:54 +00:00
|
|
|
/**
|
|
|
|
* Perform any processing that should be done only while the GPS is awake and looking for a fix.
|
|
|
|
* Override this method to check for new locations
|
|
|
|
*
|
|
|
|
* @return true if we've acquired a time
|
|
|
|
*/
|
|
|
|
virtual bool lookForTime();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform any processing that should be done only while the GPS is awake and looking for a fix.
|
|
|
|
* Override this method to check for new locations
|
|
|
|
*
|
|
|
|
* @return true if we've acquired a new location
|
|
|
|
*/
|
|
|
|
virtual bool lookForLocation();
|
2021-09-02 13:21:48 +00:00
|
|
|
virtual bool hasLock();
|
2020-10-01 16:11:54 +00:00
|
|
|
|
|
|
|
/// If possible force the GPS into sleep/low power mode
|
|
|
|
virtual void sleep();
|
2020-10-05 07:29:26 +00:00
|
|
|
virtual void wake();
|
2020-10-01 16:11:54 +00:00
|
|
|
|
2020-08-21 17:14:03 +00:00
|
|
|
private:
|
2020-07-10 18:43:14 +00:00
|
|
|
/// Attempt to connect to our GPS, returns false if no gps is present
|
|
|
|
bool tryConnect();
|
2020-08-21 17:14:03 +00:00
|
|
|
|
|
|
|
/// Switch to our desired operating mode and save the settings to flash
|
|
|
|
/// returns true for success
|
|
|
|
bool setUBXMode();
|
2020-10-01 16:11:54 +00:00
|
|
|
|
|
|
|
uint16_t maxWait() const { return i2cAddress ? 300 : 0; /*If using i2c we must poll with wait */ }
|
2020-05-04 18:15:05 +00:00
|
|
|
};
|