mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-06 11:39:32 +00:00
map coverage filter
This commit is contained in:
parent
bb46618078
commit
88d9c38031
@ -14,22 +14,17 @@ ErrorCode FloodingRouter::send(meshtastic_MeshPacket *p)
|
|||||||
{
|
{
|
||||||
// Add any messages _we_ send to the seen message list (so we will ignore all retransmissions we see)
|
// 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
|
wasSeenRecently(p); // FIXME, move this to a sniffSent method
|
||||||
|
|
||||||
|
CoverageFilter coverage;
|
||||||
|
// Is there anything upstream of this?
|
||||||
|
// I think not, but if so, we need to merge coverage.
|
||||||
|
// loadCoverageFilterFromPacket(p, coverage);
|
||||||
|
|
||||||
// -- START coverage filter population --
|
// Add our coverage (neighbors, etc.) so they are in the filter from the get-go
|
||||||
// If this is a floodable packet (for example, has non-zero hop_limit and ID),
|
mergeMyCoverage(coverage);
|
||||||
// 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
|
// Save the coverage bits into the packet:
|
||||||
mergeMyCoverage(coverage);
|
storeCoverageFilterInPacket(coverage, p);
|
||||||
|
|
||||||
// Save the coverage bits into the packet:
|
|
||||||
storeCoverageFilterInPacket(coverage, p);
|
|
||||||
}
|
|
||||||
// -- END coverage filter population --
|
|
||||||
|
|
||||||
return Router::send(p);
|
return Router::send(p);
|
||||||
}
|
}
|
||||||
|
@ -317,8 +317,6 @@ void printPacket(const char *prefix, const meshtastic_MeshPacket *p)
|
|||||||
|
|
||||||
// --- Coverage filter logging ---
|
// --- Coverage filter logging ---
|
||||||
if (p->coverage_filter.size > 0) {
|
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;
|
std::string coverageHex;
|
||||||
// Reserve enough space for 2 hex characters per byte.
|
// Reserve enough space for 2 hex characters per byte.
|
||||||
coverageHex.reserve(p->coverage_filter.size * 2);
|
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);
|
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;
|
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.
|
// Clear out coverage_filter
|
||||||
// Usually, you set p->coverage_filter.size = 16 if you want to transmit.
|
memset(radioBuffer.header.coverage_filter, 0, BLOOM_FILTER_SIZE_BYTES);
|
||||||
radioBuffer.header.coverage_filter.fill(0); // Clear first, in case size < 16
|
|
||||||
|
// Copy if size > 0:
|
||||||
if (p->coverage_filter.size > 0) {
|
if (p->coverage_filter.size > 0) {
|
||||||
memcpy(radioBuffer.header.coverage_filter.data(),
|
memcpy(radioBuffer.header.coverage_filter, p->coverage_filter.bytes,
|
||||||
p->coverage_filter.bytes,
|
std::min<size_t>(p->coverage_filter.size, BLOOM_FILTER_SIZE_BYTES));
|
||||||
std::min((size_t)p->coverage_filter.size, (size_t)BLOOM_FILTER_SIZE_BYTES));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the sender nodenum is zero, that means uninitialized
|
// if the sender nodenum is zero, that means uninitialized
|
||||||
|
@ -45,7 +45,7 @@ typedef struct {
|
|||||||
uint8_t relay_node;
|
uint8_t relay_node;
|
||||||
|
|
||||||
// A 16-byte Bloom filter that tracks coverage of the current 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;
|
} PacketHeader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -411,8 +411,7 @@ void RadioLibInterface::handleReceiveInterrupt()
|
|||||||
|
|
||||||
// ----------------- Copy coverage_filter in the packet object ------------------
|
// ----------------- Copy coverage_filter in the packet object ------------------
|
||||||
mp->coverage_filter.size = BLOOM_FILTER_SIZE_BYTES;
|
mp->coverage_filter.size = BLOOM_FILTER_SIZE_BYTES;
|
||||||
memcpy(mp->coverage_filter.bytes,
|
memcpy(mp->coverage_filter.bytes, radioBuffer.header.coverage_filter, BLOOM_FILTER_SIZE_BYTES);
|
||||||
radioBuffer.header.coverage_filter.data(), BLOOM_FILTER_SIZE_BYTES);
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
addReceiveMetadata(mp);
|
addReceiveMetadata(mp);
|
||||||
|
Loading…
Reference in New Issue
Block a user