mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-22 10:42:49 +00:00
add SinglePortPlugin to simpilify api
This commit is contained in:
24
src/mesh/SinglePortPlugin.h
Normal file
24
src/mesh/SinglePortPlugin.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "MeshPlugin.h"
|
||||
|
||||
/**
|
||||
* Most plugins are only interested in sending/receving one particular portnum. This baseclass simplifies that common
|
||||
* case.
|
||||
*/
|
||||
class SinglePortPlugin : public MeshPlugin
|
||||
{
|
||||
protected:
|
||||
PortNum ourPortNum;
|
||||
|
||||
public:
|
||||
/** Constructor
|
||||
* name is for debugging output
|
||||
*/
|
||||
SinglePortPlugin(const char *_name, PortNum _ourPortNum) : MeshPlugin(_name), ourPortNum(_ourPortNum) {}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @return true if you want to receive the specified portnum
|
||||
*/
|
||||
virtual bool wantPortnum(PortNum p) { return p == ourPortNum; }
|
||||
};
|
||||
Reference in New Issue
Block a user