oops - we weren't properly stripping timestamps from new style positions

This commit is contained in:
Kevin Hester
2021-02-14 11:37:32 +08:00
parent 8c225a3c65
commit 52ec4d511c
2 changed files with 15 additions and 17 deletions

View File

@@ -31,14 +31,25 @@ MeshPacket *PositionPlugin::allocReply()
{
NodeInfo *node = service.refreshMyNodeInfo(); // should guarantee there is now a position
assert(node->has_position);
return allocDataProtobuf(node->position);
Position p = node->position;
// Strip out any time information before sending packets to other nodes - to keep the wire size small (and because other
// nodes shouldn't trust it anyways) Note: we allow a device with a local GPS to include the time, so that gpsless
// devices can get time.
if (getRTCQuality() < RTCQualityGPS) {
DEBUG_MSG("Stripping time %u from position send\n", p.time);
p.time = 0;
} else
DEBUG_MSG("Providing time to mesh %u\n", p.time);
return allocDataProtobuf(p);
}
void PositionPlugin::sendOurPosition(NodeNum dest, bool wantReplies)
{
// 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)
if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal)
service.cancelSending(prevPacketId);
MeshPacket *p = allocReply();
@@ -49,4 +60,3 @@ void PositionPlugin::sendOurPosition(NodeNum dest, bool wantReplies)
service.sendToMesh(p);
}