diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index fcc82e54c..0bd35c687 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -15,6 +15,22 @@ ErrorCode FloodingRouter::send(meshtastic_MeshPacket *p) // Add any messages _we_ send to the seen message list (so we will ignore all retransmissions we see) wasSeenRecently(p); // FIXME, move this to a sniffSent method + // -- START coverage filter population -- + // If this is a floodable packet (for example, has non-zero hop_limit and ID), + // we can add our coverage. + if (p->id != 0 && p->hop_limit > 0) { + CoverageFilter coverage; + // Is there anything upstream of this? I think not, but if so, we need to merge coverage. + // loadCoverageFilterFromPacket(p, coverage); + + // Add our coverage (neighbors, etc.) so they are in the filter from the get-go + mergeMyCoverage(coverage); + + // Save the coverage bits into the packet: + storeCoverageFilterInPacket(coverage, p); + } + // -- END coverage filter population -- + return Router::send(p); } diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index f343263f9..0e92b34ae 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -634,6 +634,15 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p) p->hop_limit | (p->want_ack ? PACKET_FLAGS_WANT_ACK_MASK : 0) | (p->via_mqtt ? PACKET_FLAGS_VIA_MQTT_MASK : 0); radioBuffer.header.flags |= (p->hop_start << PACKET_FLAGS_HOP_START_SHIFT) & PACKET_FLAGS_HOP_START_MASK; + // Coverage filter is 16 bytes, but p->coverage_filter.size might be 0..16. + // Usually, you set p->coverage_filter.size = 16 if you want to transmit. + radioBuffer.header.coverage_filter.fill(0); // Clear first, in case size < 16 + if (p->coverage_filter.size > 0) { + memcpy(radioBuffer.header.coverage_filter.data(), + p->coverage_filter.bytes, + std::min((size_t)p->coverage_filter.size, (size_t)BLOOM_FILTER_SIZE_BYTES)); + } + // if the sender nodenum is zero, that means uninitialized assert(radioBuffer.header.from);