diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index f3a3bd1a..59e9fb25 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -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); diff --git a/src/plugins/PositionPlugin.cpp b/src/plugins/PositionPlugin.cpp index 4ea7298e..4a0fdb4d 100644 --- a/src/plugins/PositionPlugin.cpp +++ b/src/plugins/PositionPlugin.cpp @@ -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); } -