2020-05-04 18:15:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "GPS.h"
|
|
|
|
#include "Observer.h"
|
2020-07-06 08:45:55 +00:00
|
|
|
#include "../concurrency/PeriodicTask.h"
|
2020-05-04 18:15:05 +00:00
|
|
|
#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-07-06 08:45:55 +00:00
|
|
|
class UBloxGPS : public GPS, public concurrency::PeriodicTask
|
2020-05-04 18:15:05 +00:00
|
|
|
{
|
|
|
|
SFE_UBLOX_GPS ublox;
|
|
|
|
|
|
|
|
bool wantNewLocation = true;
|
|
|
|
|
|
|
|
CallbackObserver<UBloxGPS, void *> notifySleepObserver = CallbackObserver<UBloxGPS, void *>(this, &UBloxGPS::prepareSleep);
|
|
|
|
|
|
|
|
public:
|
|
|
|
UBloxGPS();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if we succeeded
|
|
|
|
*/
|
|
|
|
virtual bool setup();
|
|
|
|
|
|
|
|
virtual void doTask();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Restart our lock attempt - try to get and broadcast a GPS reading ASAP
|
|
|
|
* called after the CPU wakes from light-sleep state */
|
|
|
|
virtual void startLock();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
/// Prepare the GPS for the cpu entering deep or light sleep, expect to be gone for at least 100s of msecs
|
|
|
|
/// always returns 0 to indicate okay to sleep
|
|
|
|
int prepareSleep(void *unused);
|
2020-07-10 18:43:14 +00:00
|
|
|
|
|
|
|
/// Attempt to connect to our GPS, returns false if no gps is present
|
|
|
|
bool tryConnect();
|
2020-05-04 18:15:05 +00:00
|
|
|
};
|