mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-16 10:04:30 +01:00
updated font, change order of config attributes
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <painlessMesh.h>
|
||||
#include <base/MeshSprocket.h>
|
||||
#include <MeshNet.h>
|
||||
#include <DNSServer.h>
|
||||
|
||||
|
||||
#include "config.h"
|
||||
@@ -22,6 +23,7 @@
|
||||
using namespace std;
|
||||
using namespace std::placeholders;
|
||||
|
||||
const byte DNS_PORT = 53;
|
||||
|
||||
class IlluCat : public MeshSprocket {
|
||||
public:
|
||||
@@ -30,6 +32,7 @@ class IlluCat : public MeshSprocket {
|
||||
NeoPatternDto state;
|
||||
AsyncWebServer* server;
|
||||
AsyncWebSocket* ws;
|
||||
DNSServer* dnsServer;
|
||||
|
||||
NeoPixelConfig pixelConfig;
|
||||
SprocketConfig sprocketConfig;
|
||||
@@ -76,12 +79,17 @@ class IlluCat : public MeshSprocket {
|
||||
pixels = new NeoPattern(pixelConfig.length, pixelConfig.pin, NEO_GRB + NEO_KHZ800);
|
||||
server = new AsyncWebServer(80);
|
||||
ws = new AsyncWebSocket("/pixel");
|
||||
dnsServer = new DNSServer();
|
||||
|
||||
addPlugin(new OtaTcpPlugin(otaConfig));
|
||||
addPlugin(new WebServerPlugin(webConfig, server));
|
||||
addPlugin(new WebConfigPlugin(server));
|
||||
addPlugin(new PixelPlugin(pixelConfig, pixels));
|
||||
|
||||
|
||||
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||
dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
|
||||
Serial.println(WiFi.softAPIP());
|
||||
defaultAnimation();
|
||||
|
||||
// setup web stuff
|
||||
@@ -98,8 +106,8 @@ class IlluCat : public MeshSprocket {
|
||||
|
||||
void patternWebRequestHandler(AsyncWebServerRequest *request) {
|
||||
Serial.println("POST /pixel/state");
|
||||
if(request->hasParam("msg", true)) {
|
||||
String inStr = request->getParam("msg", true)->value();
|
||||
if(request->hasParam("state", true)) {
|
||||
String inStr = request->getParam("state", true)->value();
|
||||
dispatch(0, inStr);
|
||||
}
|
||||
request->send(200, "text/plain", "OK");
|
||||
@@ -108,9 +116,8 @@ class IlluCat : public MeshSprocket {
|
||||
virtual void onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len) {
|
||||
if(type == WS_EVT_DATA){
|
||||
String frame = WsUtils::parseFrameAsString(type, arg, data, len, 0);
|
||||
dispatch(0, frame);
|
||||
// TODO broadcast enable/disable flag
|
||||
net->mesh.sendBroadcast(frame);
|
||||
dispatch(0, frame);
|
||||
client->text(String(millis()));
|
||||
}
|
||||
}
|
||||
@@ -126,7 +133,7 @@ class IlluCat : public MeshSprocket {
|
||||
virtual void onNewConnection(uint32_t nodeId){
|
||||
PRINT_MSG(Serial, SPROCKET_TYPE, "connected to %u", nodeId);
|
||||
// publish current state to new node
|
||||
// FIXME we got a memory leak here
|
||||
// TODO broadcast enable/disable flag
|
||||
//String stateJson = currentMessage.toJsonString();
|
||||
//net->mesh.sendSingle(nodeId, stateJson);
|
||||
}
|
||||
@@ -139,6 +146,7 @@ class IlluCat : public MeshSprocket {
|
||||
|
||||
void loop(){
|
||||
MeshSprocket::loop();
|
||||
dnsServer->processNextRequest();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user