add SinglePortPlugin to simpilify api

This commit is contained in:
Kevin Hester
2020-12-05 10:14:15 +08:00
parent ae7d3ee5ed
commit b6e21bcbcd
4 changed files with 31 additions and 16 deletions

View File

@@ -1,23 +1,19 @@
#pragma once
#include "MeshPlugin.h"
#include "SinglePortPlugin.h"
#include "Observer.h"
/**
* Text message handling for meshtastic - draws on the OLED display the most recent received message
*/
class TextMessagePlugin : public MeshPlugin, public Observable<const MeshPacket *>
class TextMessagePlugin : public SinglePortPlugin, public Observable<const MeshPacket *>
{
public:
/** Constructor
* name is for debugging output
*/
TextMessagePlugin() : MeshPlugin("text") {}
TextMessagePlugin() : SinglePortPlugin("text", PortNum_TEXT_MESSAGE_APP) {}
protected:
/**
* @return true if you want to receive the specified portnum
*/
virtual bool wantPortnum(PortNum p) { return p == PortNum_TEXT_MESSAGE_APP; }
/** Called to handle a particular incoming message