mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-15 05:02:21 +01:00
add network update to loop
This commit is contained in:
@@ -21,6 +21,7 @@ Sprocket* Sprocket::activate() {
|
|||||||
|
|
||||||
Sprocket* Sprocket::join(Network& net){
|
Sprocket* Sprocket::join(Network& net){
|
||||||
Serial.println("join network");
|
Serial.println("join network");
|
||||||
|
hasNetwork = 1;
|
||||||
network = &net;
|
network = &net;
|
||||||
net.init(&scheduler);
|
net.init(&scheduler);
|
||||||
net.onReceive(bind(&Sprocket::dispatch,this, _1, _2));
|
net.onReceive(bind(&Sprocket::dispatch,this, _1, _2));
|
||||||
@@ -36,4 +37,5 @@ Sprocket* Sprocket::addTask(Task& tsk){
|
|||||||
|
|
||||||
void Sprocket::loop(){
|
void Sprocket::loop(){
|
||||||
scheduler.execute();
|
scheduler.execute();
|
||||||
|
if(hasNetwork) network->update();
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,7 @@ class Sprocket {
|
|||||||
protected:
|
protected:
|
||||||
Scheduler scheduler;
|
Scheduler scheduler;
|
||||||
Network* network;
|
Network* network;
|
||||||
|
int hasNetwork = 0;
|
||||||
public:
|
public:
|
||||||
SprocketConfig config;
|
SprocketConfig config;
|
||||||
Sprocket();
|
Sprocket();
|
||||||
|
|||||||
Reference in New Issue
Block a user