Skip to content

Commit 209ea6f

Browse files
committed
Congeal lock handling
1 parent fff9d69 commit 209ea6f

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

src/gps/GPS.cpp

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,37 +1155,28 @@ int32_t GPS::runOnce()
11551155
shouldPublish = true;
11561156
}
11571157

1158-
// 2. Got a lock for the first time
1158+
// 2. Got a lock for the first time, or 3. Got a lock after turning back on
11591159
bool gotLoc = lookForLocation();
1160-
if (gotLoc && !hasValidLocation) { // declare that we have location ASAP
1161-
LOG_DEBUG("hasValidLocation RISING EDGE");
1162-
hasValidLocation = true;
1163-
if (updateInterval <= 10 * 1000UL) {
1164-
shouldPublish = true;
1165-
} else {
1166-
// Hold for up to 20secs after getting a lock to download ephemeris etc
1167-
uint32_t holdTime = updateInterval - 1000;
1168-
if (holdTime > 20000)
1169-
holdTime = 20000;
1170-
fixHoldEnds = millis() + holdTime;
1160+
if (gotLoc) {
11711161
#ifdef GPS_DEBUG
1172-
LOG_DEBUG("Holding for %ums (first Lock)", holdTime);
1173-
#endif
1162+
if (!hasValidLocation) { // declare that we have location ASAP
1163+
LOG_DEBUG("hasValidLocation RISING EDGE");
11741164
}
1175-
}
1176-
// 3. Got a lock after turning back on
1177-
if (gotLoc && prev_fixQual == 0) { // just got a lock after turning back on.
1178-
if (updateInterval <= 10 * 1000UL) {
1179-
shouldPublish = true;
1180-
} else {
1181-
// Hold for up to 20secs after getting a lock to download ephemeris etc
1182-
uint32_t holdTime = updateInterval - 1000;
1183-
if (holdTime > 20000)
1184-
holdTime = 20000;
1185-
fixHoldEnds = millis() + holdTime;
1165+
#endif
1166+
if (!hasValidLocation || prev_fixQual == 0) {
1167+
hasValidLocation = true;
1168+
if (updateInterval <= 10 * 1000UL) {
1169+
shouldPublish = true;
1170+
} else {
1171+
// Hold for up to 20secs after getting a lock to download ephemeris etc
1172+
uint32_t holdTime = updateInterval - 1000;
1173+
if (holdTime > 20000)
1174+
holdTime = 20000;
1175+
fixHoldEnds = millis() + holdTime;
11861176
#ifdef GPS_DEBUG
1187-
LOG_DEBUG("Holding for %ums (Lock after GPS_OFF)", holdTime);
1177+
LOG_DEBUG("Holding for %ums after lock", holdTime);
11881178
#endif
1179+
}
11891180
}
11901181
}
11911182

0 commit comments

Comments
 (0)