mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-17 18:42:10 +00:00
issue 879 - add opt-in flag for plugins
This commit is contained in:
parent
4669e4713c
commit
1e455ac4c3
@ -66,7 +66,7 @@ MeshPacket *MeshPlugin::allocErrorResponse(Routing_Error err, const MeshPacket *
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MeshPlugin::callPlugins(const MeshPacket &mp)
|
void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
||||||
{
|
{
|
||||||
// DEBUG_MSG("In call plugins\n");
|
// DEBUG_MSG("In call plugins\n");
|
||||||
bool pluginFound = false;
|
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
|
// Was this message directed to us specifically? Will be false if we are sniffing someone elses packets
|
||||||
auto ourNodeNum = nodeDB.getNodeNum();
|
auto ourNodeNum = nodeDB.getNodeNum();
|
||||||
bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum;
|
bool toUs = mp.to == NODENUM_BROADCAST || mp.to == ourNodeNum;
|
||||||
|
|
||||||
for (auto i = plugins->begin(); i != plugins->end(); ++i) {
|
for (auto i = plugins->begin(); i != plugins->end(); ++i) {
|
||||||
auto &pi = **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)
|
/// 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);
|
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
|
assert(!pi.myReply); // If it is !null it means we have a bug, because it should have been sent the previous time
|
||||||
|
|
||||||
if (wantsPacket) {
|
if (wantsPacket) {
|
||||||
@ -169,7 +175,9 @@ void MeshPlugin::callPlugins(const MeshPacket &mp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!pluginFound)
|
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()
|
MeshPacket *MeshPlugin::allocReply()
|
||||||
|
@ -33,7 +33,7 @@ class MeshPlugin
|
|||||||
|
|
||||||
/** For use only by MeshService
|
/** 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<MeshPlugin *> GetMeshPluginsWithUIFrames();
|
static std::vector<MeshPlugin *> GetMeshPluginsWithUIFrames();
|
||||||
#ifndef NO_SCREEN
|
#ifndef NO_SCREEN
|
||||||
@ -48,6 +48,10 @@ class MeshPlugin
|
|||||||
*/
|
*/
|
||||||
bool isPromiscuous = false;
|
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
|
/** Most plugins only understand decrypted packets. For plugins that also want to see encrypted packets, they should set this
|
||||||
* flag */
|
* flag */
|
||||||
bool encryptedOk = false;
|
bool encryptedOk = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user