map coverage filter

This commit is contained in:
medentem 2024-12-29 18:45:22 -06:00
parent bb46618078
commit 88d9c38031
4 changed files with 17 additions and 25 deletions

View File

@ -15,12 +15,9 @@ 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.
// 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
@ -28,8 +25,6 @@ ErrorCode FloodingRouter::send(meshtastic_MeshPacket *p)
// Save the coverage bits into the packet:
storeCoverageFilterInPacket(coverage, p);
}
// -- END coverage filter population --
return Router::send(p);
}

View File

@ -317,8 +317,6 @@ void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
// --- Coverage filter logging ---
if (p->coverage_filter.size > 0) {
// If the coverage_filter.size is 0, you might skip printing or
// choose to indicate it differently. Usually it will be 16 though.
std::string coverageHex;
// Reserve enough space for 2 hex characters per byte.
coverageHex.reserve(p->coverage_filter.size * 2);
@ -634,13 +632,13 @@ 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
// Clear out coverage_filter
memset(radioBuffer.header.coverage_filter, 0, BLOOM_FILTER_SIZE_BYTES);
// Copy if size > 0:
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));
memcpy(radioBuffer.header.coverage_filter, p->coverage_filter.bytes,
std::min<size_t>(p->coverage_filter.size, BLOOM_FILTER_SIZE_BYTES));
}
// if the sender nodenum is zero, that means uninitialized

View File

@ -45,7 +45,7 @@ typedef struct {
uint8_t relay_node;
// A 16-byte Bloom filter that tracks coverage of the current node.
std::array<uint8_t, BLOOM_FILTER_SIZE_BYTES> coverage_filter;
uint8_t coverage_filter[BLOOM_FILTER_SIZE_BYTES] __attribute__((__aligned));
} PacketHeader;
/**

View File

@ -411,8 +411,7 @@ void RadioLibInterface::handleReceiveInterrupt()
// ----------------- Copy coverage_filter in the packet object ------------------
mp->coverage_filter.size = BLOOM_FILTER_SIZE_BYTES;
memcpy(mp->coverage_filter.bytes,
radioBuffer.header.coverage_filter.data(), BLOOM_FILTER_SIZE_BYTES);
memcpy(mp->coverage_filter.bytes, radioBuffer.header.coverage_filter, BLOOM_FILTER_SIZE_BYTES);
// -----------------------------------------------------------------------------
addReceiveMetadata(mp);