firmware/src/gps/UBloxGPS.h

53 lines
1.4 KiB
C
Raw Normal View History

2020-05-04 18:15:05 +00:00
#pragma once
#include "../concurrency/PeriodicTask.h"
2020-05-04 18:15:05 +00:00
#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-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;
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();
/**
* Reset our GPS back to factory settings
*
* @return true for success
*/
bool factoryReset();
2020-05-04 18:15:05 +00:00
private:
2020-05-04 18:15:05 +00:00
/// 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();
/// Switch to our desired operating mode and save the settings to flash
/// returns true for success
bool setUBXMode();
2020-05-04 18:15:05 +00:00
};