mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 13:25:03 +01:00
Simplify
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user