kopia lustrzana https://github.com/meshtastic/firmware
add SinglePortPlugin to simpilify api
rodzic
ae7d3ee5ed
commit
b6e21bcbcd
|
@ -13,7 +13,7 @@ For app cleanup:
|
||||||
* on python side print error messages if old position/user messages seen
|
* on python side print error messages if old position/user messages seen
|
||||||
* on python side handle new position/user messages
|
* on python side handle new position/user messages
|
||||||
* DONE fix position sending to use new plugin
|
* DONE fix position sending to use new plugin
|
||||||
* Add SinglePortNumPlugin - as the new most useful baseclass
|
* DONE Add SinglePortNumPlugin - as the new most useful baseclass
|
||||||
* DONE move positions into regular data packets (use new app framework)
|
* DONE move positions into regular data packets (use new app framework)
|
||||||
* DONE move user info into regular data packets (use new app framework)
|
* DONE move user info into regular data packets (use new app framework)
|
||||||
* test that positions, text messages and user info still work
|
* test that positions, text messages and user info still work
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "MeshPlugin.h"
|
#include "SinglePortPlugin.h"
|
||||||
#include "Router.h"
|
#include "Router.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,25 +9,20 @@
|
||||||
* If you are using protobufs to encode your packets (recommended) you can use this as a baseclass for your plugin
|
* If you are using protobufs to encode your packets (recommended) you can use this as a baseclass for your plugin
|
||||||
* and avoid a bunch of boilerplate code.
|
* and avoid a bunch of boilerplate code.
|
||||||
*/
|
*/
|
||||||
template <class T> class ProtobufPlugin : private MeshPlugin
|
template <class T> class ProtobufPlugin : private SinglePortPlugin
|
||||||
{
|
{
|
||||||
const pb_msgdesc_t *fields;
|
const pb_msgdesc_t *fields;
|
||||||
PortNum ourPortNum;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* name is for debugging output
|
* name is for debugging output
|
||||||
*/
|
*/
|
||||||
ProtobufPlugin(const char *_name, PortNum _ourPortNum, const pb_msgdesc_t *_fields)
|
ProtobufPlugin(const char *_name, PortNum _ourPortNum, const pb_msgdesc_t *_fields)
|
||||||
: MeshPlugin(_name), fields(_fields), ourPortNum(_ourPortNum)
|
: SinglePortPlugin(_name, _ourPortNum), fields(_fields)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
|
||||||
* @return true if you want to receive the specified portnum
|
|
||||||
*/
|
|
||||||
virtual bool wantPortnum(PortNum p) { return p == ourPortNum; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a received message, the data field in the message is already decoded and is provided
|
* Handle a received message, the data field in the message is already decoded and is provided
|
||||||
|
|
|
@ -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; }
|
||||||
|
};
|
|
@ -1,23 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "MeshPlugin.h"
|
#include "SinglePortPlugin.h"
|
||||||
#include "Observer.h"
|
#include "Observer.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text message handling for meshtastic - draws on the OLED display the most recent received message
|
* 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:
|
public:
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* name is for debugging output
|
* name is for debugging output
|
||||||
*/
|
*/
|
||||||
TextMessagePlugin() : MeshPlugin("text") {}
|
TextMessagePlugin() : SinglePortPlugin("text", PortNum_TEXT_MESSAGE_APP) {}
|
||||||
|
|
||||||
protected:
|
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
|
/** Called to handle a particular incoming message
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue