mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-18 10:46:40 +01:00
separate concerns
This commit is contained in:
39
src/wifiMesh/MeshCat.h
Normal file
39
src/wifiMesh/MeshCat.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef __MESHCAT__
|
||||
#define __MESHCAT__
|
||||
|
||||
#include <TaskSchedulerDeclarations.h>
|
||||
#include <MeshNet.h>
|
||||
#include <SprocketConfig.h>
|
||||
#include "utils_print.h"
|
||||
#include "IlluCat.h"
|
||||
#include "config.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
|
||||
class MeshCat : public IlluCat {
|
||||
public:
|
||||
Scheduler* meshScheduler;
|
||||
|
||||
MeshCat(SprocketConfig cfg, OtaConfig otaCfg, WebServerConfig webCfg) : IlluCat(cfg, otaCfg, webCfg) {
|
||||
meshScheduler = new Scheduler();
|
||||
}
|
||||
|
||||
Sprocket* join(Network& net){
|
||||
PRINT_MSG(Serial, SPROCKET_TYPE, "join mesh network");
|
||||
net.init(meshScheduler);
|
||||
net.onReceive(bind(&IlluCat::dispatch,this, _1, _2));
|
||||
net.connect();
|
||||
network = net;
|
||||
return activate(&scheduler, &net);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
meshScheduler->execute();
|
||||
yield();
|
||||
Sprocket::loop();
|
||||
yield();
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
25
src/wifiMesh/main.cpp
Normal file
25
src/wifiMesh/main.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "config.h"
|
||||
#include "MeshNet.h"
|
||||
#include "MeshCat.h"
|
||||
|
||||
MeshNet net({
|
||||
SPROCKET_MODE, WIFI_CHANNEL,
|
||||
MESH_PORT, MESH_PREFIX, MESH_PASSWORD,
|
||||
STATION_SSID, STATION_PASSWORD, HOSTNAME,
|
||||
MESH_DEBUG_TYPES
|
||||
});
|
||||
MeshCat sprocket(
|
||||
{ STARTUP_DELAY, SERIAL_BAUD_RATE },
|
||||
{ OTA_PORT, OTA_PASSWORD },
|
||||
{ WEB_CONTEXT_PATH, WEB_DOC_ROOT, WEB_DEFAULT_FILE }
|
||||
);
|
||||
|
||||
void setup() {
|
||||
delay(STARTUP_DELAY);
|
||||
sprocket.join(net);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
sprocket.loop();
|
||||
yield();
|
||||
}
|
||||
Reference in New Issue
Block a user