move plugins to sprocket

This commit is contained in:
2018-08-24 17:42:35 +02:00
parent 426d495fd9
commit 5334d58433
11 changed files with 182 additions and 45 deletions

View File

@@ -3,11 +3,14 @@
#include <TaskSchedulerDeclarations.h>
#include <Arduino.h>
#include <vector>
#include "FS.h"
#ifdef ESP32
#include "SPIFFS.h"
#endif
#include "Network.h"
#include "SprocketConfig.h"
#include "Plugin.h"
using namespace std;
using namespace std::placeholders;
@@ -15,16 +18,12 @@ using namespace std::placeholders;
// FIXME move to some global fnc lib
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(array[0])
struct SprocketConfig {
int startupDelay;
int serialBaudRate;
};
class Sprocket {
protected:
Scheduler scheduler;
public:
SprocketConfig config;
std::vector<Plugin*> plugins;
Sprocket();
Sprocket(SprocketConfig);
Sprocket* init(SprocketConfig);
@@ -33,8 +32,12 @@ class Sprocket {
virtual void loop();
virtual Sprocket* activate();
virtual Sprocket* activate(Scheduler*) { return this; }
virtual Sprocket* activate(Scheduler*, Network*) { return this; }
virtual Sprocket* activate(Scheduler*, Network*);
virtual void dispatch( uint32_t from, String &msg ) {}
void addPlugin(Plugin* p);
void setupPlugins(Scheduler* scheduler, Network* network);
void dispatchMessageToPlugins(MeshMessage msg);
};
#endif