mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-08 04:28:47 +00:00
expand relay_node and utilize to improve coverage knowledge
This commit is contained in:
parent
25a58003c7
commit
4a60761af5
@ -37,12 +37,11 @@ enum RxSource {
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#ifdef USERPREFS_USE_COVERAGE_FILTER
|
#ifdef USERPREFS_USE_COVERAGE_FILTER
|
||||||
#define HOP_MAX 15
|
#define HOP_MAX 15
|
||||||
#else
|
#else
|
||||||
#define HOP_MAX 7
|
#define HOP_MAX 7
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/// We normally just use max 3 hops for sending reliable messages
|
/// We normally just use max 3 hops for sending reliable messages
|
||||||
#define HOP_RELIABLE 3
|
#define HOP_RELIABLE 3
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ enum RxSource {
|
|||||||
#define STALE_COVERAGE_SECONDS 60 * 60 * 0.5 // 1 hour
|
#define STALE_COVERAGE_SECONDS 60 * 60 * 0.5 // 1 hour
|
||||||
|
|
||||||
// Size of the Bloom filter in bytes (128 bits)
|
// Size of the Bloom filter in bytes (128 bits)
|
||||||
#define BLOOM_FILTER_SIZE_BYTES 16
|
#define BLOOM_FILTER_SIZE_BYTES 13
|
||||||
|
|
||||||
// Size of the Bloom filter in bits (128 bits)
|
// Size of the Bloom filter in bits (128 bits)
|
||||||
#define BLOOM_FILTER_SIZE_BITS (BLOOM_FILTER_SIZE_BYTES * 8)
|
#define BLOOM_FILTER_SIZE_BITS (BLOOM_FILTER_SIZE_BYTES * 8)
|
||||||
|
@ -498,7 +498,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
|
|||||||
#else
|
#else
|
||||||
config.lora.hop_limit = HOP_RELIABLE;
|
config.lora.hop_limit = HOP_RELIABLE;
|
||||||
#endif
|
#endif
|
||||||
LOG_DEBUG("Hop Limit set to %x", config.lora.hop_limit);
|
LOG_DEBUG("Hop Limit set to %x", config.lora.hop_limit);
|
||||||
#ifdef USERPREFS_CONFIG_LORA_IGNORE_MQTT
|
#ifdef USERPREFS_CONFIG_LORA_IGNORE_MQTT
|
||||||
config.lora.ignore_mqtt = USERPREFS_CONFIG_LORA_IGNORE_MQTT;
|
config.lora.ignore_mqtt = USERPREFS_CONFIG_LORA_IGNORE_MQTT;
|
||||||
#else
|
#else
|
||||||
@ -835,17 +835,12 @@ bool NodeDB::isValidCandidateForCoverage(const meshtastic_NodeInfoLite &node)
|
|||||||
LOG_DEBUG("Node 0x%x is not valid for coverage: Ignored", node.num);
|
LOG_DEBUG("Node 0x%x is not valid for coverage: Ignored", node.num);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 3) Exclude nodes that aren't direct neighbors
|
// 3) Exclude MQTT-based nodes if desired
|
||||||
if (!node.has_hops_away || node.hops_away != 0) {
|
|
||||||
LOG_DEBUG("Node 0x%x is not valid for coverage: Not Direct Neighbor", node.num);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 4) Exclude MQTT-based nodes if desired
|
|
||||||
if (node.via_mqtt) {
|
if (node.via_mqtt) {
|
||||||
LOG_DEBUG("Node 0x%x is not valid for coverage: MQTT", node.num);
|
LOG_DEBUG("Node 0x%x is not valid for coverage: MQTT", node.num);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// 5) Must have last_heard
|
// 4) Must have last_heard
|
||||||
if (node.last_heard == 0) {
|
if (node.last_heard == 0) {
|
||||||
LOG_DEBUG("Node 0x%x is not valid for coverage: Missing Last Heard", node.num);
|
LOG_DEBUG("Node 0x%x is not valid for coverage: Missing Last Heard", node.num);
|
||||||
return false;
|
return false;
|
||||||
@ -869,7 +864,6 @@ bool NodeDB::isValidCandidateForCoverage(const meshtastic_NodeInfoLite &node)
|
|||||||
std::vector<NodeNum> NodeDB::getCoveredNodes(uint32_t timeWindowSecs)
|
std::vector<NodeNum> NodeDB::getCoveredNodes(uint32_t timeWindowSecs)
|
||||||
{
|
{
|
||||||
uint32_t now = getTime();
|
uint32_t now = getTime();
|
||||||
NodeNum localNode = getNodeNum();
|
|
||||||
|
|
||||||
// We'll collect (nodeNum, last_heard, snr) for both main DB + ephemeral
|
// We'll collect (nodeNum, last_heard, snr) for both main DB + ephemeral
|
||||||
struct NodeCandidate {
|
struct NodeCandidate {
|
||||||
@ -891,7 +885,7 @@ std::vector<NodeNum> NodeDB::getCoveredNodes(uint32_t timeWindowSecs)
|
|||||||
|
|
||||||
uint32_t age = now - node.last_heard;
|
uint32_t age = now - node.last_heard;
|
||||||
if (age <= timeWindowSecs) {
|
if (age <= timeWindowSecs) {
|
||||||
allCandidates.push_back(NodeCandidate{node.num, node.last_heard, node.snr});
|
allCandidates.push_back(NodeCandidate{node.relay_node, node.last_heard, node.snr});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -903,9 +897,9 @@ std::vector<NodeNum> NodeDB::getCoveredNodes(uint32_t timeWindowSecs)
|
|||||||
|
|
||||||
uint32_t age = now - node.last_heard;
|
uint32_t age = now - node.last_heard;
|
||||||
if (age <= timeWindowSecs) {
|
if (age <= timeWindowSecs) {
|
||||||
allCandidates.push_back(NodeCandidate{node.num, node.last_heard, node.snr});
|
allCandidates.push_back(NodeCandidate{node.relay_node, node.last_heard, node.snr});
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG("Node 0x%x is not valid for coverage: Aged Out", node.num);
|
LOG_DEBUG("Node 0x%x is not valid for coverage: Aged Out", node.relay_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,7 +954,7 @@ void NodeDB::cleanupMeshDB()
|
|||||||
|
|
||||||
for (int i = 0; i < numMeshNodes; i++) {
|
for (int i = 0; i < numMeshNodes; i++) {
|
||||||
if (meshNodes->at(i).has_user) {
|
if (meshNodes->at(i).has_user) {
|
||||||
if (meshNodes->at(i).has_hops_away && meshNodes->at(i).hops_away == 0 && meshNodes->at(i).last_heard > maxLastHeardDirectNeighbor_) {
|
if (meshNodes->at(i).last_heard > maxLastHeardDirectNeighbor_) {
|
||||||
maxLastHeardDirectNeighbor_ = meshNodes->at(i).last_heard;
|
maxLastHeardDirectNeighbor_ = meshNodes->at(i).last_heard;
|
||||||
}
|
}
|
||||||
if (meshNodes->at(i).user.public_key.size > 0) {
|
if (meshNodes->at(i).user.public_key.size > 0) {
|
||||||
|
@ -637,8 +637,8 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p)
|
|||||||
radioBuffer.header.to = p->to;
|
radioBuffer.header.to = p->to;
|
||||||
radioBuffer.header.id = p->id;
|
radioBuffer.header.id = p->id;
|
||||||
radioBuffer.header.channel = p->channel;
|
radioBuffer.header.channel = p->channel;
|
||||||
radioBuffer.header.next_hop = 0; // *** For future use ***
|
radioBuffer.header.next_hop = 0; // *** For future use ***
|
||||||
radioBuffer.header.relay_node = 0; // *** For future use ***
|
radioBuffer.header.relay_node = nodeDB->getNodeNum(); // *** For future use ***
|
||||||
if (p->hop_limit > HOP_MAX) {
|
if (p->hop_limit > HOP_MAX) {
|
||||||
LOG_WARN("hop limit %d is too high, setting to %d", p->hop_limit, HOP_RELIABLE);
|
LOG_WARN("hop limit %d is too high, setting to %d", p->hop_limit, HOP_RELIABLE);
|
||||||
p->hop_limit = HOP_RELIABLE;
|
p->hop_limit = HOP_RELIABLE;
|
||||||
|
@ -42,7 +42,7 @@ typedef struct {
|
|||||||
uint8_t next_hop;
|
uint8_t next_hop;
|
||||||
|
|
||||||
// ***For future use*** Last byte of the NodeNum of the node that will relay/relayed this packet
|
// ***For future use*** Last byte of the NodeNum of the node that will relay/relayed this packet
|
||||||
uint8_t relay_node;
|
NodeNum 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.
|
||||||
uint8_t coverage_filter[BLOOM_FILTER_SIZE_BYTES] __attribute__((__aligned__));
|
uint8_t coverage_filter[BLOOM_FILTER_SIZE_BYTES] __attribute__((__aligned__));
|
||||||
|
@ -92,6 +92,8 @@ typedef struct _meshtastic_NodeInfoLite {
|
|||||||
bool is_ignored;
|
bool is_ignored;
|
||||||
/* Last byte of the node number of the node that should be used as the next hop to reach this node. */
|
/* Last byte of the node number of the node that should be used as the next hop to reach this node. */
|
||||||
uint8_t next_hop;
|
uint8_t next_hop;
|
||||||
|
/* Node id of the relaying node. */
|
||||||
|
uint32_t relay_node;
|
||||||
} meshtastic_NodeInfoLite;
|
} meshtastic_NodeInfoLite;
|
||||||
|
|
||||||
/* This message is never sent over the wire, but it is used for serializing DB
|
/* This message is never sent over the wire, but it is used for serializing DB
|
||||||
|
@ -690,7 +690,7 @@ typedef struct _meshtastic_MqttClientProxyMessage {
|
|||||||
|
|
||||||
typedef PB_BYTES_ARRAY_T(256) meshtastic_MeshPacket_encrypted_t;
|
typedef PB_BYTES_ARRAY_T(256) meshtastic_MeshPacket_encrypted_t;
|
||||||
typedef PB_BYTES_ARRAY_T(32) meshtastic_MeshPacket_public_key_t;
|
typedef PB_BYTES_ARRAY_T(32) meshtastic_MeshPacket_public_key_t;
|
||||||
typedef PB_BYTES_ARRAY_T(16) meshtastic_MeshPacket_coverage_filter_t;
|
typedef PB_BYTES_ARRAY_T(13) meshtastic_MeshPacket_coverage_filter_t;
|
||||||
/* A packet envelope sent/received over the mesh
|
/* A packet envelope sent/received over the mesh
|
||||||
only payload_variant is sent in the payload portion of the LORA packet.
|
only payload_variant is sent in the payload portion of the LORA packet.
|
||||||
The other fields are either not sent at all, or sent in the special 16 byte LORA header. */
|
The other fields are either not sent at all, or sent in the special 16 byte LORA header. */
|
||||||
@ -770,7 +770,7 @@ typedef struct _meshtastic_MeshPacket {
|
|||||||
uint8_t next_hop;
|
uint8_t next_hop;
|
||||||
/* Last byte of the node number of the node that will relay/relayed this packet.
|
/* Last byte of the node number of the node that will relay/relayed this packet.
|
||||||
Set by the firmware internally, clients are not supposed to set this. */
|
Set by the firmware internally, clients are not supposed to set this. */
|
||||||
uint8_t relay_node;
|
uint32_t relay_node;
|
||||||
/* *Never* sent over the radio links.
|
/* *Never* sent over the radio links.
|
||||||
Timestamp after which this packet may be sent.
|
Timestamp after which this packet may be sent.
|
||||||
Set by the firmware internally, clients are not supposed to set this. */
|
Set by the firmware internally, clients are not supposed to set this. */
|
||||||
|
Loading…
Reference in New Issue
Block a user