mirror of
https://github.com/meshtastic/firmware.git
synced 2026-01-06 09:57:52 +00:00
Start of repeater role with in firmware
This commit is contained in:
27
src/modules/RepeaterModule.cpp
Normal file
27
src/modules/RepeaterModule.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#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 rebroadcasting", &mp);
|
||||
meshtastic_MeshPacket *p = const_cast<meshtastic_MeshPacket *>(&mp);
|
||||
router->send(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
meshtastic_MeshPacket *RepeaterModule::allocReply()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RepeaterModule::RepeaterModule() : ProtobufModule("repeater", meshtastic_PortNum_ROUTING_APP, &meshtastic_Routing_msg)
|
||||
{
|
||||
isPromiscuous = true;
|
||||
encryptedOk = true;
|
||||
}
|
||||
31
src/modules/RepeaterModule.h
Normal file
31
src/modules/RepeaterModule.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#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:
|
||||
/** 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;
|
||||
Reference in New Issue
Block a user