mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-17 02:06:39 +01:00
comment out all mesh stuff
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
#ifndef __MESH_APP__
|
#ifndef __MESH_APP__
|
||||||
#define __MESH_APP__
|
#define __MESH_APP__
|
||||||
|
|
||||||
#include <painlessMesh.h>
|
#include <TaskScheduler.h>
|
||||||
#include <base/MeshSprocket.h>
|
//#include <painlessMesh.h>
|
||||||
#include <MeshNet.h>
|
//#include <MeshNet.h>
|
||||||
#include <DNSServer.h>
|
#include <Sprocket.h>
|
||||||
|
//#include <DNSServer.h>
|
||||||
|
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@@ -23,16 +24,17 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
const byte DNS_PORT = 53;
|
//const byte DNS_PORT = 53;
|
||||||
|
|
||||||
class IlluCat : public MeshSprocket {
|
class IlluCat : public Sprocket {
|
||||||
public:
|
public:
|
||||||
|
Scheduler* ts;
|
||||||
NeoPattern* pixels;
|
NeoPattern* pixels;
|
||||||
NeoPatternDto defaultState;
|
NeoPatternDto defaultState;
|
||||||
NeoPatternDto state;
|
NeoPatternDto state;
|
||||||
AsyncWebServer* server;
|
AsyncWebServer* server;
|
||||||
AsyncWebSocket* ws;
|
AsyncWebSocket* ws;
|
||||||
DNSServer* dnsServer;
|
//DNSServer* dnsServer;
|
||||||
|
|
||||||
NeoPixelConfig pixelConfig;
|
NeoPixelConfig pixelConfig;
|
||||||
SprocketConfig sprocketConfig;
|
SprocketConfig sprocketConfig;
|
||||||
@@ -41,7 +43,7 @@ class IlluCat : public MeshSprocket {
|
|||||||
|
|
||||||
SprocketMessage currentMessage;
|
SprocketMessage currentMessage;
|
||||||
|
|
||||||
IlluCat(SprocketConfig cfg, OtaConfig otaCfg, WebServerConfig webCfg/* , NeoPixelConfig pixelCfg */) : MeshSprocket(cfg) {
|
IlluCat(SprocketConfig cfg, OtaConfig otaCfg, WebServerConfig webCfg/* , NeoPixelConfig pixelCfg */) : Sprocket(cfg) {
|
||||||
//pixelConfig = pixelCfg;
|
//pixelConfig = pixelCfg;
|
||||||
|
|
||||||
sprocketConfig = cfg;
|
sprocketConfig = cfg;
|
||||||
@@ -53,6 +55,8 @@ class IlluCat : public MeshSprocket {
|
|||||||
pixelConfig.brightness = 32;
|
pixelConfig.brightness = 32;
|
||||||
pixelConfig.updateInterval = 100;
|
pixelConfig.updateInterval = 100;
|
||||||
pixelConfig.defaultColor = 100;
|
pixelConfig.defaultColor = 100;
|
||||||
|
|
||||||
|
ts = new Scheduler();
|
||||||
|
|
||||||
}
|
}
|
||||||
virtual void scanningAnimation() {
|
virtual void scanningAnimation() {
|
||||||
@@ -64,7 +68,7 @@ class IlluCat : public MeshSprocket {
|
|||||||
}
|
}
|
||||||
Sprocket* activate(Scheduler* scheduler, Network* network) {
|
Sprocket* activate(Scheduler* scheduler, Network* network) {
|
||||||
|
|
||||||
net = static_cast<MeshNet*>(network);
|
//net = static_cast<MeshNet*>(network);
|
||||||
|
|
||||||
// load config files from SPIFFS
|
// load config files from SPIFFS
|
||||||
if(SPIFFS.begin()){
|
if(SPIFFS.begin()){
|
||||||
@@ -77,10 +81,10 @@ class IlluCat : public MeshSprocket {
|
|||||||
pixels = new NeoPattern(pixelConfig.length, pixelConfig.pin, NEO_GRB + NEO_KHZ800);
|
pixels = new NeoPattern(pixelConfig.length, pixelConfig.pin, NEO_GRB + NEO_KHZ800);
|
||||||
server = new AsyncWebServer(80);
|
server = new AsyncWebServer(80);
|
||||||
ws = new AsyncWebSocket("/pixel");
|
ws = new AsyncWebSocket("/pixel");
|
||||||
dnsServer = new DNSServer();
|
//dnsServer = new DNSServer();
|
||||||
|
|
||||||
// add plugins
|
// add plugins
|
||||||
addPlugin(new OtaTcpPlugin(otaConfig));
|
//addPlugin(new OtaTcpPlugin(otaConfig));
|
||||||
addPlugin(new WebServerPlugin(webConfig, server));
|
addPlugin(new WebServerPlugin(webConfig, server));
|
||||||
addPlugin(new WebConfigPlugin(server));
|
addPlugin(new WebConfigPlugin(server));
|
||||||
addPlugin(new PixelPlugin(pixelConfig, pixels));
|
addPlugin(new PixelPlugin(pixelConfig, pixels));
|
||||||
@@ -88,8 +92,8 @@ class IlluCat : public MeshSprocket {
|
|||||||
|
|
||||||
// configure DNS
|
// configure DNS
|
||||||
// plugin?
|
// plugin?
|
||||||
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
//dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||||
dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
|
//dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
|
||||||
String softApPrt = "SoftAP IP: " + WiFi.softAPIP().toString();
|
String softApPrt = "SoftAP IP: " + WiFi.softAPIP().toString();
|
||||||
PRINT_MSG(Serial, SPROCKET_TYPE, softApPrt.c_str());
|
PRINT_MSG(Serial, SPROCKET_TYPE, softApPrt.c_str());
|
||||||
|
|
||||||
@@ -100,8 +104,8 @@ class IlluCat : public MeshSprocket {
|
|||||||
ws->onEvent(bind(&IlluCat::onWsEvent, this, _1, _2, _3, _4, _5, _6));
|
ws->onEvent(bind(&IlluCat::onWsEvent, this, _1, _2, _3, _4, _5, _6));
|
||||||
server->addHandler(ws);
|
server->addHandler(ws);
|
||||||
|
|
||||||
return MeshSprocket::activate(scheduler, network);
|
return Sprocket::activate(scheduler, network);
|
||||||
} using MeshSprocket::activate;
|
} using Sprocket::activate;
|
||||||
|
|
||||||
// TODO move to utils
|
// TODO move to utils
|
||||||
String getRequestParameterOrDefault(AsyncWebServerRequest *request, String param, String defaultValue, bool isPost = true){
|
String getRequestParameterOrDefault(AsyncWebServerRequest *request, String param, String defaultValue, bool isPost = true){
|
||||||
@@ -111,6 +115,8 @@ class IlluCat : public MeshSprocket {
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void patternWebRequestHandler(AsyncWebServerRequest *request) {
|
void patternWebRequestHandler(AsyncWebServerRequest *request) {
|
||||||
PRINT_MSG(Serial, SPROCKET_TYPE, "POST /pixel/api");
|
PRINT_MSG(Serial, SPROCKET_TYPE, "POST /pixel/api");
|
||||||
currentMessage.topic = getRequestParameterOrDefault(request, "topic", "");
|
currentMessage.topic = getRequestParameterOrDefault(request, "topic", "");
|
||||||
@@ -119,7 +125,7 @@ class IlluCat : public MeshSprocket {
|
|||||||
String msg = currentMessage.toJsonString();
|
String msg = currentMessage.toJsonString();
|
||||||
publish(currentMessage.topic, currentMessage.payload);
|
publish(currentMessage.topic, currentMessage.payload);
|
||||||
if(currentMessage.broadcast){
|
if(currentMessage.broadcast){
|
||||||
net->mesh.sendBroadcast(msg);
|
network.broadcast(msg);
|
||||||
}
|
}
|
||||||
request->send(200, "text/plain", msg);
|
request->send(200, "text/plain", msg);
|
||||||
}
|
}
|
||||||
@@ -137,14 +143,16 @@ class IlluCat : public MeshSprocket {
|
|||||||
currentMessage.from = from;
|
currentMessage.from = from;
|
||||||
publish(currentMessage.topic, currentMessage.payload);
|
publish(currentMessage.topic, currentMessage.payload);
|
||||||
if(currentMessage.broadcast){
|
if(currentMessage.broadcast){
|
||||||
net->mesh.sendBroadcast(msg);
|
network.broadcast(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(){
|
void loop(){
|
||||||
MeshSprocket::loop();
|
Sprocket::loop();
|
||||||
dnsServer->processNextRequest();
|
yield();
|
||||||
|
//ts->execute();
|
||||||
|
//dnsServer->processNextRequest();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,14 @@
|
|||||||
#define SPROCKET_MODE 0
|
#define SPROCKET_MODE 0
|
||||||
#define WIFI_CHANNEL 11
|
#define WIFI_CHANNEL 11
|
||||||
#define MESH_PORT 5555
|
#define MESH_PORT 5555
|
||||||
|
#define AP_SSID "illucat"
|
||||||
|
#define AP_PASSWORD "illumination"
|
||||||
#define MESH_PREFIX "illucat-mesh"
|
#define MESH_PREFIX "illucat-mesh"
|
||||||
#define MESH_PASSWORD "th3r31sn0sp00n"
|
#define MESH_PASSWORD "th3r31sn0sp00n"
|
||||||
#define STATION_SSID "MyAP"
|
#define STATION_SSID "MyAP"
|
||||||
#define STATION_PASSWORD "th3r31sn0sp00n"
|
#define STATION_PASSWORD "th3r31sn0sp00n"
|
||||||
#define HOSTNAME "illucat"
|
#define HOSTNAME "illucat"
|
||||||
|
#define CONNECT_TIMEOUT 10000
|
||||||
#define MESH_DEBUG_TYPES ERROR | STARTUP | CONNECTION
|
#define MESH_DEBUG_TYPES ERROR | STARTUP | CONNECTION
|
||||||
//ERROR | MESH_STATUS | CONNECTION | SYNC | COMMUNICATION | GENERAL | MSG_TYPES | REMOTE
|
//ERROR | MESH_STATUS | CONNECTION | SYNC | COMMUNICATION | GENERAL | MSG_TYPES | REMOTE
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "MeshNet.h"
|
//#include "MeshNet.h"
|
||||||
|
#include "WiFiNet.h"
|
||||||
#include "IlluCat.h"
|
#include "IlluCat.h"
|
||||||
|
|
||||||
MeshNet net({
|
/* MeshNet net({
|
||||||
SPROCKET_MODE, WIFI_CHANNEL,
|
SPROCKET_MODE, WIFI_CHANNEL,
|
||||||
MESH_PORT, MESH_PREFIX, MESH_PASSWORD,
|
MESH_PORT, MESH_PREFIX, MESH_PASSWORD,
|
||||||
STATION_SSID, STATION_PASSWORD, HOSTNAME,
|
STATION_SSID, STATION_PASSWORD, HOSTNAME,
|
||||||
MESH_DEBUG_TYPES
|
MESH_DEBUG_TYPES
|
||||||
});
|
}); */
|
||||||
|
WiFiNet net(SPROCKET_MODE,STATION_SSID, STATION_PASSWORD,AP_SSID, AP_PASSWORD,HOSTNAME,CONNECT_TIMEOUT);
|
||||||
IlluCat sprocket(
|
IlluCat sprocket(
|
||||||
{ STARTUP_DELAY, SERIAL_BAUD_RATE },
|
{ STARTUP_DELAY, SERIAL_BAUD_RATE },
|
||||||
{ OTA_PORT, OTA_PASSWORD },
|
{ OTA_PORT, OTA_PASSWORD },
|
||||||
|
|||||||
Reference in New Issue
Block a user