Skip to content

Commit 5771c0c

Browse files
committed
Trying to make the module work without protobuf changes
1 parent 1ca852f commit 5771c0c

File tree

4 files changed

+34
-34
lines changed

4 files changed

+34
-34
lines changed

src/mesh/NodeDB.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,8 +543,6 @@ void NodeDB::installDefaultConfig(bool preserveKey = false)
543543
config.has_network = true;
544544
config.has_bluetooth = (HAS_BLUETOOTH ? true : false);
545545
config.has_security = true;
546-
config.has_routing = true;
547-
config.routing.signal_based_routing = true;
548546
config.device.rebroadcast_mode = meshtastic_Config_DeviceConfig_RebroadcastMode_ALL;
549547

550548
config.lora.sx126x_rx_boosted_gain = true;

src/mesh/SignalRoutingModule.cpp

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ SignalRoutingModule::SignalRoutingModule() : MeshModule("SignalRouting")
2525
}
2626

2727
bool SignalRoutingModule::shouldUseSignalBasedRouting(const meshtastic_MeshPacket *p) {
28-
if (!config.routing.signal_based_routing || !routingGraph) {
28+
// Signal-based routing enabled by default in this fork
29+
// TODO: Use config.routing.signal_based_routing after protobuf regeneration
30+
if (!signalBasedRoutingEnabled || !routingGraph) {
2931
return false;
3032
}
3133

@@ -105,41 +107,38 @@ void SignalRoutingModule::onNodeInfoChanged() {
105107
}
106108

107109
bool SignalRoutingModule::isSignalBasedCapable(NodeNum nodeId) {
110+
// TODO: Check node->signal_based_capable after protobuf regeneration
111+
// For now, assume all nodes we've heard from recently are capable
112+
// (this is a temporary heuristic until we can exchange capability info)
108113
const meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(nodeId);
109-
return node && node->signal_based_capable;
114+
if (!node) return false;
115+
116+
// Consider a node capable if we've heard from it in the last 5 minutes
117+
uint32_t now = getValidTime(RTCQualityFromNet);
118+
return (now - node->last_heard) < 300;
110119
}
111120

112121
float SignalRoutingModule::getSignalBasedCapablePercentage() {
113-
int totalNodes = 0;
114-
int capableNodes = 0;
115-
116-
for (int i = 0; i < nodeDB->getNumMeshNodes(); i++) {
117-
const meshtastic_NodeInfoLite *node = nodeDB->getMeshNodeByIndex(i);
118-
if (node) {
119-
totalNodes++;
120-
if (node->signal_based_capable) {
121-
capableNodes++;
122-
}
123-
}
124-
}
125-
126-
if (totalNodes == 0) return 0.0f;
127-
return (static_cast<float>(capableNodes) / totalNodes) * 100.0f;
122+
// int totalNodes = 0;
123+
// int capableNodes = 0;
124+
125+
// for (int i = 0; i < nodeDB->getNumMeshNodes(); i++) {
126+
// const meshtastic_NodeInfoLite *node = nodeDB->getMeshNodeByIndex(i);
127+
// if (node) {
128+
// totalNodes++;
129+
// if (node->signal_based_capable) {
130+
// capableNodes++;
131+
// }
132+
// }
133+
// }
134+
135+
// if (totalNodes == 0) return 0.0f;
136+
// return (static_cast<float>(capableNodes) / totalNodes) * 100.0f;
137+
return 100.0f;
128138
}
129139

130140
void SignalRoutingModule::updateSignalBasedCapable() {
131-
// Update our own node info to indicate signal-based capability
132-
meshtastic_NodeInfo *ourNodeInfo = nodeDB->getMutableNodeInfo();
133-
if (ourNodeInfo) {
134-
ourNodeInfo->signal_based_capable = true;
135-
136-
// Update neighbors list (max 6 as per requirements)
137-
ourNodeInfo->neighbors_count = std::min(static_cast<size_t>(6), neighbors.size());
138-
for (size_t i = 0; i < ourNodeInfo->neighbors_count; i++) {
139-
ourNodeInfo->neighbors[i] = neighbors[i];
140-
}
141-
142-
LOG_DEBUG("SignalRouting: Updated NodeInfo - signal_based_capable=true, neighbors=%d",
143-
ourNodeInfo->neighbors_count);
144-
}
141+
// TODO: Set ourNodeInfo->signal_based_capable = true after protobuf regeneration
142+
// For now, this is a no-op since the field doesn't exist yet
143+
LOG_DEBUG("SignalRouting: Module initialized (signal_based_capable will be set after protobuf update)");
145144
}

src/mesh/SignalRoutingModule.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@ class SignalRoutingModule : public MeshModule
3838

3939
private:
4040
Graph *routingGraph;
41-
std::vector<meshtastic_NeighborLink> neighbors;
4241
uint32_t lastGraphUpdate = 0;
4342
static constexpr uint32_t GRAPH_UPDATE_INTERVAL_MS = 300 * 1000; // 300 seconds
4443

44+
// Signal-based routing enabled by default (until protobuf config is available)
45+
bool signalBasedRoutingEnabled = true;
46+
4547
/**
4648
* Check if a node is signal-based routing capable
4749
*/

src/modules/Modules.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#endif
5353
#include "modules/RoutingModule.h"
5454
#include "modules/TextMessageModule.h"
55+
#include "mesh/SignalRoutingModule.h"
5556
#if !MESHTASTIC_EXCLUDE_TRACEROUTE
5657
#include "modules/TraceRouteModule.h"
5758
#endif

0 commit comments

Comments
 (0)