mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-23 11:10:52 +00:00
add assertIsSetup() and use it from OSThread constructor
fixes nasty bug @mc-hamster discovered with plugin order of operations
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
#include "configuration.h"
|
||||
#include "main.h"
|
||||
|
||||
NodeInfoPlugin nodeInfoPlugin;
|
||||
NodeInfoPlugin *nodeInfoPlugin;
|
||||
|
||||
bool NodeInfoPlugin::handleReceivedProtobuf(const MeshPacket &mp, const User &p)
|
||||
{
|
||||
|
||||
@@ -29,4 +29,4 @@ class NodeInfoPlugin : public ProtobufPlugin<User>
|
||||
virtual MeshPacket *allocReply();
|
||||
};
|
||||
|
||||
extern NodeInfoPlugin nodeInfoPlugin;
|
||||
extern NodeInfoPlugin *nodeInfoPlugin;
|
||||
20
src/plugins/Plugins.cpp
Normal file
20
src/plugins/Plugins.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "plugins/NodeInfoPlugin.h"
|
||||
#include "plugins/PositionPlugin.h"
|
||||
#include "plugins/ReplyPlugin.h"
|
||||
#include "plugins/RemoteHardwarePlugin.h"
|
||||
#include "plugins/TextMessagePlugin.h"
|
||||
|
||||
/**
|
||||
* Create plugin instances here. If you are adding a new plugin, you must 'new' it here (or somewhere else)
|
||||
*/
|
||||
void setupPlugins() {
|
||||
nodeInfoPlugin = new NodeInfoPlugin();
|
||||
positionPlugin = new PositionPlugin();
|
||||
textMessagePlugin = new TextMessagePlugin();
|
||||
|
||||
// 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();
|
||||
}
|
||||
6
src/plugins/Plugins.h
Normal file
6
src/plugins/Plugins.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Create plugin instances here. If you are adding a new plugin, you must 'new' it here (or somewhere else)
|
||||
*/
|
||||
void setupPlugins();
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "Router.h"
|
||||
#include "configuration.h"
|
||||
|
||||
PositionPlugin positionPlugin;
|
||||
PositionPlugin *positionPlugin;
|
||||
|
||||
bool PositionPlugin::handleReceivedProtobuf(const MeshPacket &mp, const Position &p)
|
||||
{
|
||||
|
||||
@@ -30,4 +30,4 @@ class PositionPlugin : public ProtobufPlugin<Position>
|
||||
virtual MeshPacket *allocReply();
|
||||
};
|
||||
|
||||
extern PositionPlugin positionPlugin;
|
||||
extern PositionPlugin *positionPlugin;
|
||||
@@ -6,8 +6,6 @@
|
||||
#include "configuration.h"
|
||||
#include "main.h"
|
||||
|
||||
RemoteHardwarePlugin remoteHardwarePlugin;
|
||||
|
||||
#define NUM_GPIOS 64
|
||||
|
||||
// Because (FIXME) we currently don't tell API clients status on sent messages
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
// Create an a static instance of our plugin - this registers with the plugin system
|
||||
ReplyPlugin replyPlugin;
|
||||
|
||||
MeshPacket *ReplyPlugin::allocReply()
|
||||
{
|
||||
assert(currentRequest); // should always be !NULL
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "NodeDB.h"
|
||||
#include "PowerFSM.h"
|
||||
|
||||
TextMessagePlugin textMessagePlugin;
|
||||
TextMessagePlugin *textMessagePlugin;
|
||||
|
||||
bool TextMessagePlugin::handleReceived(const MeshPacket &mp)
|
||||
{
|
||||
|
||||
@@ -22,4 +22,4 @@ class TextMessagePlugin : public SinglePortPlugin, public Observable<const MeshP
|
||||
virtual bool handleReceived(const MeshPacket &mp);
|
||||
};
|
||||
|
||||
extern TextMessagePlugin textMessagePlugin;
|
||||
extern TextMessagePlugin *textMessagePlugin;
|
||||
Reference in New Issue
Block a user