mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-20 17:52:35 +00:00
make plugin reply handling simpler
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
|
||||
std::vector<MeshPlugin *> *MeshPlugin::plugins;
|
||||
|
||||
const MeshPacket *MeshPlugin::currentRequest;
|
||||
|
||||
MeshPlugin::MeshPlugin(const char *_name) : name(_name)
|
||||
{
|
||||
// Can't trust static initalizer order, so we check each time
|
||||
@@ -27,11 +29,13 @@ void MeshPlugin::callPlugins(const MeshPacket &mp)
|
||||
// DEBUG_MSG("In call plugins\n");
|
||||
for (auto i = plugins->begin(); i != plugins->end(); ++i) {
|
||||
auto &pi = **i;
|
||||
|
||||
pi.currentRequest = ∓
|
||||
if (pi.wantPortnum(mp.decoded.data.portnum)) {
|
||||
bool handled = pi.handleReceived(mp);
|
||||
|
||||
// Possibly send replies (unless we are handling a locally generated message)
|
||||
if (mp.decoded.want_response && mp.from != nodeDB.getNodeNum())
|
||||
// Possibly send replies
|
||||
if (mp.decoded.want_response)
|
||||
pi.sendResponse(mp);
|
||||
|
||||
DEBUG_MSG("Plugin %s handled=%d\n", pi.name, handled);
|
||||
@@ -41,6 +45,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp)
|
||||
else {
|
||||
DEBUG_MSG("Plugin %s not interested\n", pi.name);
|
||||
}
|
||||
pi.currentRequest = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user