mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-31 23:21:06 +00:00
Rename MeshPlugin, SinglePortPlugin and ProtobufPlugin
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
#include "configuration.h"
|
||||
#include "MeshPlugin.h"
|
||||
#include "MeshModule.h"
|
||||
#include "Channels.h"
|
||||
#include "MeshService.h"
|
||||
#include "NodeDB.h"
|
||||
#include "modules/RoutingModule.h"
|
||||
#include <assert.h>
|
||||
|
||||
std::vector<MeshPlugin *> *MeshPlugin::modules;
|
||||
std::vector<MeshModule *> *MeshModule::modules;
|
||||
|
||||
const MeshPacket *MeshPlugin::currentRequest;
|
||||
const MeshPacket *MeshModule::currentRequest;
|
||||
|
||||
/**
|
||||
* If any of the current chain of modules has already sent a reply, it will be here. This is useful to allow
|
||||
* the RoutingPlugin to avoid sending redundant acks
|
||||
*/
|
||||
MeshPacket *MeshPlugin::currentReply;
|
||||
MeshPacket *MeshModule::currentReply;
|
||||
|
||||
MeshPlugin::MeshPlugin(const char *_name) : name(_name)
|
||||
MeshModule::MeshModule(const char *_name) : name(_name)
|
||||
{
|
||||
// Can't trust static initalizer order, so we check each time
|
||||
if (!modules)
|
||||
modules = new std::vector<MeshPlugin *>();
|
||||
modules = new std::vector<MeshModule *>();
|
||||
|
||||
modules->push_back(this);
|
||||
}
|
||||
|
||||
void MeshPlugin::setup() {}
|
||||
void MeshModule::setup() {}
|
||||
|
||||
MeshPlugin::~MeshPlugin()
|
||||
MeshModule::~MeshModule()
|
||||
{
|
||||
assert(0); // FIXME - remove from list of modules once someone needs this feature
|
||||
}
|
||||
|
||||
MeshPacket *MeshPlugin::allocAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex)
|
||||
MeshPacket *MeshModule::allocAckNak(Routing_Error err, NodeNum to, PacketId idFrom, ChannelIndex chIndex)
|
||||
{
|
||||
Routing c = Routing_init_default;
|
||||
|
||||
@@ -57,7 +57,7 @@ MeshPacket *MeshPlugin::allocAckNak(Routing_Error err, NodeNum to, PacketId idFr
|
||||
return p;
|
||||
}
|
||||
|
||||
MeshPacket *MeshPlugin::allocErrorResponse(Routing_Error err, const MeshPacket *p)
|
||||
MeshPacket *MeshModule::allocErrorResponse(Routing_Error err, const MeshPacket *p)
|
||||
{
|
||||
auto r = allocAckNak(err, getFrom(p), p->id, p->channel);
|
||||
|
||||
@@ -66,7 +66,7 @@ MeshPacket *MeshPlugin::allocErrorResponse(Routing_Error err, const MeshPacket *
|
||||
return r;
|
||||
}
|
||||
|
||||
void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
void MeshModule::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
{
|
||||
// DEBUG_MSG("In call modules\n");
|
||||
bool moduleFound = false;
|
||||
@@ -183,7 +183,7 @@ void MeshPlugin::callPlugins(const MeshPacket &mp, RxSource src)
|
||||
(src == RX_SRC_LOCAL) ? "LOCAL":"REMOTE");
|
||||
}
|
||||
|
||||
MeshPacket *MeshPlugin::allocReply()
|
||||
MeshPacket *MeshModule::allocReply()
|
||||
{
|
||||
auto r = myReply;
|
||||
myReply = NULL; // Only use each reply once
|
||||
@@ -194,7 +194,7 @@ MeshPacket *MeshPlugin::allocReply()
|
||||
* so that subclasses can (optionally) send a response back to the original sender. Implementing this method
|
||||
* is optional
|
||||
*/
|
||||
void MeshPlugin::sendResponse(const MeshPacket &req)
|
||||
void MeshModule::sendResponse(const MeshPacket &req)
|
||||
{
|
||||
auto r = allocReply();
|
||||
if (r) {
|
||||
@@ -222,10 +222,10 @@ void setReplyTo(MeshPacket *p, const MeshPacket &to)
|
||||
p->decoded.request_id = to.id;
|
||||
}
|
||||
|
||||
std::vector<MeshPlugin *> MeshPlugin::GetMeshModulesWithUIFrames()
|
||||
std::vector<MeshModule *> MeshModule::GetMeshModulesWithUIFrames()
|
||||
{
|
||||
|
||||
std::vector<MeshPlugin *> modulesWithUIFrames;
|
||||
std::vector<MeshModule *> modulesWithUIFrames;
|
||||
if (modules) {
|
||||
for (auto i = modules->begin(); i != modules->end(); ++i) {
|
||||
auto &pi = **i;
|
||||
@@ -238,7 +238,7 @@ std::vector<MeshPlugin *> MeshPlugin::GetMeshModulesWithUIFrames()
|
||||
return modulesWithUIFrames;
|
||||
}
|
||||
|
||||
void MeshPlugin::observeUIEvents(
|
||||
void MeshModule::observeUIEvents(
|
||||
Observer<const UIFrameEvent *> *observer)
|
||||
{
|
||||
if (modules) {
|
||||
@@ -254,7 +254,7 @@ void MeshPlugin::observeUIEvents(
|
||||
}
|
||||
}
|
||||
|
||||
AdminMessageHandleResult MeshPlugin::handleAdminMessageForAllPlugins(const MeshPacket &mp, AdminMessage *request, AdminMessage *response)
|
||||
AdminMessageHandleResult MeshModule::handleAdminMessageForAllPlugins(const MeshPacket &mp, AdminMessage *request, AdminMessage *response)
|
||||
{
|
||||
AdminMessageHandleResult handled = AdminMessageHandleResult::NOT_HANDLED;
|
||||
if (modules) {
|
||||
@@ -52,23 +52,23 @@ typedef struct _UIFrameEvent {
|
||||
* Interally we use modules to implement the core meshtastic text messaging and gps position sharing features. You
|
||||
* can use these classes as examples for how to write your own custom module. See here: (FIXME)
|
||||
*/
|
||||
class MeshPlugin
|
||||
class MeshModule
|
||||
{
|
||||
static std::vector<MeshPlugin *> *modules;
|
||||
static std::vector<MeshModule *> *modules;
|
||||
|
||||
public:
|
||||
/** Constructor
|
||||
* name is for debugging output
|
||||
*/
|
||||
MeshPlugin(const char *_name);
|
||||
MeshModule(const char *_name);
|
||||
|
||||
virtual ~MeshPlugin();
|
||||
virtual ~MeshModule();
|
||||
|
||||
/** For use only by MeshService
|
||||
*/
|
||||
static void callPlugins(const MeshPacket &mp, RxSource src = RX_SRC_RADIO);
|
||||
|
||||
static std::vector<MeshPlugin *> GetMeshModulesWithUIFrames();
|
||||
static std::vector<MeshModule *> GetMeshModulesWithUIFrames();
|
||||
static void observeUIEvents(Observer<const UIFrameEvent *> *observer);
|
||||
static AdminMessageHandleResult handleAdminMessageForAllPlugins(
|
||||
const MeshPacket &mp, AdminMessage *request, AdminMessage *response);
|
||||
@@ -438,7 +438,7 @@ size_t NodeDB::getNumOnlineNodes()
|
||||
return numseen;
|
||||
}
|
||||
|
||||
#include "MeshPlugin.h"
|
||||
#include "MeshModule.h"
|
||||
|
||||
/** Update position info for this node based on received position data
|
||||
*/
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "configuration.h"
|
||||
#include "ProtobufPlugin.h"
|
||||
#include "ProtobufModule.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include "SinglePortPlugin.h"
|
||||
#include "SinglePortModule.h"
|
||||
|
||||
/**
|
||||
* A base class for mesh modules that assume that they are sending/receiving one particular protobuf based
|
||||
@@ -8,7 +8,7 @@
|
||||
* If you are using protobufs to encode your packets (recommended) you can use this as a baseclass for your module
|
||||
* and avoid a bunch of boilerplate code.
|
||||
*/
|
||||
template <class T> class ProtobufPlugin : protected SinglePortPlugin
|
||||
template <class T> class ProtobufModule : protected SinglePortModule
|
||||
{
|
||||
const pb_msgdesc_t *fields;
|
||||
|
||||
@@ -16,8 +16,8 @@ template <class T> class ProtobufPlugin : protected SinglePortPlugin
|
||||
/** Constructor
|
||||
* name is for debugging output
|
||||
*/
|
||||
ProtobufPlugin(const char *_name, PortNum _ourPortNum, const pb_msgdesc_t *_fields)
|
||||
: SinglePortPlugin(_name, _ourPortNum), fields(_fields)
|
||||
ProtobufModule(const char *_name, PortNum _ourPortNum, const pb_msgdesc_t *_fields)
|
||||
: SinglePortModule(_name, _ourPortNum), fields(_fields)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "configuration.h"
|
||||
#include "ReliableRouter.h"
|
||||
#include "MeshPlugin.h"
|
||||
#include "MeshModule.h"
|
||||
#include "MeshTypes.h"
|
||||
#include "mesh-pb-constants.h"
|
||||
|
||||
@@ -92,7 +92,7 @@ void ReliableRouter::sniffReceived(const MeshPacket *p, const Routing *c)
|
||||
if (p->to == ourNode) { // ignore ack/nak/want_ack packets that are not address to us (we only handle 0 hop reliability
|
||||
// - not DSR routing)
|
||||
if (p->want_ack) {
|
||||
if (MeshPlugin::currentReply)
|
||||
if (MeshModule::currentReply)
|
||||
DEBUG_MSG("Someone else has replied to this message, no need for a 2nd ack\n");
|
||||
else
|
||||
sendAckNak(Routing_Error_NONE, getFrom(p), p->id, p->channel);
|
||||
|
||||
@@ -377,7 +377,7 @@ void Router::handleReceived(MeshPacket *p, RxSource src)
|
||||
}
|
||||
|
||||
// call modules here
|
||||
MeshPlugin::callPlugins(*p, src);
|
||||
MeshModule::callPlugins(*p, src);
|
||||
}
|
||||
|
||||
void Router::perhapsHandleReceived(MeshPacket *p)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#pragma once
|
||||
#include "MeshPlugin.h"
|
||||
#include "MeshModule.h"
|
||||
#include "Router.h"
|
||||
|
||||
/**
|
||||
* Most modules are only interested in sending/receving one particular portnum. This baseclass simplifies that common
|
||||
* case.
|
||||
*/
|
||||
class SinglePortPlugin : public MeshPlugin
|
||||
class SinglePortModule : public MeshModule
|
||||
{
|
||||
protected:
|
||||
PortNum ourPortNum;
|
||||
@@ -15,7 +15,7 @@ class SinglePortPlugin : public MeshPlugin
|
||||
/** Constructor
|
||||
* name is for debugging output
|
||||
*/
|
||||
SinglePortPlugin(const char *_name, PortNum _ourPortNum) : MeshPlugin(_name), ourPortNum(_ourPortNum) {}
|
||||
SinglePortModule(const char *_name, PortNum _ourPortNum) : MeshModule(_name), ourPortNum(_ourPortNum) {}
|
||||
|
||||
protected:
|
||||
/**
|
||||
Reference in New Issue
Block a user