add network update to loop

This commit is contained in:
2018-07-13 18:31:33 +02:00
parent d2c0998b8f
commit 9acd1cb6a8
2 changed files with 3 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ Sprocket* Sprocket::activate() {
Sprocket* Sprocket::join(Network& net){
Serial.println("join network");
hasNetwork = 1;
network = &net;
net.init(&scheduler);
net.onReceive(bind(&Sprocket::dispatch,this, _1, _2));
@@ -36,4 +37,5 @@ Sprocket* Sprocket::addTask(Task& tsk){
void Sprocket::loop(){
scheduler.execute();
if(hasNetwork) network->update();
}

View File

@@ -18,6 +18,7 @@ class Sprocket {
protected:
Scheduler scheduler;
Network* network;
int hasNetwork = 0;
public:
SprocketConfig config;
Sprocket();