diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index 65cb4ce36..4ebd2f4d7 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -66,7 +66,7 @@ MeshPacket *MeshPlugin::allocErrorResponse(Routing_Error err, const MeshPacket * return r; } -void MeshPlugin::callPlugins(const MeshPacket &mp) +void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src) { // DEBUG_MSG("In call plugins\n"); bool pluginFound = false; @@ -79,6 +79,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp) // Was this message directed to us specifically? Will be false if we are sniffing someone elses packets auto ourNodeNum = nodeDB.getNodeNum(); bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum; + for (auto i = plugins->begin(); i != plugins->end(); ++i) { auto &pi = **i; @@ -87,6 +88,11 @@ void MeshPlugin::callPlugins(const MeshPacket &mp) /// We only call plugins that are interested in the packet (and the message is destined to us or we are promiscious) bool wantsPacket = (isDecoded || pi.encryptedOk) && (pi.isPromiscuous || toUs) && pi.wantPacket(&mp); + if ((src == RX_SRC_LOCAL) && !(pi.loopbackOk)) { + // new case, monitor separately for now, then FIXME merge above + wantsPacket = false; + } + assert(!pi.myReply); // If it is !null it means we have a bug, because it should have been sent the previous time if (wantsPacket) { @@ -169,7 +175,9 @@ void MeshPlugin::callPlugins(const MeshPacket &mp) } if (!pluginFound) - DEBUG_MSG("No plugins interested in portnum=%d\n", mp.decoded.portnum); + DEBUG_MSG("No plugins interested in portnum=%d, src=%s\n", + mp.decoded.portnum, + (src == RX_SRC_LOCAL) ? "LOCAL":"REMOTE"); } MeshPacket *MeshPlugin::allocReply() diff --git a/src/mesh/MeshPlugin.h b/src/mesh/MeshPlugin.h index 937c37dfe..2350c951a 100644 --- a/src/mesh/MeshPlugin.h +++ b/src/mesh/MeshPlugin.h @@ -33,7 +33,7 @@ class MeshPlugin /** For use only by MeshService */ - static void callPlugins(const MeshPacket &mp); + static void callPlugins(const MeshPacket &mp, RxSource src = RX_SRC_RADIO); static std::vector GetMeshPluginsWithUIFrames(); #ifndef NO_SCREEN @@ -48,6 +48,10 @@ class MeshPlugin */ bool isPromiscuous = false; + /** Also receive a copy of LOCALLY GENERATED messages - most plugins should leave + * this setting disabled - see issue #877 */ + bool loopbackOk = false; + /** Most plugins only understand decrypted packets. For plugins that also want to see encrypted packets, they should set this * flag */ bool encryptedOk = false;