Skip to content

Commit 4ccdd80

Browse files
jp-bennettCopilotthebenternCopilot
authored
Add search duration check for exceeding 15 minutes (#10293)
* Add search duration check for exceeding 15 minutes Added a condition to check if the search duration exceeds 15 minutes, indicating too long of a search. * trunk * Fix searchedTooLong: move 15-min cap before UINT32_MAX check, cache elapsed, add constexpr Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/b7f74430-9e7e-4a6f-8095-6176c1eee972 Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> * Update src/gps/GPSUpdateScheduling.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove dead UINT32_MAX branch from searchedTooLong Agent-Logs-Url: https://github.com/meshtastic/firmware/sessions/6dad5b56-902e-4d0e-90c1-038a9c2df364 Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: thebentern <9000580+thebentern@users.noreply.github.com> Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent aec0805 commit 4ccdd80

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/gps/GPSUpdateScheduling.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,25 @@ bool GPSUpdateScheduling::isUpdateDue()
7070
// Have we been searching for a GPS position for too long?
7171
bool GPSUpdateScheduling::searchedTooLong()
7272
{
73+
constexpr uint32_t oneMinuteMs = 60UL * 1000UL;
74+
constexpr uint32_t maxSearchClampMs = 15UL * oneMinuteMs; // Hard cap: 15 minutes is always too long
75+
uint32_t elapsed = elapsedSearchMs();
76+
77+
// Anything over 15 minutes is too long, regardless of the broadcast interval.
78+
// TODO: Make a smarter algorithm that backs off the search dwell time when not getting a lock.
79+
if (elapsed > maxSearchClampMs)
80+
return true;
81+
7382
uint32_t minimumOrConfiguredSecs =
7483
Default::getConfiguredOrMinimumValue(config.position.position_broadcast_secs, default_broadcast_interval_secs);
7584
uint32_t maxSearchMs = Default::getConfiguredOrDefaultMs(minimumOrConfiguredSecs, default_broadcast_interval_secs);
76-
// If broadcast interval set to max, no such thing as "too long"
77-
if (maxSearchMs == UINT32_MAX)
78-
return false;
7985

8086
// If we've been searching longer than our position broadcast interval: that's too long
81-
else if (elapsedSearchMs() > maxSearchMs)
87+
if (elapsed > maxSearchMs)
8288
return true;
8389

8490
// Otherwise, not too long yet!
85-
else
86-
return false;
91+
return false;
8792
}
8893

8994
// Updates the predicted time-to-get-lock, by exponentially smoothing the latest observation

0 commit comments

Comments
 (0)