diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 980964043..d1b786a44 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -19,6 +19,7 @@ #include "power.h" #include #include +#include "modules/FishEyeStateRoutingModule.h" #if ARCH_PORTDUINO #include "PortduinoGlue.h" @@ -232,6 +233,10 @@ ErrorCode MeshService::sendQueueStatusToPhone(const meshtastic_QueueStatus &qs, void MeshService::sendToMesh(meshtastic_MeshPacket *p, RxSource src, bool ccToPhone) { + if(config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.fish_eye_state_routing.enabled && p->decoded.dest != 0 && p->decoded.dest != NODENUM_BROADCAST){ + p->to = fishEyeStateRoutingModule->getNextHopForID(p->decoded.dest); + } + uint32_t mesh_packet_id = p->id; nodeDB->updateFrom(*p); // update our local DB for this packet (because phone might have sent position packets etc...) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 992f38ff4..c2f5e59d9 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -11,6 +11,7 @@ #include "mesh-pb-constants.h" #include "meshUtils.h" #include "modules/RoutingModule.h" +#include "modules/FishEyeStateRoutingModule.h" #if !MESHTASTIC_EXCLUDE_MQTT #include "mqtt/MQTT.h" #endif @@ -652,6 +653,14 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) if (!skipHandle) { MeshModule::callModules(*p, src); + if(config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState && moduleConfig.fish_eye_state_routing.enabled == true && ((isToUs(p) || isBroadcast(p->to)) && p->decoded.dest != 0 && !isBroadcast(p->decoded.dest))){ + meshtastic_MeshPacket *copy = allocForSending(); + copy = p; + copy->to = fishEyeStateRoutingModule->getNextHopForID(copy->decoded.dest); + copy->from = nodeDB->getNodeNum(); + service->sendToMesh(copy); + } + #if !MESHTASTIC_EXCLUDE_MQTT // Mark as pki_encrypted if it is not yet decoded and MQTT encryption is also enabled, hash matches and it's a DM not to // us (because we would be able to decrypt it) @@ -665,6 +674,8 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) #endif } + + packetPool.release(p_encrypted); // Release the encrypted packet } diff --git a/src/modules/FishEyeStateRoutingModule.cpp b/src/modules/FishEyeStateRoutingModule.cpp index 03eb7ae98..f2b115ded 100644 --- a/src/modules/FishEyeStateRoutingModule.cpp +++ b/src/modules/FishEyeStateRoutingModule.cpp @@ -104,6 +104,7 @@ bool FishEyeStateRoutingModule::isequal(const meshtastic_FishEyeStateRouting &s1 * returns next-Hop for a Message to a given NodeID, if Node is unknwon BroadcastID is returned */ uint32_t FishEyeStateRoutingModule::getNextHopForID(uint32_t dest){ + if (dest == nodeDB->getNodeNum()){return dest;} auto it = NextHopTable.find(dest); if(it == NextHopTable.end()){ return NODENUM_BROADCAST;