2020-11-28 04:10:19 +00:00
|
|
|
#include "MeshPlugin.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
2020-11-28 05:25:03 +00:00
|
|
|
std::vector<MeshPlugin *> *MeshPlugin::plugins;
|
2020-11-28 04:10:19 +00:00
|
|
|
|
2020-11-28 05:25:03 +00:00
|
|
|
MeshPlugin::MeshPlugin(const char *_name) : name(_name)
|
|
|
|
{
|
|
|
|
// Can't trust static initalizer order, so we check each time
|
|
|
|
if(!plugins)
|
|
|
|
plugins = new std::vector<MeshPlugin *>();
|
|
|
|
|
|
|
|
plugins->push_back(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MeshPlugin::setup() {
|
2020-11-28 04:10:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MeshPlugin::~MeshPlugin()
|
|
|
|
{
|
|
|
|
assert(0); // FIXME - remove from list of plugins once someone needs this feature
|
|
|
|
}
|
|
|
|
|
|
|
|
void MeshPlugin::callPlugins(const MeshPacket &mp)
|
|
|
|
{
|
2020-11-28 05:25:03 +00:00
|
|
|
DEBUG_MSG("In call plugins\n");
|
|
|
|
for (auto i = plugins->begin(); i != plugins->end(); ++i) {
|
|
|
|
auto &pi = **i;
|
|
|
|
if (pi.wantPortnum(mp.decoded.data.portnum)) {
|
|
|
|
bool handled = pi.handleReceived(mp);
|
|
|
|
DEBUG_MSG("Plugin %s handled=%d\n", pi.name, handled);
|
|
|
|
if (handled)
|
2020-11-28 04:10:19 +00:00
|
|
|
break;
|
2020-11-28 05:25:03 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
DEBUG_MSG("Plugin %s not interested\n", pi.name);
|
|
|
|
}
|
2020-11-28 04:10:19 +00:00
|
|
|
}
|
|
|
|
}
|