Yank repeater module and just guard clause the alloc

This commit is contained in:
Ben Meadors 2023-01-28 09:11:12 -06:00
parent e229a67d25
commit 103f1992dd
5 changed files with 3 additions and 68 deletions

View File

@ -84,7 +84,6 @@ class Router : protected concurrency::OSThread
protected: protected:
friend class RoutingModule; friend class RoutingModule;
friend class RepeaterModule;
/** /**
* Should this incoming filter be dropped? * Should this incoming filter be dropped?

View File

@ -82,9 +82,8 @@ void setupModules()
// NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra // NOTE! This module must be added LAST because it likes to check for replies from other modules and avoid sending extra
// acks // acks
routingModule = new RoutingModule();
} else { } else {
adminModule = new AdminModule(); adminModule = new AdminModule();
repeaterModule = new RepeaterModule();
} }
routingModule = new RoutingModule();
} }

View File

@ -1,32 +0,0 @@
#include "RepeaterModule.h"
#include "MeshService.h"
#include "NodeDB.h"
#include "Router.h"
#include "configuration.h"
#include "main.h"
RepeaterModule *repeaterModule;
bool RepeaterModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Routing *r)
{
printPacket("Repeater observed message", &mp);
router->sniffReceived(&mp, r);
if ((mp.to == NODENUM_BROADCAST || mp.to == nodeDB.getNodeNum()) && (mp.from != 0)) {
printPacket("Delivering rx packet", &mp);
service.handleFromRadio(&mp);
}
return false;
}
meshtastic_MeshPacket *RepeaterModule::allocReply()
{
return NULL;
}
RepeaterModule::RepeaterModule() : ProtobufModule("repeater", meshtastic_PortNum_ROUTING_APP, &meshtastic_Routing_msg)
{
isPromiscuous = true;
encryptedOk = true;
}

View File

@ -1,33 +0,0 @@
#pragma once
#include "Channels.h"
#include "ProtobufModule.h"
/**
* Routing module for router control messages
*/
class RepeaterModule : public ProtobufModule<meshtastic_Routing>
{
public:
/** Constructor
* name is for debugging output
*/
RepeaterModule();
protected:
friend class Router;
/** Called to handle a particular incoming message
@return true if you've guaranteed you've handled this message and no other handlers should be considered for it
*/
virtual bool handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_Routing *p) override;
/** Messages can be received that have the want_response bit set. If set, this callback will be invoked
* so that subclasses can (optionally) send a response back to the original sender. */
virtual meshtastic_MeshPacket *allocReply() override;
/// Override wantPacket to say we want to see all packets, not just those for our port number
virtual bool wantPacket(const meshtastic_MeshPacket *p) override { return true; }
};
extern RepeaterModule *repeaterModule;

View File

@ -24,6 +24,8 @@ bool RoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mesh
meshtastic_MeshPacket *RoutingModule::allocReply() meshtastic_MeshPacket *RoutingModule::allocReply()
{ {
if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER)
return NULL;
assert(currentRequest); assert(currentRequest);
// We only consider making replies if the request was a legit routing packet (not just something we were sniffing) // We only consider making replies if the request was a legit routing packet (not just something we were sniffing)