mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-05 02:59:11 +00:00
Hold for >20s after GPS lock
GPS chips are designed to stay locked for a while to download some data and save it. This data is important for speeding up future locks, and making them higher quality. Our present configuration could make every lock perform similar to first lock. This patch sets a hold of between 20s and 10% of the lock search time after lock is acquired. This should allow the GPS to finish its work before we turn it off. Fixes https://github.com/meshtastic/firmware/issues/7466
This commit is contained in:
parent
67e3a17b28
commit
7d745ec408
@ -1126,6 +1126,10 @@ int32_t GPS::runOnce()
|
||||
LOG_DEBUG("hasValidLocation RISING EDGE");
|
||||
hasValidLocation = true;
|
||||
shouldPublish = true;
|
||||
lastFixStartMsec = millis();
|
||||
// Calculate hold duration: 10% of search time or 20s, whichever is smaller
|
||||
uint32_t tenPercent = scheduling.elapsedSearchMs() / 10;
|
||||
fixHoldEnds = lastFixStartMsec + ((tenPercent < 20000) ? tenPercent : 20000);
|
||||
}
|
||||
|
||||
bool tooLong = scheduling.searchedTooLong();
|
||||
@ -1135,7 +1139,7 @@ int32_t GPS::runOnce()
|
||||
// Once we get a location we no longer desperately want an update
|
||||
if ((gotLoc && gotTime) || tooLong) {
|
||||
|
||||
if (tooLong) {
|
||||
if (tooLong && !gotLoc) {
|
||||
// we didn't get a location during this ack window, therefore declare loss of lock
|
||||
if (hasValidLocation) {
|
||||
LOG_DEBUG("hasValidLocation FALLING EDGE");
|
||||
@ -1143,8 +1147,11 @@ int32_t GPS::runOnce()
|
||||
p = meshtastic_Position_init_default;
|
||||
hasValidLocation = false;
|
||||
}
|
||||
|
||||
down();
|
||||
if (millis() > fixHoldEnds) {
|
||||
down();
|
||||
} else {
|
||||
LOG_DEBUG("Holding for GPS data download: %d ms", fixHoldEnds - millis());
|
||||
}
|
||||
shouldPublish = true; // publish our update for this just finished acquisition window
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ class GPS : private concurrency::OSThread
|
||||
uint8_t fixType = 0; // fix type from GPGSA
|
||||
#endif
|
||||
|
||||
uint32_t lastWakeStartMsec = 0, lastSleepStartMsec = 0, lastFixStartMsec = 0;
|
||||
uint32_t lastFixStartMsec = 0, fixHoldEnds = 0;
|
||||
uint32_t rx_gpio = 0;
|
||||
uint32_t tx_gpio = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user