firmware/src/gps/UBloxGPS.h

68 lines
1.7 KiB
C
Raw Normal View History

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;
public:
UBloxGPS();
/**
* Returns true if we succeeded
*/
virtual bool setup();
/**
* 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:
/** 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();
/**
* 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();
/// If possible force the GPS into sleep/low power mode
virtual void sleep();
private:
2020-07-10 18:43:14 +00:00
/// Attempt to connect to our GPS, returns false if no gps is present
bool tryConnect();
/// 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
};