mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 13:25:03 +01:00
50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#ifndef __MESH_SPROCKET__
|
|
#define __MESH_SPROCKET__
|
|
|
|
#define DEBUG_ESP_OTA
|
|
#include <vector>
|
|
#include <painlessMesh.h>
|
|
#include <Sprocket.h>
|
|
#include <MeshNet.h>
|
|
#include <base/SprocketMessage.h>
|
|
#include <base/MeshSprocketConfig.h>
|
|
#include "config.h"
|
|
#include "utils_print.h"
|
|
|
|
using namespace std;
|
|
using namespace std::placeholders;
|
|
|
|
class MeshSprocket : public Sprocket {
|
|
public:
|
|
MeshNet* net;
|
|
|
|
MeshSprocket(){};
|
|
MeshSprocket(SprocketConfig cfg) : Sprocket(cfg) {
|
|
|
|
}
|
|
|
|
Sprocket* activate(Scheduler* scheduler) {
|
|
Sprocket::activate(scheduler);
|
|
//net = static_cast<MeshNet*>(network);
|
|
//net->onReceive(bind(&MeshSprocket::dispatch,this, _1, _2));
|
|
|
|
return this;
|
|
} using Sprocket::activate;
|
|
|
|
// TODO transmit SprocketMessage
|
|
virtual void dispatch( uint32_t from, String &msg ) {
|
|
SprocketMessage sMsg;
|
|
sMsg.fromJsonString(msg);
|
|
if(sMsg.valid){
|
|
sMsg.from = from;
|
|
publish(sMsg.topic, sMsg.payload);
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
//net->update();
|
|
scheduler.execute();
|
|
}
|
|
};
|
|
|
|
#endif |