introduce dispatch method to simplify things

This commit is contained in:
2018-07-13 16:16:44 +02:00
parent 6cfd065f41
commit b4ebd347eb
5 changed files with 15 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ class MeshApp : public Sprocket {
MeshApp(SprocketConfig cfg) : Sprocket(cfg) {}
Sprocket* activate(Scheduler* scheduler, Network* network) {
net = static_cast<MeshNet*>(network);
net->onReceive(bind(&MeshApp::onReceive,this, _1, _2));
//net->onReceive(bind(&MeshApp::onReceive,this, _1, _2));
// add a task that sends stuff to the mesh
someTask.set(TASK_SECOND * 5, TASK_FOREVER,
bind(&MeshApp::heartbeat, this, net));
@@ -28,7 +28,7 @@ class MeshApp : public Sprocket {
network->broadcast(msg);
}
void onReceive( uint32_t from, String &msg ) {
void dispatch( uint32_t from, String &msg ) {
Serial.printf("MeshApp: received from %u msg=%s\n", from, msg.c_str());
// respond in receive callback can cause an endless loop when all nodes run the same firmware
//String foo = String("cheerz back to ") + String(from);