mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 21:34:08 +01:00
move plugins to sprocket
This commit is contained in:
@@ -18,6 +18,11 @@ Sprocket* Sprocket::init(SprocketConfig cfg){
|
||||
Sprocket* Sprocket::activate() {
|
||||
return activate(&scheduler);
|
||||
}
|
||||
Sprocket* Sprocket::activate(Scheduler* scheduler, Network* network) {
|
||||
// setup plugins
|
||||
setupPlugins(scheduler, network);
|
||||
return this;
|
||||
}
|
||||
|
||||
Sprocket* Sprocket::join(Network& net){
|
||||
Serial.println("join network");
|
||||
@@ -35,4 +40,25 @@ Sprocket* Sprocket::addTask(Task& tsk){
|
||||
|
||||
void Sprocket::loop(){
|
||||
scheduler.execute();
|
||||
}
|
||||
|
||||
|
||||
void Sprocket::addPlugin(Plugin* p){
|
||||
plugins.reserve(1);
|
||||
plugins.push_back(p);
|
||||
}
|
||||
|
||||
void Sprocket::setupPlugins(Scheduler* scheduler, Network* network){
|
||||
for(Plugin* p : plugins){
|
||||
p->setup(scheduler, network);
|
||||
}
|
||||
}
|
||||
|
||||
void Sprocket::dispatchMessageToPlugins(MeshMessage msg){
|
||||
if(msg.type != MeshMessage::NONE){ // baaaa
|
||||
for(Plugin* p : plugins){
|
||||
Serial.println("dispatch to plugins");
|
||||
p->onMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user