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

1.2-legacy
Kevin Hester 2021-02-14 11:37:32 +08:00
rodzic 8c225a3c65
commit 52ec4d511c
2 zmienionych plików z 15 dodań i 17 usunięć

Wyświetl plik

@ -178,18 +178,6 @@ void MeshService::sendToMesh(MeshPacket *p)
{
nodeDB.updateFrom(*p); // update our local DB for this packet (because phone might have sent position packets etc...)
// 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 (p->which_payloadVariant == MeshPacket_decoded_tag && p->decoded.which_payloadVariant == SubPacket_position_tag &&
p->decoded.position.time) {
if (getRTCQuality() < RTCQualityGPS) {
DEBUG_MSG("Stripping time %u from position send\n", p->decoded.position.time);
p->decoded.position.time = 0;
} else
DEBUG_MSG("Providing time to mesh %u\n", p->decoded.position.time);
}
// Note: We might return !OK if our fifo was full, at that point the only option we have is to drop it
router->sendLocal(p);
}
@ -221,7 +209,7 @@ NodeInfo *MeshService::refreshMyNodeInfo() {
Position &position = node->position;
// Update our local node info with our position (even if we don't decide to update anyone else)
position.time = getValidTime(RTCQualityGPS); // This nodedb timestamp might be stale, so update it if our clock is valid.
position.time = getValidTime(RTCQualityFromNet); // This nodedb timestamp might be stale, so update it if our clock is kinda valid
position.battery_level = powerStatus->getBatteryChargePercent();
updateBatteryLevel(position.battery_level);

Wyświetl plik

@ -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);
}