Plumbing for the GroupPlugin

This commit is contained in:
Jm Casler
2022-02-19 23:43:32 -08:00
parent 701668804a
commit e34190b497
7 changed files with 103 additions and 14 deletions

View File

@@ -0,0 +1,37 @@
#include "GroupPlugin.h"
#include "MeshService.h"
#include "Router.h"
#include "configuration.h"
GroupPlugin *groupPlugin;
GroupPlugin::GroupPlugin()
: ProtobufPlugin("group", PortNum_GROUP_APP, GroupInfo_fields), concurrency::OSThread("GroupPlugin")
{
//isPromiscuous = true; // We always want to update our nodedb, even if we are sniffing on others
//setIntervalFromNow(60 * 1000); // Send our initial position 60 seconds after we start (to give GPS time to setup)
}
bool GroupPlugin::handleReceivedProtobuf(const MeshPacket &mp, GroupInfo *pptr)
{
auto p = *pptr;
return false; // Let others look at this message also if they want
}
MeshPacket *GroupPlugin::allocReply()
{
return allocDataProtobuf(p);
}
int32_t GroupPlugin::runOnce()
{
NodeInfo *node = nodeDB.getNode(nodeDB.getNodeNum());
return 5000; // to save power only wake for our callback occasionally
}

29
src/plugins/GroupPlugin.h Normal file
View File

@@ -0,0 +1,29 @@
#pragma once
#include "GroupPlugin.h"
#include "ProtobufPlugin.h"
#include "concurrency/OSThread.h"
/**
* Position plugin for sending/receiving positions into the mesh
*/
class GroupPlugin : private concurrency::OSThread, public ProtobufPlugin<GroupInfo>
{
public:
GroupPlugin();
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 MeshPacket &mp, GroupInfo *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 MeshPacket *allocReply() override;
/** Does our periodic broadcast */
virtual int32_t runOnce() override;
};
extern GroupPlugin *groupPlugin;

View File

@@ -1,22 +1,22 @@
#include "configuration.h"
#include "input/InputBroker.h"
#include "input/RotaryEncoderInterruptImpl1.h"
#include "plugins/AdminPlugin.h"
#include "plugins/CannedMessagePlugin.h"
#include "plugins/ExternalNotificationPlugin.h"
#include "plugins/GroupPlugin.h"
#include "plugins/NodeInfoPlugin.h"
#include "plugins/PositionPlugin.h"
#include "plugins/RemoteHardwarePlugin.h"
#include "plugins/ReplyPlugin.h"
#include "plugins/TextMessagePlugin.h"
#include "plugins/TextMessagePlugin.h"
#include "plugins/RoutingPlugin.h"
#include "plugins/AdminPlugin.h"
#include "plugins/CannedMessagePlugin.h"
#include "plugins/TextMessagePlugin.h"
#ifndef PORTDUINO
#include "plugins/EnvironmentalMeasurement/EnvironmentalMeasurementPlugin.h"
#endif
#ifndef NO_ESP32
#include "plugins/esp32/SerialPlugin.h"
#include "plugins/esp32/RangeTestPlugin.h"
#include "plugins/esp32/SerialPlugin.h"
#include "plugins/esp32/StoreForwardPlugin.h"
#endif
@@ -30,14 +30,14 @@ void setupPlugins()
nodeInfoPlugin = new NodeInfoPlugin();
positionPlugin = new PositionPlugin();
textMessagePlugin = new TextMessagePlugin();
groupPlugin = new GroupPlugin();
// Note: if the rest of meshtastic doesn't need to explicitly use your plugin, you do not need to assign the instance
// to a global variable.
new RemoteHardwarePlugin();
new ReplyPlugin();
rotaryEncoderInterruptImpl1 =
new RotaryEncoderInterruptImpl1();
rotaryEncoderInterruptImpl1 = new RotaryEncoderInterruptImpl1();
rotaryEncoderInterruptImpl1->init();
cannedMessagePlugin = new CannedMessagePlugin();
#ifndef PORTDUINO