For our first position send on boot, validate that we have received a fresh position (#9023)

This commit is contained in:
Ben Meadors
2025-12-20 07:01:00 -06:00
committed by GitHub
parent 31e55d0b66
commit 661f49ad7a
4 changed files with 20 additions and 1 deletions

View File

@@ -349,6 +349,11 @@ void PositionModule::sendOurPosition()
void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t channel)
{
if (!config.position.fixed_position && !nodeDB->hasLocalPositionSinceBoot()) {
LOG_DEBUG("Skip position send; no fresh position since boot");
return;
}
// cancel any not yet sent (now stale) position packets
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
service->cancelSending(prevPacketId);
@@ -420,8 +425,12 @@ int32_t PositionModule::runOnce()
return RUNONCE_INTERVAL;
}
bool waitingForFreshPosition = (lastGpsSend == 0) && !config.position.fixed_position && !nodeDB->hasLocalPositionSinceBoot();
if (lastGpsSend == 0 || msSinceLastSend >= intervalMs) {
if (nodeDB->hasValidPosition(node)) {
if (waitingForFreshPosition) {
LOG_DEBUG("Skip initial position send; no fresh position since boot");
} else if (nodeDB->hasValidPosition(node)) {
lastGpsSend = now;
lastGpsLatitude = node->position.latitude_i;