add network as member of Sprocket

This commit is contained in:
2018-07-13 18:29:16 +02:00
parent b4ebd347eb
commit d2c0998b8f
3 changed files with 4 additions and 0 deletions

View File

@@ -35,6 +35,8 @@ void MeshNet::update(){
// only needed when no scheduler was passed to mesh.init
mesh.update();
}
// example, not used, to be removed
void MeshNet::onReceive( std::function<void(uint32_t from, String &msg)> cb) {
mesh.onReceive(cb);
}

View File

@@ -21,6 +21,7 @@ Sprocket* Sprocket::activate() {
Sprocket* Sprocket::join(Network& net){
Serial.println("join network");
network = &net;
net.init(&scheduler);
net.onReceive(bind(&Sprocket::dispatch,this, _1, _2));
net.connect();

View File

@@ -17,6 +17,7 @@ struct SprocketConfig {
class Sprocket {
protected:
Scheduler scheduler;
Network* network;
public:
SprocketConfig config;
Sprocket();