mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-15 17:42:12 +00:00
fix GPS fixme wrt deletion
This commit is contained in:
parent
58715f454c
commit
217bd934d7
@ -25,7 +25,7 @@ uint8_t GPS::i2cAddress = 0;
|
|||||||
|
|
||||||
GPS *gps;
|
GPS *gps;
|
||||||
|
|
||||||
/// Multiple GPS instances might use the same serial port (in sequence), but we can
|
/// Multiple GPS instances might use the same serial port (in sequence), but we can
|
||||||
/// only init that port once.
|
/// only init that port once.
|
||||||
static bool didSerialInit;
|
static bool didSerialInit;
|
||||||
|
|
||||||
@ -33,7 +33,7 @@ bool GPS::setupGPS()
|
|||||||
{
|
{
|
||||||
if (_serial_gps && !didSerialInit) {
|
if (_serial_gps && !didSerialInit) {
|
||||||
didSerialInit = true;
|
didSerialInit = true;
|
||||||
|
|
||||||
#ifdef GPS_RX_PIN
|
#ifdef GPS_RX_PIN
|
||||||
_serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
_serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN);
|
||||||
#else
|
#else
|
||||||
@ -73,6 +73,13 @@ bool GPS::setup()
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GPS::~GPS()
|
||||||
|
{
|
||||||
|
// we really should unregister our sleep observer
|
||||||
|
notifySleepObserver.unobserve();
|
||||||
|
notifyDeepSleepObserver.unobserve();
|
||||||
|
}
|
||||||
|
|
||||||
// Allow defining the polarity of the WAKE output. default is active high
|
// Allow defining the polarity of the WAKE output. default is active high
|
||||||
#ifndef GPS_WAKE_ACTIVE
|
#ifndef GPS_WAKE_ACTIVE
|
||||||
#define GPS_WAKE_ACTIVE 1
|
#define GPS_WAKE_ACTIVE 1
|
||||||
@ -86,8 +93,8 @@ void GPS::wake()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GPS::sleep()
|
||||||
void GPS::sleep() {
|
{
|
||||||
#ifdef PIN_GPS_WAKE
|
#ifdef PIN_GPS_WAKE
|
||||||
digitalWrite(PIN_GPS_WAKE, GPS_WAKE_ACTIVE ? 0 : 1);
|
digitalWrite(PIN_GPS_WAKE, GPS_WAKE_ACTIVE ? 0 : 1);
|
||||||
pinMode(PIN_GPS_WAKE, OUTPUT);
|
pinMode(PIN_GPS_WAKE, OUTPUT);
|
||||||
@ -158,7 +165,8 @@ uint32_t GPS::getWakeTime() const
|
|||||||
return t; // already maxint
|
return t; // already maxint
|
||||||
|
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
t = radioConfig.preferences.is_router ? 5 * 60 : 15 * 60; // Allow up to 15 mins for each attempt (probably will be much less if we can find sats) or less if a router
|
t = radioConfig.preferences.is_router ? 5 * 60 : 15 * 60; // Allow up to 15 mins for each attempt (probably will be much
|
||||||
|
// less if we can find sats) or less if a router
|
||||||
|
|
||||||
t *= 1000; // msecs
|
t *= 1000; // msecs
|
||||||
|
|
||||||
@ -179,8 +187,8 @@ uint32_t GPS::getSleepTime() const
|
|||||||
if (t == UINT32_MAX)
|
if (t == UINT32_MAX)
|
||||||
return t; // already maxint
|
return t; // already maxint
|
||||||
|
|
||||||
if (t == 0) // default - unset in preferences
|
if (t == 0) // default - unset in preferences
|
||||||
t = radioConfig.preferences.is_router ? 24 * 60 * 60 : 2 * 60; // 2 mins or once per day for routers
|
t = radioConfig.preferences.is_router ? 24 * 60 * 60 : 2 * 60; // 2 mins or once per day for routers
|
||||||
|
|
||||||
t *= 1000;
|
t *= 1000;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ class GPS : private concurrency::OSThread
|
|||||||
|
|
||||||
GPS() : concurrency::OSThread("GPS") {}
|
GPS() : concurrency::OSThread("GPS") {}
|
||||||
|
|
||||||
virtual ~GPS() {} // FIXME, we really should unregister our sleep observer
|
virtual ~GPS();
|
||||||
|
|
||||||
/** We will notify this observable anytime GPS state has changed meaningfully */
|
/** We will notify this observable anytime GPS state has changed meaningfully */
|
||||||
Observable<const meshtastic::GPSStatus *> newStatus;
|
Observable<const meshtastic::GPSStatus *> newStatus;
|
||||||
|
Loading…
Reference in New Issue
Block a user