This commit is contained in:
2018-06-12 19:44:22 +00:00
parent a6d17ba6a3
commit 16b4f254e5
17 changed files with 98 additions and 254 deletions

View File

@@ -2,24 +2,18 @@
#define __MESH_APP__
#include <painlessMesh.h>
#include "App.h"
#include "MeshNet.h"
#define MESH_PREFIX "whateverYouLike"
#define MESH_PASSWORD "somethingSneaky"
#define MESH_PORT 5555
#include <Sprocket.h>
#include <MeshNet.h>
using namespace std;
using namespace std::placeholders;
class MeshApp : public App {
class MeshApp : public Sprocket {
public:
Task someTask;
MeshNet* net;
MeshApp() /* : App(sprkt) */ {
}
void activate(Scheduler* scheduler, Network* network) {
Sprocket* activate(Scheduler* scheduler, Network* network) {
net = static_cast<MeshNet*>(network);
net->mesh.onReceive(bind(&MeshApp::receivedCallback,this, _1, _2));
// add a task that sends stuff to the mesh
@@ -27,7 +21,7 @@ class MeshApp : public App {
bind(&MeshApp::advertise, this, net));
scheduler->addTask(someTask);
someTask.enable();
}
} using Sprocket::activate;
void advertise(MeshNet* network){
String msg = "Hi, my name is " + String(network->id);
@@ -40,6 +34,10 @@ class MeshApp : public App {
//String foo = String("cheerz back to ") + String(from);
//net->broadcast(foo);
}
void loop() {
net->update();
scheduler.execute();
}
};
#endif